mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-06-16 19:54:23 +00:00
Compare commits
32 Commits
ecs-experi
...
windows-cl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80d0cd68f9 | ||
|
|
8e8d0153c8 | ||
|
|
badde23d1c | ||
|
|
bb9b2597e5 | ||
|
|
92d086c10b | ||
|
|
a0f2aebb4d | ||
|
|
9ea616bd9b | ||
|
|
ba2c692565 | ||
|
|
4133008d9c | ||
|
|
1f5982ed0e | ||
|
|
5e73fa5e4c | ||
|
|
fff7bf879f | ||
|
|
c20e1fbcf0 | ||
|
|
1f8ec6e295 | ||
|
|
51070d475d | ||
|
|
5a05622eca | ||
|
|
3760ffa349 | ||
|
|
9be88b3083 | ||
|
|
0772e563c1 | ||
|
|
4b99b984af | ||
|
|
628f6b4101 | ||
|
|
0d45403e8c | ||
|
|
fa017b6db9 | ||
|
|
10e64a5d20 | ||
|
|
83e08f63bc | ||
|
|
ece0e29577 | ||
|
|
6eea3f3662 | ||
|
|
6c8bb743af | ||
|
|
f4082cc538 | ||
|
|
edc7109e19 | ||
|
|
da45152b43 | ||
|
|
8b9a0768a2 |
@@ -3,7 +3,7 @@ CLIENT_PATH=./client
|
||||
# Updates NET_VERSION in CMakeVariables.txt
|
||||
NET_VERSION=171022
|
||||
# make sure this is a long random string
|
||||
# generate a "SHA 256-bit Key" from here: https://gchq.github.io/CyberChef/#recipe=Pseudo-Random_Number_Generator(256,'Hex')
|
||||
# grab a "SHA 256-bit Key" from here: https://keygen.io/
|
||||
ACCOUNT_MANAGER_SECRET=
|
||||
# Should be the externally facing IP of your server host
|
||||
EXTERNAL_IP=localhost
|
||||
|
||||
2
.github/workflows/build-and-push-docker.yml
vendored
2
.github/workflows/build-and-push-docker.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: CI
|
||||
name: Build and Update Docker
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
26
.github/workflows/build-and-test.yml
vendored
26
.github/workflows/build-and-test.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: CI
|
||||
name: Build And Test
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -14,6 +14,13 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ windows-2022, ubuntu-22.04, macos-13 ]
|
||||
include:
|
||||
- os: windows-2022
|
||||
configureType: windows-msvc
|
||||
- os: ubuntu-22.04
|
||||
configureType: linux-gnu
|
||||
- os: macos-13
|
||||
configureType: macos
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -33,20 +40,13 @@ jobs:
|
||||
- name: cmake
|
||||
uses: lukka/run-cmake@v10
|
||||
with:
|
||||
workflowPreset: "ci-${{matrix.os}}"
|
||||
configurePreset: "${{matrix.configureType}}"
|
||||
buildPreset: "ci-${{matrix.os}}"
|
||||
testPreset: "ci-${{matrix.os}}"
|
||||
|
||||
- name: artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-${{matrix.os}}
|
||||
path: |
|
||||
build/*/*Server*
|
||||
build/*/*.ini
|
||||
build/*/*.so
|
||||
build/*/*.dll
|
||||
build/*/*.dylib
|
||||
build/*/vanity/
|
||||
build/*/navmeshes/
|
||||
build/*/migrations/
|
||||
build/*/*.dcf
|
||||
!build/*/*.pdb
|
||||
!build/*/d*/
|
||||
build/*
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -4,7 +4,6 @@ RelWithDebInfo/
|
||||
docker/configs
|
||||
|
||||
# Third party libraries
|
||||
thirdparty/magic_enum
|
||||
thirdparty/mysql/
|
||||
thirdparty/mysql_linux/
|
||||
CMakeVariables.txt
|
||||
@@ -114,6 +113,8 @@ CMakeFiles/TargetDirectories.txt
|
||||
*.sln
|
||||
*.recipe
|
||||
|
||||
CMakeUserPresets.json
|
||||
|
||||
# clangd
|
||||
.cache
|
||||
thirdparty/zlib-1.2.11/
|
||||
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -14,3 +14,6 @@
|
||||
path = thirdparty/mariadb-connector-cpp
|
||||
url = https://github.com/mariadb-corporation/mariadb-connector-cpp.git
|
||||
ignore = dirty
|
||||
[submodule "thirdparty/magic_enum"]
|
||||
path = thirdparty/magic_enum
|
||||
url = https://github.com/Neargye/magic_enum.git
|
||||
|
||||
@@ -19,6 +19,14 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Export the compile commands for debuggi
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0063 NEW) # Set CMAKE visibility policy to NEW on project and subprojects
|
||||
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) # Set C and C++ symbol visibility to hide inlined functions
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||
|
||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: Debug, Release, RelWithDebInfo, MinSizeRel")
|
||||
|
||||
if (${CMAKE_BUILD_TYPE} MATCHES "") # CI likes to set CMAKE_BUILD_TYPE to an empty string
|
||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
|
||||
endif()
|
||||
|
||||
set(DLU_CONFIG_DIR ${CMAKE_SOURCE_DIR}/build CACHE PATH "The directory where the server configuration files are stored")
|
||||
|
||||
# Read variables from file
|
||||
FILE(READ "${CMAKE_SOURCE_DIR}/CMakeVariables.txt" variables)
|
||||
@@ -72,7 +80,7 @@ if(UNIX)
|
||||
|
||||
# For all except Clang and Apple Clang
|
||||
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
add_compile_options("-static-libgcc" "-lstdc++fs")
|
||||
add_compile_options("-static-libgcc" "-lstdc++fs" "-Wno-error=implicit-function-declaration" "-Wno-error=int-conversion")
|
||||
endif()
|
||||
|
||||
if(${DYNAMIC} AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
@@ -90,10 +98,11 @@ elseif(WIN32)
|
||||
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
# Our output dir
|
||||
#set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) # unfortunately, forces all libraries to be built in series, which will slow down the build process
|
||||
# Set the output directories
|
||||
# ./build/<platform + architecture (x64, x86, aarch64)>/<compiler>/<build_mode>/
|
||||
|
||||
set(CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_CXX_COMPILER_ID}/${CMAKE_BUILD_TYPE})
|
||||
|
||||
# TODO make this not have to override the build type directories
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
|
||||
@@ -108,43 +117,28 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
|
||||
# Get DLU config directory
|
||||
if(DEFINED ENV{DLU_CONFIG_DIR})
|
||||
set(DLU_CONFIG_DIR $ENV{DLU_CONFIG_DIR})
|
||||
else()
|
||||
set(DLU_CONFIG_DIR ${CMAKE_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
message(STATUS "Configuration Directory is ${DLU_CONFIG_DIR}, and the build directory is ${CMAKE_BINARY_DIR}")
|
||||
|
||||
find_package(MariaDB)
|
||||
|
||||
# Fetch third party dependencies
|
||||
set(DLU_THIRDPARTY_SOURCE_DIR ${CMAKE_SOURCE_DIR}/thirdparty)
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
magic_enum
|
||||
SYSTEM
|
||||
# SOURCE_DIR ${DLU_THIRDPARTY_SOURCE_DIR}/magic_enum
|
||||
GIT_REPOSITORY https://github.com/Neargye/magic_enum.git
|
||||
GIT_TAG v0.9.7
|
||||
)
|
||||
FetchContent_MakeAvailable(magic_enum)
|
||||
|
||||
include(CMakePrintHelpers)
|
||||
cmake_print_properties(TARGETS magic_enum::magic_enum PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES)
|
||||
|
||||
# Create a /resServer directory
|
||||
make_directory(${CMAKE_BINARY_DIR}/resServer)
|
||||
|
||||
# Create a /logs directory
|
||||
make_directory(${CMAKE_BINARY_DIR}/logs)
|
||||
|
||||
# Get DLU config directory
|
||||
if(DEFINED ENV{DLU_CONFIG_DIR})
|
||||
set(DLU_CONFIG_DIR $ENV{DLU_CONFIG_DIR})
|
||||
else()
|
||||
set(DLU_CONFIG_DIR ${PROJECT_BINARY_DIR})
|
||||
endif()
|
||||
message(STATUS "Variable: DLU_CONFIG_DIR = ${DLU_CONFIG_DIR}")
|
||||
|
||||
# Copy resource files on first build
|
||||
set(RESOURCE_FILES "sharedconfig.ini" "authconfig.ini" "chatconfig.ini" "worldconfig.ini" "masterconfig.ini" "blocklist.dcf")
|
||||
message(STATUS "Checking resource file integrity")
|
||||
|
||||
|
||||
include(Utils)
|
||||
UpdateConfigOption(${DLU_CONFIG_DIR}/authconfig.ini "port" "auth_server_port")
|
||||
UpdateConfigOption(${DLU_CONFIG_DIR}/chatconfig.ini "port" "chat_server_port")
|
||||
@@ -213,15 +207,15 @@ endforeach()
|
||||
message(STATUS "Resource file integrity check complete")
|
||||
|
||||
# if navmeshes directory does not exist, create it
|
||||
if(NOT EXISTS ${PROJECT_BINARY_DIR}/navmeshes)
|
||||
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/navmeshes)
|
||||
if(NOT EXISTS ${CMAKE_BINARY_DIR}/navmeshes)
|
||||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/navmeshes)
|
||||
endif()
|
||||
|
||||
# Copy navmesh data on first build and extract it
|
||||
configure_file(${CMAKE_SOURCE_DIR}/resources/navmeshes.zip ${PROJECT_BINARY_DIR}/navmeshes.zip COPYONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/resources/navmeshes.zip ${CMAKE_BINARY_DIR}/navmeshes.zip COPYONLY)
|
||||
|
||||
file(ARCHIVE_EXTRACT INPUT ${PROJECT_BINARY_DIR}/navmeshes.zip DESTINATION ${PROJECT_BINARY_DIR}/navmeshes)
|
||||
file(REMOVE ${PROJECT_BINARY_DIR}/navmeshes.zip)
|
||||
file(ARCHIVE_EXTRACT INPUT ${CMAKE_BINARY_DIR}/navmeshes.zip DESTINATION ${CMAKE_BINARY_DIR}/navmeshes)
|
||||
file(REMOVE ${CMAKE_BINARY_DIR}/navmeshes.zip)
|
||||
|
||||
# Copy vanity files on first build
|
||||
set(VANITY_FILES "CREDITS.md" "INFO.md" "TESTAMENT.md" "root.xml" "dev-tribute.xml" "atm.xml" "demo.xml")
|
||||
@@ -231,20 +225,20 @@ foreach(file ${VANITY_FILES})
|
||||
endforeach()
|
||||
|
||||
# Move our migrations for MasterServer to run
|
||||
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/migrations/dlu/)
|
||||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/migrations/dlu/)
|
||||
file(GLOB SQL_FILES ${CMAKE_SOURCE_DIR}/migrations/dlu/*.sql)
|
||||
|
||||
foreach(file ${SQL_FILES})
|
||||
get_filename_component(file ${file} NAME)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/migrations/dlu/${file} ${PROJECT_BINARY_DIR}/migrations/dlu/${file})
|
||||
configure_file(${CMAKE_SOURCE_DIR}/migrations/dlu/${file} ${CMAKE_BINARY_DIR}/migrations/dlu/${file})
|
||||
endforeach()
|
||||
|
||||
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/migrations/cdserver/)
|
||||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/migrations/cdserver/)
|
||||
file(GLOB SQL_FILES ${CMAKE_SOURCE_DIR}/migrations/cdserver/*.sql)
|
||||
|
||||
foreach(file ${SQL_FILES})
|
||||
get_filename_component(file ${file} NAME)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/migrations/cdserver/${file} ${PROJECT_BINARY_DIR}/migrations/cdserver/${file})
|
||||
configure_file(${CMAKE_SOURCE_DIR}/migrations/cdserver/${file} ${CMAKE_BINARY_DIR}/migrations/cdserver/${file})
|
||||
endforeach()
|
||||
|
||||
# Add system specfic includes for Apple, Windows and Other Unix OS' (including Linux)
|
||||
@@ -269,6 +263,7 @@ include_directories(
|
||||
"tests/dGameTests/dComponentsTests"
|
||||
|
||||
SYSTEM
|
||||
"thirdparty/magic_enum/include/magic_enum"
|
||||
"thirdparty/raknet/Source"
|
||||
"thirdparty/tinyxml2"
|
||||
"thirdparty/recastnavigation"
|
||||
@@ -319,7 +314,6 @@ file(
|
||||
# Add our library subdirectories for creation of the library object
|
||||
add_subdirectory(dCommon)
|
||||
add_subdirectory(dDatabase)
|
||||
add_subdirectory(dECS)
|
||||
add_subdirectory(dChatFilter)
|
||||
add_subdirectory(dNet)
|
||||
add_subdirectory(dScripts) # Add for dGame to use
|
||||
@@ -330,7 +324,7 @@ add_subdirectory(dPhysics)
|
||||
add_subdirectory(dServer)
|
||||
|
||||
# Create a list of common libraries shared between all binaries
|
||||
set(COMMON_LIBRARIES "dCommon" "dDatabase" "dNet" "raknet" "magic_enum::magic_enum")
|
||||
set(COMMON_LIBRARIES "dCommon" "dDatabase" "dNet" "raknet" "magic_enum")
|
||||
|
||||
# Add platform specific common libraries
|
||||
if(UNIX)
|
||||
|
||||
@@ -11,72 +11,37 @@
|
||||
"displayName": "Default configure step",
|
||||
"description": "Use 'build' dir and Unix makefiles",
|
||||
"binaryDir": "${sourceDir}/build",
|
||||
"generator": "Unix Makefiles"
|
||||
},
|
||||
{
|
||||
"name": "debug-config",
|
||||
"hidden": true,
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Debug"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "relwithdebinfo-config",
|
||||
"hidden": true,
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "release-config",
|
||||
"hidden": true,
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "clang-config",
|
||||
"hidden": true,
|
||||
"toolchainFile": "${sourceDir}/cmake/toolchains/linux-clang.cmake"
|
||||
},
|
||||
{
|
||||
"name": "gnu-config",
|
||||
"hidden": true,
|
||||
"toolchainFile": "${sourceDir}/cmake/toolchains/linux-gnu.cmake"
|
||||
},
|
||||
{
|
||||
"name": "windows-msvc",
|
||||
"inherits": "default",
|
||||
"displayName": "[Multi] Windows (MSVC)",
|
||||
"description": "Set architecture to 64-bit (b/c RakNet)",
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"binaryDir": "${sourceDir}/build/msvc",
|
||||
"architecture": {
|
||||
"value": "x64"
|
||||
},
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Windows"
|
||||
}
|
||||
"generator": "Unix Makefiles",
|
||||
"hidden": true
|
||||
},
|
||||
{
|
||||
"name": "windows-default",
|
||||
"inherits": "windows-msvc",
|
||||
"displayName": "Windows only Configure Settings",
|
||||
"inherits": "default",
|
||||
"displayName": "Windows Default Configure Settings",
|
||||
"description": "Sets build and install directories",
|
||||
"generator": "Ninja",
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Windows"
|
||||
},
|
||||
"architecture": {
|
||||
"value": "x64"
|
||||
}
|
||||
"hidden": true
|
||||
},
|
||||
{
|
||||
"name": "linux-config",
|
||||
"name": "windows-msvc",
|
||||
"inherits": "windows-default",
|
||||
"displayName": "Windows (MSVC)",
|
||||
"description": "Create a build using MSVC"
|
||||
},
|
||||
{
|
||||
"name": "windows-clang",
|
||||
"inherits": "windows-default",
|
||||
"displayName": "EXPERIMENTAL - Windows (Clang)",
|
||||
"description": "Create a build using Clang",
|
||||
"toolset": "ClangCL"
|
||||
},
|
||||
{
|
||||
"name": "linux-default",
|
||||
"inherits": "default",
|
||||
"hidden": true,
|
||||
"condition": {
|
||||
@@ -86,553 +51,74 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-debug",
|
||||
"inherits": [
|
||||
"linux-config",
|
||||
"clang-config",
|
||||
"debug-config"
|
||||
],
|
||||
"displayName": "EXPERIMENTAL - [Debug] Linux (Clang)",
|
||||
"description": "Create a debug build using the Clang toolchain for Linux",
|
||||
"binaryDir": "${sourceDir}/build/clang-debug"
|
||||
"name": "linux-clang",
|
||||
"inherits": "linux-default",
|
||||
"toolchainFile": "${sourceDir}/cmake/toolchains/linux-clang.cmake",
|
||||
"displayName": "Linux (Clang)",
|
||||
"description": "Create a build using the Clang toolchain for Linux"
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-relwithdebinfo",
|
||||
"inherits": [
|
||||
"linux-config",
|
||||
"clang-config",
|
||||
"relwithdebinfo-config"
|
||||
],
|
||||
"displayName": "EXPERIMENTAL - [RelWithDebInfo] Linux (Clang)",
|
||||
"description": "Create a release build with debug info using the Clang toolchain for Linux",
|
||||
"binaryDir": "${sourceDir}/build/clang-relwithdebinfo"
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-release",
|
||||
"inherits": [
|
||||
"linux-config",
|
||||
"clang-config",
|
||||
"release-config"
|
||||
],
|
||||
"displayName": "EXPERIMENTAL - [Release] Linux (Clang)",
|
||||
"description": "Create a release build using the Clang toolchain for Linux",
|
||||
"binaryDir": "${sourceDir}/build/clang-release"
|
||||
},
|
||||
{
|
||||
"name": "linux-gnu-debug",
|
||||
"inherits": [
|
||||
"linux-config",
|
||||
"gnu-config",
|
||||
"debug-config"
|
||||
],
|
||||
"displayName": "[Debug] Linux (GNU)",
|
||||
"description": "Create a debug build using the GNU toolchain for Linux",
|
||||
"binaryDir": "${sourceDir}/build/gnu-debug"
|
||||
},
|
||||
{
|
||||
"name": "linux-gnu-relwithdebinfo",
|
||||
"inherits": [
|
||||
"linux-config",
|
||||
"gnu-config",
|
||||
"relwithdebinfo-config"
|
||||
],
|
||||
"displayName": "[RelWithDebInfo] Linux (GNU)",
|
||||
"description": "Create a release build with debug info using the GNU toolchain for Linux",
|
||||
"binaryDir": "${sourceDir}/build/gnu-relwithdebinfo"
|
||||
},
|
||||
{
|
||||
"name": "linux-gnu-release",
|
||||
"inherits": [
|
||||
"linux-config",
|
||||
"gnu-config",
|
||||
"release-config"
|
||||
],
|
||||
"displayName": "[Release] Linux (GNU)",
|
||||
"description": "Create a release build using the GNU toolchain for Linux",
|
||||
"binaryDir": "${sourceDir}/build/gnu-release"
|
||||
"name": "linux-gnu",
|
||||
"inherits": "linux-default",
|
||||
"toolchainFile": "${sourceDir}/cmake/toolchains/linux-gnu.cmake",
|
||||
"displayName": "Linux (GNU)",
|
||||
"description": "Create a build using the GNU toolchain for Linux"
|
||||
},
|
||||
{
|
||||
"name": "macos",
|
||||
"inherits": "default",
|
||||
"displayName": "[Multi] MacOS",
|
||||
"displayName": "MacOS",
|
||||
"description": "Create a build for MacOS",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Darwin"
|
||||
},
|
||||
"binaryDir": "${sourceDir}/build/macos"
|
||||
}
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"configurePreset": "default",
|
||||
"displayName": "Default Build",
|
||||
"description": "Default Build",
|
||||
"jobs": 2
|
||||
},
|
||||
{
|
||||
"name": "windows-msvc-debug",
|
||||
"inherits": "default",
|
||||
"configurePreset": "windows-msvc",
|
||||
"displayName": "[Debug] Windows (MSVC)",
|
||||
"description": "This preset is used to build in debug mode using the MSVC toolchain on Windows",
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
"name": "windows-msvc-relwithdebinfo",
|
||||
"inherits": "default",
|
||||
"configurePreset": "windows-msvc",
|
||||
"displayName": "[RelWithDebInfo] Windows (MSVC)",
|
||||
"description": "This preset is used to build in debug mode using the MSVC toolchain on Windows",
|
||||
"configuration": "RelWithDebInfo"
|
||||
},
|
||||
{
|
||||
"name": "windows-msvc-release",
|
||||
"inherits": "default",
|
||||
"configurePreset": "windows-msvc",
|
||||
"displayName": "[Release] Windows (MSVC)",
|
||||
"description": "This preset is used to build in release mode using the MSVC toolchain on Windows",
|
||||
"configuration": "Release"
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-debug",
|
||||
"inherits": "default",
|
||||
"configurePreset": "linux-clang-debug",
|
||||
"displayName": "EXPERIMENTAL - [Debug] Linux (Clang)",
|
||||
"description": "This preset is used to build in debug mode using the Clang toolchain on Linux",
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-relwithdebinfo",
|
||||
"inherits": "default",
|
||||
"configurePreset": "linux-clang-relwithdebinfo",
|
||||
"displayName": "EXPERIMENTAL - [RelWithDebInfo] Linux (Clang)",
|
||||
"description": "This preset is used to build in release mode with debug info using the Clang toolchain on Linux",
|
||||
"configuration": "RelWithDebInfo"
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-release",
|
||||
"inherits": "default",
|
||||
"configurePreset": "linux-clang-release",
|
||||
"displayName": "EXPERIMENTAL - [Release] Linux (Clang)",
|
||||
"description": "This preset is used to build in release mode using the Clang toolchain on Linux",
|
||||
"configuration": "Release"
|
||||
},
|
||||
{
|
||||
"name": "linux-gnu-debug",
|
||||
"inherits": "default",
|
||||
"configurePreset": "linux-gnu-debug",
|
||||
"displayName": "[Debug] Linux (GNU)",
|
||||
"description": "This preset is used to build in debug mode using the GNU toolchain on Linux",
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
"name": "linux-gnu-relwithdebinfo",
|
||||
"inherits": "default",
|
||||
"configurePreset": "linux-gnu-relwithdebinfo",
|
||||
"displayName": "[RelWithDebInfo] Linux (GNU)",
|
||||
"description": "This preset is used to build in release mode with debug info using the GNU toolchain on Linux",
|
||||
"configuration": "RelWithDebInfo"
|
||||
},
|
||||
{
|
||||
"name": "linux-gnu-release",
|
||||
"inherits": "default",
|
||||
"configurePreset": "linux-gnu-release",
|
||||
"displayName": "[Release] Linux (GNU)",
|
||||
"description": "This preset is used to build in release mode using the GNU toolchain on Linux",
|
||||
"configuration": "Release"
|
||||
},
|
||||
{
|
||||
"name": "macos-debug",
|
||||
"inherits": "default",
|
||||
"configurePreset": "macos",
|
||||
"displayName": "[Debug] MacOS",
|
||||
"description": "This preset is used to build in debug mode on MacOS",
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
"name": "macos-relwithdebinfo",
|
||||
"inherits": "default",
|
||||
"configurePreset": "macos",
|
||||
"displayName": "[RelWithDebInfo] MacOS",
|
||||
"description": "This preset is used to build in release mode with debug info on MacOS",
|
||||
"configuration": "RelWithDebInfo"
|
||||
},
|
||||
{
|
||||
"name": "macos-release",
|
||||
"inherits": "default",
|
||||
"configurePreset": "macos",
|
||||
"displayName": "[Release] MacOS",
|
||||
"description": "This preset is used to build in release mode on MacOS",
|
||||
"configuration": "Release"
|
||||
}
|
||||
{ "name": "ci-ubuntu-22.04", "configurePreset": "linux-gnu" },
|
||||
{ "name": "ci-macos-13", "configurePreset": "macos" },
|
||||
{ "name": "ci-windows-2022", "configurePreset": "windows-msvc" }
|
||||
],
|
||||
"testPresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"hidden": true,
|
||||
"execution": {
|
||||
"jobs": 2
|
||||
},
|
||||
"output": {
|
||||
"outputOnFailure": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "default",
|
||||
"configurePreset": "default",
|
||||
"execution": {
|
||||
"jobs": 2
|
||||
},
|
||||
"output": {
|
||||
"outputOnFailure": true
|
||||
}
|
||||
"name": "ci-ubuntu-22.04",
|
||||
"configurePreset": "linux-gnu",
|
||||
"displayName": "CI Tests on Linux",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "windows-msvc-test",
|
||||
"inherits": "default",
|
||||
"name": "ci-macos-13",
|
||||
"configurePreset": "macos",
|
||||
"displayName": "CI Tests on MacOS",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "ci-windows-2022",
|
||||
"configurePreset": "windows-msvc",
|
||||
"hidden": true,
|
||||
"displayName": "CI Tests on windows",
|
||||
"inherits": "default",
|
||||
|
||||
"configuration": "RelWithDebInfo",
|
||||
"filter": {
|
||||
"exclude": {
|
||||
"name": "((example)|(minigzip))+"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-msvc-debug",
|
||||
"inherits": "windows-msvc-test",
|
||||
"configurePreset": "windows-msvc",
|
||||
"displayName": "[Debug] Windows (MSVC)",
|
||||
"description": "Runs all tests on a Windows configuration",
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
"name": "windows-msvc-relwithdebinfo",
|
||||
"inherits": "windows-msvc-test",
|
||||
"configurePreset": "windows-msvc",
|
||||
"displayName": "[RelWithDebInfo] Windows (MSVC)",
|
||||
"description": "Runs all tests on a Windows configuration",
|
||||
"configuration": "RelWithDebInfo"
|
||||
},
|
||||
{
|
||||
"name": "windows-msvc-release",
|
||||
"inherits": "windows-msvc-test",
|
||||
"configurePreset": "windows-msvc",
|
||||
"displayName": "[Release] Windows (MSVC)",
|
||||
"description": "Runs all tests on a Windows configuration",
|
||||
"configuration": "Release"
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-debug",
|
||||
"inherits": "default",
|
||||
"configurePreset": "linux-clang-debug",
|
||||
"displayName": "EXPERIMENTAL - [Debug] Linux (Clang)",
|
||||
"description": "Runs all tests on a Linux Clang configuration",
|
||||
"configuration": "Release"
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-relwithdebinfo",
|
||||
"inherits": "default",
|
||||
"configurePreset": "linux-clang-relwithdebinfo",
|
||||
"displayName": "EXPERIMENTAL - [RelWithDebInfo] Linux (Clang)",
|
||||
"description": "Runs all tests on a Linux Clang configuration",
|
||||
"configuration": "RelWithDebInfo"
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-release",
|
||||
"inherits": "default",
|
||||
"configurePreset": "linux-clang-release",
|
||||
"displayName": "EXPERIMENTAL - [Release] Linux (Clang)",
|
||||
"description": "Runs all tests on a Linux Clang configuration",
|
||||
"configuration": "Release"
|
||||
},
|
||||
{
|
||||
"name": "linux-gnu-debug",
|
||||
"inherits": "default",
|
||||
"configurePreset": "linux-gnu-debug",
|
||||
"displayName": "[Debug] Linux (GNU)",
|
||||
"description": "Runs all tests on a Linux GNU configuration",
|
||||
"configuration": "Release"
|
||||
},
|
||||
{
|
||||
"name": "linux-gnu-relwithdebinfo",
|
||||
"inherits": "default",
|
||||
"configurePreset": "linux-gnu-relwithdebinfo",
|
||||
"displayName": "[RelWithDebInfo] Linux (GNU)",
|
||||
"description": "Runs all tests on a Linux GNU configuration",
|
||||
"configuration": "RelWithDebInfo"
|
||||
},
|
||||
{
|
||||
"name": "linux-gnu-release",
|
||||
"inherits": "default",
|
||||
"configurePreset": "linux-gnu-release",
|
||||
"displayName": "[Release] Linux (GNU)",
|
||||
"description": "Runs all tests on a Linux GNU configuration",
|
||||
"configuration": "Release"
|
||||
},
|
||||
{
|
||||
"name": "macos-debug",
|
||||
"inherits": "default",
|
||||
"configurePreset": "macos",
|
||||
"displayName": "[Debug] MacOS",
|
||||
"description": "Runs all tests on a MacOS configuration",
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
"name": "macos-relwithdebinfo",
|
||||
"inherits": "default",
|
||||
"configurePreset": "macos",
|
||||
"displayName": "[RelWithDebInfo] MacOS",
|
||||
"description": "Runs all tests on a MacOS configuration",
|
||||
"configuration": "RelWithDebInfo"
|
||||
},
|
||||
{
|
||||
"name": "macos-release",
|
||||
"inherits": "default",
|
||||
"configurePreset": "macos",
|
||||
"displayName": "[Release] MacOS",
|
||||
"description": "Runs all tests on a MacOS configuration",
|
||||
"configuration": "Release"
|
||||
}
|
||||
],
|
||||
"workflowPresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "default"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "default"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"name": "default"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "windows-msvc-debug",
|
||||
"displayName": "[Debug] Windows (MSVC)",
|
||||
"description": "MSVC debug workflow preset for Windows",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "windows-msvc"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "windows-msvc-debug"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"name": "windows-msvc-debug"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "windows-msvc-relwithdebinfo",
|
||||
"displayName": "[RelWithDebInfo] Windows (MSVC)",
|
||||
"description": "MSVC release with debug info workflow preset for Windows",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "windows-msvc"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "windows-msvc-relwithdebinfo"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"name": "windows-msvc-relwithdebinfo"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ci-windows-2022",
|
||||
"displayName": "[Release] Windows (MSVC)",
|
||||
"description": "CI workflow preset for Windows",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "windows-msvc"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "windows-msvc-release"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"name": "windows-msvc-release"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "linux-gnu-debug",
|
||||
"displayName": "[Debug] Linux (GNU)",
|
||||
"description": "GNU debug workflow preset for Linux",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "linux-gnu-debug"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "linux-gnu-debug"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"name": "linux-gnu-debug"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "linux-gnu-relwithdebinfo",
|
||||
"displayName": "[RelWithDebInfo] Linux (GNU)",
|
||||
"description": "GNU release with debug info workflow preset for Linux",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "linux-gnu-relwithdebinfo"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "linux-gnu-relwithdebinfo"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"name": "linux-gnu-relwithdebinfo"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ci-ubuntu-22.04",
|
||||
"displayName": "[Release] Linux (GNU)",
|
||||
"description": "CI workflow preset for Ubuntu",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "linux-gnu-release"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "linux-gnu-release"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"name": "linux-gnu-release"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-debug",
|
||||
"displayName": "EXPERIMENTAL - [Debug] Linux (Clang)",
|
||||
"description": "Clang debug workflow preset for Linux",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "linux-clang-debug"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "linux-clang-debug"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"name": "linux-clang-debug"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-relwithdebinfo",
|
||||
"displayName": "EXPERIMENTAL - [RelWithDebInfo] Linux (Clang)",
|
||||
"description": "Clang release with debug info workflow preset for Linux",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "linux-clang-relwithdebinfo"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "linux-clang-relwithdebinfo"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"name": "linux-clang-relwithdebinfo"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-release",
|
||||
"displayName": "EXPERIMENTAL - [Release] Linux (Clang)",
|
||||
"description": "Clang release workflow preset for Linux",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "linux-clang-release"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "linux-clang-release"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"name": "linux-clang-release"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "macos-debug",
|
||||
"displayName": "[Debug] MacOS",
|
||||
"description": "Release workflow preset for MacOS",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "macos"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "macos-debug"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"name": "macos-debug"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "macos-relwithdebinfo",
|
||||
"displayName": "[RelWithDebInfo] MacOS",
|
||||
"description": "Release with debug info workflow preset for MacOS",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "macos"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "macos-relwithdebinfo"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"name": "macos-relwithdebinfo"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ci-macos-13",
|
||||
"displayName": "[Release] MacOS",
|
||||
"description": "CI workflow preset for MacOS",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "macos"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "macos-release"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"name": "macos-release"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
18
Dockerfile
18
Dockerfile
@@ -23,23 +23,23 @@ RUN --mount=type=cache,id=build-apt-cache,target=/var/cache/apt \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Grab libraries and load them
|
||||
COPY --from=build /app/build/mariadbcpp/libmariadbcpp.so /usr/local/lib/
|
||||
COPY --from=build /app/build/Linux-x86_64/GNU/Release/mariadbcpp/libmariadbcpp.so /usr/local/lib/
|
||||
RUN ldconfig
|
||||
|
||||
# Server bins
|
||||
COPY --from=build /app/build/*Server /app/
|
||||
COPY --from=build /app/build/Linux-x86_64/GNU/Release/*Server /app/
|
||||
|
||||
# Necessary suplimentary files
|
||||
COPY --from=build /app/build/*.ini /app/configs/
|
||||
COPY --from=build /app/build/vanity/*.* /app/vanity/
|
||||
COPY --from=build /app/build/navmeshes /app/navmeshes
|
||||
COPY --from=build /app/build/migrations /app/migrations
|
||||
COPY --from=build /app/build/*.dcf /app/
|
||||
COPY --from=build /app/build/Linux-x86_64/GNU/Release/*.ini /app/configs/
|
||||
COPY --from=build /app/build/Linux-x86_64/GNU/Release/vanity/*.* /app/vanity/
|
||||
COPY --from=build /app/build/Linux-x86_64/GNU/Release/navmeshes /app/navmeshes
|
||||
COPY --from=build /app/build/Linux-x86_64/GNU/Release/migrations /app/migrations
|
||||
COPY --from=build /app/build/Linux-x86_64/GNU/Release/*.dcf /app/
|
||||
|
||||
# backup of config and vanity files to copy to the host incase
|
||||
# of a mount clobbering the copy from above
|
||||
COPY --from=build /app/build/*.ini /app/default-configs/
|
||||
COPY --from=build /app/build/vanity/*.* /app/default-vanity/
|
||||
COPY --from=build /app/build/Linux-x86_64/GNU/Release/*.ini /app/default-configs/
|
||||
COPY --from=build /app/build/Linux-x86_64/GNU/Release/vanity/*.* /app/default-vanity/
|
||||
|
||||
# needed as the container runs with the root user
|
||||
# and therefore sudo doesn't exist
|
||||
|
||||
@@ -371,7 +371,7 @@ at once. For that:
|
||||
- Download the [.env.example](.env.example) file and place it next to `client` with the file name `.env`
|
||||
- You may get warnings that this name starts with a dot, acknowledge those, this is intentional. Depending on your operating system, you may need to activate showing hidden files (e.g. Ctrl-H in Gnome on Linux) and/or file extensions ("File name extensions" in the "View" tab on Windows).
|
||||
- Update the `ACCOUNT_MANAGER_SECRET` and `MARIADB_PASSWORD` with strong random passwords.
|
||||
- Use a password generator <https://gchq.github.io/CyberChef/#recipe=Pseudo-Random_Number_Generator(256,'Hex')>
|
||||
- Use a password generator like <https://keygen.io>
|
||||
- Avoid `:` and `@` characters
|
||||
- Once the database user is created, changing the password will not update it, so the server will just fail to connect.
|
||||
- Set `EXTERNAL_IP` to your LAN IP or public IP if you want to host the game for friends & family
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# On Windows ClangCL can't compile the connector from source but can link to an msvc compiled one,
|
||||
# so prefer the prebuilt binaries unless MARIADB_BUILD_SOURCE is specified
|
||||
if(WIN32 AND NOT MARIADB_BUILD_SOURCE)
|
||||
set(MARIADB_MSI_DIR "${PROJECT_BINARY_DIR}/msi")
|
||||
set(MARIADB_CONNECTOR_DIR "${PROJECT_BINARY_DIR}/mariadbcpp")
|
||||
set(MARIADB_MSI_DIR "${CMAKE_BINARY_DIR}/msi")
|
||||
set(MARIADB_CONNECTOR_DIR "${CMAKE_BINARY_DIR}/mariadbcpp")
|
||||
set(MARIADB_C_CONNECTOR_DIR "${MARIADB_CONNECTOR_DIR}/MariaDB/MariaDB Connector C 64-bit")
|
||||
set(MARIADB_CPP_CONNECTOR_DIR "${MARIADB_CONNECTOR_DIR}/MariaDB/MariaDB C++ Connector 64-bit")
|
||||
|
||||
@@ -59,7 +59,7 @@ if(WIN32 AND NOT MARIADB_BUILD_SOURCE)
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${MARIADBCPP_SHARED_LIBRARY_LOCATION}"
|
||||
"${MARIADBC_SHARED_LIBRARY_LOCATION}"
|
||||
"${PROJECT_BINARY_DIR}")
|
||||
"${CMAKE_BINARY_DIR}")
|
||||
|
||||
# MariaDB uses plugins that the database needs to load, the prebuilt binaries by default will try to find the libraries in system directories,
|
||||
# so set this define and the servers will set the MARIADB_PLUGIN_DIR environment variable to the appropriate directory.
|
||||
@@ -86,13 +86,13 @@ else() # Build from source
|
||||
-DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0)
|
||||
endif()
|
||||
|
||||
set(MARIADBCPP_INSTALL_DIR ${PROJECT_BINARY_DIR}/prefix)
|
||||
set(MARIADBCPP_LIBRARY_DIR ${PROJECT_BINARY_DIR}/mariadbcpp)
|
||||
set(MARIADBCPP_INSTALL_DIR ${CMAKE_BINARY_DIR}/prefix)
|
||||
set(MARIADBCPP_LIBRARY_DIR ${CMAKE_BINARY_DIR}/mariadbcpp)
|
||||
set(MARIADBCPP_PLUGIN_DIR ${MARIADBCPP_LIBRARY_DIR}/plugin)
|
||||
set(MARIADBCPP_SOURCE_DIR ${PROJECT_SOURCE_DIR}/thirdparty/mariadb-connector-cpp)
|
||||
set(MARIADB_INCLUDE_DIR "${MARIADBCPP_SOURCE_DIR}/include")
|
||||
ExternalProject_Add(mariadb_connector_cpp
|
||||
PREFIX "${PROJECT_BINARY_DIR}/thirdparty/mariadb-connector-cpp"
|
||||
PREFIX "${CMAKE_BINARY_DIR}/thirdparty/mariadb-connector-cpp"
|
||||
SOURCE_DIR ${MARIADBCPP_SOURCE_DIR}
|
||||
INSTALL_DIR ${MARIADBCPP_INSTALL_DIR}
|
||||
CMAKE_ARGS -Wno-dev
|
||||
@@ -127,20 +127,20 @@ else() # Build from source
|
||||
endif()
|
||||
|
||||
# Create mariadb connector library object
|
||||
add_library(MariaDB::ConnCpp SHARED IMPORTED GLOBAL)
|
||||
add_dependencies(MariaDB::ConnCpp mariadb_connector_cpp)
|
||||
set_target_properties(MariaDB::ConnCpp PROPERTIES
|
||||
add_library(mariadb_cpp_connector SHARED IMPORTED GLOBAL)
|
||||
add_dependencies(mariadb_cpp_connector mariadb_connector_cpp)
|
||||
set_target_properties(mariadb_cpp_connector PROPERTIES
|
||||
IMPORTED_LOCATION "${MARIADBCPP_SHARED_LIBRARY_LOCATION}")
|
||||
|
||||
if(WIN32)
|
||||
set_target_properties(MariaDB::ConnCpp PROPERTIES
|
||||
set_target_properties(mariadb_cpp_connector PROPERTIES
|
||||
IMPORTED_IMPLIB "${MARIADB_IMPLIB_LOCATION}")
|
||||
elseif(APPLE)
|
||||
set_target_properties(MariaDB::ConnCpp PROPERTIES
|
||||
set_target_properties(mariadb_cpp_connector PROPERTIES
|
||||
IMPORTED_SONAME "libmariadbcpp")
|
||||
endif()
|
||||
|
||||
# Add directories to include lists
|
||||
target_include_directories(MariaDB::ConnCpp SYSTEM INTERFACE ${MARIADB_INCLUDE_DIR})
|
||||
target_include_directories(mariadb_cpp_connector SYSTEM INTERFACE ${MARIADB_INCLUDE_DIR})
|
||||
|
||||
set(MariaDB_FOUND TRUE)
|
||||
set(mariadb_found TRUE)
|
||||
|
||||
@@ -45,11 +45,15 @@ if (UNIX)
|
||||
elseif (WIN32)
|
||||
include(FetchContent)
|
||||
|
||||
set(WITH_GTEST OFF CACHE BOOL "" FORCE)
|
||||
set(ZLIB_ENABLE_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(ZLIB_COMPAT ON CACHE BOOL "Enable ZLIB compatibility mode" FORCE)
|
||||
|
||||
# TODO Keep an eye on the zlib repository for an update to disable testing. Don't forget to update CMakePresets
|
||||
FetchContent_Declare(
|
||||
zlib
|
||||
URL https://github.com/madler/zlib/archive/refs/tags/v1.2.11.zip
|
||||
URL_HASH MD5=9d6a627693163bbbf3f26403a3a0b0b1
|
||||
URL https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.2.2.zip
|
||||
URL_HASH MD5=2cf9199fb785ea579a2a9905a75c38b3
|
||||
)
|
||||
|
||||
# Disable warning about no project version.
|
||||
@@ -60,7 +64,6 @@ elseif (WIN32)
|
||||
FetchContent_MakeAvailable(zlib)
|
||||
|
||||
set(ZLIB_INCLUDE_DIRS ${zlib_SOURCE_DIR} ${zlib_BINARY_DIR})
|
||||
set_target_properties(zlib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIRS}")
|
||||
add_library(ZLIB::ZLIB ALIAS zlib)
|
||||
else ()
|
||||
message(
|
||||
@@ -70,6 +73,5 @@ else ()
|
||||
endif ()
|
||||
|
||||
target_link_libraries(dCommon
|
||||
PUBLIC magic_enum::magic_enum
|
||||
PRIVATE ZLIB::ZLIB bcrypt tinyxml2
|
||||
INTERFACE dDatabase)
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace ZCompression {
|
||||
}
|
||||
|
||||
int32_t Compress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst) {
|
||||
|
||||
z_stream zInfo = { 0 };
|
||||
zInfo.total_in = zInfo.avail_in = nLenSrc;
|
||||
zInfo.total_out = zInfo.avail_out = nLenDst;
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "Game.h"
|
||||
#include "Logger.h"
|
||||
|
||||
#include "zlib.h"
|
||||
|
||||
AssetManager::AssetManager(const std::filesystem::path& path) {
|
||||
if (!std::filesystem::is_directory(path)) {
|
||||
throw std::runtime_error("Attempted to load asset bundle (" + path.string() + ") however it is not a valid directory.");
|
||||
@@ -82,7 +80,7 @@ bool AssetManager::HasFile(const char* name) {
|
||||
if (fixedName.rfind("client\\res\\", 0) != 0) fixedName = "client\\res\\" + fixedName;
|
||||
|
||||
uint32_t crc = crc32b(0xFFFFFFFF, reinterpret_cast<uint8_t*>(const_cast<char*>(fixedName.c_str())), fixedName.size());
|
||||
crc = crc32b(crc, reinterpret_cast<Bytef*>(const_cast<char*>("\0\0\0\0")), 4);
|
||||
crc = crc32b(crc, reinterpret_cast<uint8_t*>(const_cast<char*>("\0\0\0\0")), 4);
|
||||
|
||||
for (const auto& item : this->m_PackIndex->GetPackFileIndices()) {
|
||||
if (item.m_Crc == crc) {
|
||||
@@ -130,7 +128,7 @@ bool AssetManager::GetFile(const char* name, char** data, uint32_t* len) {
|
||||
}
|
||||
int32_t packIndex = -1;
|
||||
uint32_t crc = crc32b(0xFFFFFFFF, reinterpret_cast<uint8_t*>(const_cast<char*>(fixedName.c_str())), fixedName.size());
|
||||
crc = crc32b(crc, reinterpret_cast<Bytef*>(const_cast<char*>("\0\0\0\0")), 4);
|
||||
crc = crc32b(crc, reinterpret_cast<uint8_t*>(const_cast<char*>("\0\0\0\0")), 4);
|
||||
|
||||
for (const auto& item : this->m_PackIndex->GetPackFileIndices()) {
|
||||
if (item.m_Crc == crc) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include "magic_enum.hpp"
|
||||
|
||||
namespace MessageType {
|
||||
enum class Game : uint16_t {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include "magic_enum.hpp"
|
||||
|
||||
namespace MessageType {
|
||||
enum class World : uint32_t {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define __STRINGIFIEDENUM_H__
|
||||
|
||||
#include <string>
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include "magic_enum.hpp"
|
||||
|
||||
namespace StringifiedEnum {
|
||||
template<typename T>
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#define DARKFLAME_PLATFORM_IOS
|
||||
#elif TARGET_OS_MAC
|
||||
#define DARKFLAME_PLATFORM_MACOS
|
||||
#pragma clang diagnostic push // prevent pragma messages being counted as a warning
|
||||
#pragma clang diagnostic ignored "-W#pragma-messages"
|
||||
#else
|
||||
#error unknown Apple operating system
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include "magic_enum.hpp"
|
||||
|
||||
static const uint8_t NUMBER_OF_INVENTORIES = 17;
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,12 @@ add_subdirectory(CDClientDatabase)
|
||||
add_subdirectory(GameDatabase)
|
||||
|
||||
add_library(dDatabase STATIC "MigrationRunner.cpp")
|
||||
|
||||
add_custom_target(conncpp_dylib
|
||||
${CMAKE_COMMAND} -E copy $<TARGET_FILE:mariadb_cpp_connector> ${CMAKE_BINARY_DIR})
|
||||
|
||||
add_dependencies(dDatabase conncpp_dylib)
|
||||
|
||||
target_include_directories(dDatabase PUBLIC ".")
|
||||
target_link_libraries(dDatabase
|
||||
PUBLIC magic_enum::magic_enum dDatabaseCDClient dDatabaseGame)
|
||||
PUBLIC dDatabaseCDClient dDatabaseGame)
|
||||
|
||||
@@ -21,7 +21,7 @@ target_include_directories(dDatabaseGame PUBLIC "."
|
||||
"${PROJECT_SOURCE_DIR}/dCommon/dEnums"
|
||||
)
|
||||
target_link_libraries(dDatabaseGame
|
||||
PUBLIC MariaDB::ConnCpp
|
||||
PUBLIC mariadb_cpp_connector
|
||||
INTERFACE dCommon)
|
||||
|
||||
# Glob together all headers that need to be precompiled
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
set(gcc_like_cxx "$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,Clang,GNU,LCC>")
|
||||
set(msvc_cxx "$<COMPILE_LANG_AND_ID:CXX,MSVC>")
|
||||
|
||||
add_library(dECS STATIC
|
||||
"Core.h"
|
||||
"Iter.h"
|
||||
"Core.cpp"
|
||||
"System.cpp"
|
||||
)
|
||||
target_include_directories(dECS PUBLIC .)
|
||||
target_link_libraries(dECS PRIVATE dCommon magic_enum::magic_enum)
|
||||
target_compile_options(dECS PRIVATE
|
||||
"$<${gcc_like_cxx}:$<BUILD_INTERFACE:-Wall;-Wextra>>"
|
||||
"$<${msvc_cxx}:$<BUILD_INTERFACE:/W3>>"
|
||||
)
|
||||
@@ -1,70 +0,0 @@
|
||||
#include <atomic>
|
||||
#include <magic_enum/magic_enum_containers.hpp>
|
||||
#include <eReplicaComponentType.h>
|
||||
#include "Core.h"
|
||||
|
||||
namespace dECS {
|
||||
struct WorldData {
|
||||
using CompSignature = magic_enum::containers::bitset<eReplicaComponentType>;
|
||||
using CompMap = std::unordered_map<LWOOBJID, CompSignature>;
|
||||
using CompStorage = std::unordered_map<eReplicaComponentType, std::unique_ptr<IStorage>>;
|
||||
|
||||
std::atomic<LWOOBJID> nextId = 1;
|
||||
CompMap map;
|
||||
CompStorage data;
|
||||
};
|
||||
|
||||
World::World() : m_World{ std::make_shared<WorldData>() } {};
|
||||
|
||||
Entity World::MakeEntity() {
|
||||
return Entity{ m_World->nextId.fetch_add(1, std::memory_order::relaxed),
|
||||
m_World };
|
||||
}
|
||||
|
||||
void* Entity::AddComponent(const eReplicaComponentType kind, const StorageConstructor storageConstructor) {
|
||||
if (auto w = m_World.lock()) {
|
||||
// Add to kind signature
|
||||
w->map[m_Id].set(kind, true);
|
||||
|
||||
// Get or add storage
|
||||
auto storageIt = w->data.find(kind);
|
||||
if (storageIt == w->data.cend()) {
|
||||
bool inserted = false;
|
||||
std::tie(storageIt, inserted) = w->data.try_emplace(kind, storageConstructor());
|
||||
if (!inserted) throw "storage emplacement failure";
|
||||
}
|
||||
auto& storage = *storageIt->second;
|
||||
|
||||
// Return reference if already mapped, otherwise add component
|
||||
auto compIt = storage.rowMap.find(m_Id);
|
||||
if (compIt == storage.rowMap.cend()) {
|
||||
const auto curSize = storage.rowMap.size();
|
||||
storage.rowMap.emplace(m_Id, curSize);
|
||||
return storage.emplace_back();
|
||||
}
|
||||
const auto row = compIt->second;
|
||||
return storage.at(row);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const void* Entity::GetComponent(const eReplicaComponentType kind) const {
|
||||
if (auto const w = m_World.lock()) {
|
||||
// Check that the entity has this component
|
||||
if (!w->map[m_Id].test(kind)) return nullptr;
|
||||
|
||||
// Get the location where it's stored
|
||||
const auto& storage = *w->data.at(kind);
|
||||
const auto it = storage.rowMap.find(m_Id);
|
||||
if (it == storage.rowMap.cend()) return nullptr;
|
||||
const auto row = it->second;
|
||||
return storage.at(row);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* Entity::GetComponent(const eReplicaComponentType kind) {
|
||||
// Casting away const for this overload is safe, if not at all pretty
|
||||
return const_cast<void*>(std::as_const(*this).GetComponent(kind));
|
||||
}
|
||||
}
|
||||
180
dECS/Core.h
180
dECS/Core.h
@@ -1,180 +0,0 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
class Component;
|
||||
enum class eReplicaComponentType : uint32_t;
|
||||
using LWOOBJID = int64_t;
|
||||
|
||||
namespace dECS {
|
||||
// template <typename C>
|
||||
// concept IsComponent = std::derived_from<C, Component>;
|
||||
|
||||
// Data structures
|
||||
struct WorldData;
|
||||
class World;
|
||||
|
||||
template <typename... Cs>
|
||||
class System;
|
||||
|
||||
class Entity;
|
||||
struct IStorage;
|
||||
|
||||
template <typename C>
|
||||
class Storage;
|
||||
|
||||
using WorldPtr = std::shared_ptr<WorldData>;
|
||||
using WeakWorldPtr = std::weak_ptr<WorldData>;
|
||||
|
||||
class World {
|
||||
public:
|
||||
World();
|
||||
|
||||
[[nodiscard]]
|
||||
Entity MakeEntity();
|
||||
|
||||
template <typename... Cs>
|
||||
[[nodiscard]]
|
||||
System<Cs...> MakeSystem() {
|
||||
return System<Cs...>{};
|
||||
}
|
||||
|
||||
template <typename... Cs, typename S>
|
||||
[[nodiscard]]
|
||||
System<Cs...> MakeSystem(S&& name) {
|
||||
return System<Cs...>{ std::forward<S>(name) };
|
||||
}
|
||||
|
||||
private:
|
||||
WorldPtr m_World;
|
||||
};
|
||||
|
||||
template <typename... Cs>
|
||||
class System {
|
||||
public:
|
||||
friend System World::MakeSystem<Cs...>();
|
||||
|
||||
template <typename... Ts, typename S>
|
||||
friend System<Ts...> World::MakeSystem(S&&);
|
||||
|
||||
/*template <typename Fn>
|
||||
requires std::is_invocable_r_v<void, Fn(Cs...), ObjId, Cs...>
|
||||
void ForEach(Fn&& f) {
|
||||
for (ObjId i = 0; i < mT.size(); ++i) {
|
||||
auto& c = mT[i];
|
||||
f(i, std::get<Cs>(c)...);
|
||||
}
|
||||
}*/
|
||||
|
||||
template <typename Fn>
|
||||
requires std::is_invocable_r_v<void, Fn(Cs...), Cs...>
|
||||
void ForEach(Fn&& fn) {
|
||||
std::tuple<Cs...> comps; // some sort of iterator that returns a tuple each 'step?'
|
||||
for (size_t i = 0; i < 5; ++i) {
|
||||
fn(std::get<Cs>(comps)...);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
System() = default;
|
||||
|
||||
template <typename S>
|
||||
explicit System(S&& name)
|
||||
: m_name{ std::forward<S>(name) }
|
||||
{}
|
||||
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
class Entity {
|
||||
public:
|
||||
friend Entity World::MakeEntity();
|
||||
|
||||
using StorageConstructor = std::function<std::unique_ptr<IStorage>()>;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr LWOOBJID GetObjectID() const noexcept {
|
||||
return m_Id;
|
||||
}
|
||||
|
||||
[[maybe_unused]]
|
||||
void* AddComponent(eReplicaComponentType, StorageConstructor);
|
||||
|
||||
template <typename C>
|
||||
[[maybe_unused]]
|
||||
C* AddComponent() {
|
||||
return static_cast<C*>(AddComponent(C::ComponentType, std::make_unique<Storage<C>>));
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
const void* GetComponent(eReplicaComponentType) const;
|
||||
|
||||
[[nodiscard]]
|
||||
void* GetComponent(eReplicaComponentType);
|
||||
|
||||
template <typename C>
|
||||
[[nodiscard]]
|
||||
const C* GetComponent() const {
|
||||
return static_cast<const C*>(GetComponent(C::ComponentType));
|
||||
}
|
||||
|
||||
template <typename C>
|
||||
[[nodiscard]]
|
||||
C* GetComponent() {
|
||||
return static_cast<C*>(GetComponent(C::ComponentType));
|
||||
}
|
||||
|
||||
private:
|
||||
Entity(const LWOOBJID id, const WeakWorldPtr world)
|
||||
: m_Id{ id }
|
||||
, m_World { world }
|
||||
{}
|
||||
|
||||
LWOOBJID m_Id;
|
||||
|
||||
WeakWorldPtr m_World;
|
||||
};
|
||||
|
||||
struct IStorage {
|
||||
using RowMap = std::unordered_map<LWOOBJID, size_t>;
|
||||
|
||||
virtual ~IStorage() = default;
|
||||
|
||||
[[nodiscard]]
|
||||
virtual void* at(size_t) = 0;
|
||||
|
||||
[[nodiscard]]
|
||||
virtual const void* at(size_t) const = 0;
|
||||
|
||||
[[nodiscard]]
|
||||
virtual void* emplace_back() = 0;
|
||||
|
||||
RowMap rowMap;
|
||||
};
|
||||
|
||||
template <typename C>
|
||||
class Storage : public IStorage {
|
||||
public:
|
||||
[[nodiscard]]
|
||||
void* at(const size_t index) override {
|
||||
return static_cast<void*>(&m_Vec.at(index));
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
const void* at(const size_t index) const override {
|
||||
return static_cast<const void*>(&m_Vec.at(index));
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
void* emplace_back() override {
|
||||
return static_cast<void*>(&m_Vec.emplace_back());
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<C> m_Vec;
|
||||
};
|
||||
}
|
||||
12
dECS/Iter.h
12
dECS/Iter.h
@@ -1,12 +0,0 @@
|
||||
#include "Core.h"
|
||||
|
||||
namespace dECS {
|
||||
class Iter {
|
||||
public:
|
||||
[[nodiscard]]
|
||||
bool Next();
|
||||
|
||||
private:
|
||||
WeakWorldPtr m_World;
|
||||
};
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
#include "PetComponent.h"
|
||||
#include "MovementAIComponent.h"
|
||||
#include "MissionComponent.h"
|
||||
#include "eMissionState.h"
|
||||
|
||||
using Pet = PetComponent;
|
||||
using Mission = MissionComponent;
|
||||
using MovementAI = MovementAIComponent;
|
||||
|
||||
struct Position : NiPoint3 {};
|
||||
struct Treasure {};
|
||||
|
||||
namespace decs {
|
||||
template <typename... Cs>
|
||||
class System {
|
||||
public:
|
||||
template <typename Fn>
|
||||
void each(Fn&& fn) {
|
||||
fn();
|
||||
}
|
||||
};
|
||||
|
||||
class Scene {
|
||||
public:
|
||||
template <typename... Cs>
|
||||
System<Cs...> system() {
|
||||
return System<Cs...>{};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void run() {
|
||||
auto scene = decs::Scene{};
|
||||
|
||||
scene.system<Pet>()
|
||||
.each([](Pet& pet) {
|
||||
|
||||
});
|
||||
|
||||
scene.system<Pet, MovementAI>()
|
||||
.each([](Pet& pet, MovementAI& move) {
|
||||
|
||||
});
|
||||
|
||||
scene.system<Pet, const Mission, const Position>()
|
||||
.each([](Pet& pet, Mission const& mission, Position const& pos) {
|
||||
auto const digUnlocked = mission.GetMissionState(842) == eMissionState::COMPLETE;
|
||||
auto const treasurePos = PetDigServer::GetClosestTreasure(pos);
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
@@ -97,8 +97,6 @@
|
||||
#include "CDSkillBehaviorTable.h"
|
||||
#include "CDZoneTableTable.h"
|
||||
|
||||
#include <ranges>
|
||||
|
||||
Observable<Entity*, const PositionUpdate&> Entity::OnPlayerPositionUpdate;
|
||||
|
||||
Entity::Entity(const LWOOBJID& objectID, EntityInfo info, User* parentUser, Entity* parentEntity) {
|
||||
@@ -288,9 +286,8 @@ void Entity::Initialize() {
|
||||
AddComponent<PropertyEntranceComponent>(propertyEntranceComponentID);
|
||||
}
|
||||
|
||||
const int32_t controllablePhysicsComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::CONTROLLABLE_PHYSICS);
|
||||
if (controllablePhysicsComponentID > 0) {
|
||||
auto* controllablePhysics = AddComponent<ControllablePhysicsComponent>(controllablePhysicsComponentID);
|
||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::CONTROLLABLE_PHYSICS) > 0) {
|
||||
auto* controllablePhysics = AddComponent<ControllablePhysicsComponent>();
|
||||
|
||||
if (m_Character) {
|
||||
controllablePhysics->LoadFromXml(m_Character->GetXMLDoc());
|
||||
@@ -333,19 +330,16 @@ void Entity::Initialize() {
|
||||
AddComponent<SimplePhysicsComponent>(simplePhysicsComponentID);
|
||||
}
|
||||
|
||||
const int32_t rigidBodyPhantomPhysicsComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS);
|
||||
if (rigidBodyPhantomPhysicsComponentID > 0) {
|
||||
AddComponent<RigidbodyPhantomPhysicsComponent>(rigidBodyPhantomPhysicsComponentID);
|
||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS) > 0) {
|
||||
AddComponent<RigidbodyPhantomPhysicsComponent>();
|
||||
}
|
||||
|
||||
const int32_t phantomPhysicsComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PHANTOM_PHYSICS);
|
||||
if (markedAsPhantom || phantomPhysicsComponentID > 0) {
|
||||
AddComponent<PhantomPhysicsComponent>(phantomPhysicsComponentID)->SetPhysicsEffectActive(false);
|
||||
if (markedAsPhantom || compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PHANTOM_PHYSICS) > 0) {
|
||||
AddComponent<PhantomPhysicsComponent>()->SetPhysicsEffectActive(false);
|
||||
}
|
||||
|
||||
const int32_t havokVehiclePhysicsComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::HAVOK_VEHICLE_PHYSICS);
|
||||
if (havokVehiclePhysicsComponentID > 0) {
|
||||
auto* havokVehiclePhysicsComponent = AddComponent<HavokVehiclePhysicsComponent>(havokVehiclePhysicsComponentID);
|
||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::HAVOK_VEHICLE_PHYSICS) > 0) {
|
||||
auto* havokVehiclePhysicsComponent = AddComponent<HavokVehiclePhysicsComponent>();
|
||||
havokVehiclePhysicsComponent->SetPosition(m_DefaultPosition);
|
||||
havokVehiclePhysicsComponent->SetRotation(m_DefaultRotation);
|
||||
}
|
||||
@@ -2167,19 +2161,7 @@ void Entity::SetRespawnPos(const NiPoint3& position) {
|
||||
auto* characterComponent = GetComponent<CharacterComponent>();
|
||||
if (characterComponent) characterComponent->SetRespawnPos(position);
|
||||
}
|
||||
|
||||
void Entity::SetRespawnRot(const NiQuaternion& rotation) {
|
||||
auto* characterComponent = GetComponent<CharacterComponent>();
|
||||
if (characterComponent) characterComponent->SetRespawnRot(rotation);
|
||||
}
|
||||
|
||||
int32_t Entity::GetCollisionGroup() const {
|
||||
for (const auto* component : m_Components | std::views::values) {
|
||||
auto* compToCheck = dynamic_cast<const PhysicsComponent*>(component);
|
||||
if (compToCheck) {
|
||||
return compToCheck->GetCollisionGroup();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -107,11 +107,6 @@ public:
|
||||
|
||||
const SystemAddress& GetSystemAddress() const;
|
||||
|
||||
// Returns the collision group for this entity.
|
||||
// Because the collision group is stored on a base component, this will look for a physics component
|
||||
// then return the collision group from that.
|
||||
int32_t GetCollisionGroup() const;
|
||||
|
||||
/**
|
||||
* Setters
|
||||
*/
|
||||
|
||||
@@ -55,7 +55,7 @@ set(DGAME_DBEHAVIORS_SOURCES "AirMovementBehavior.cpp"
|
||||
"VerifyBehavior.cpp")
|
||||
|
||||
add_library(dBehaviors OBJECT ${DGAME_DBEHAVIORS_SOURCES})
|
||||
target_link_libraries(dBehaviors PUBLIC dDatabaseCDClient dPhysics magic_enum::magic_enum)
|
||||
target_link_libraries(dBehaviors PUBLIC dDatabaseCDClient dPhysics)
|
||||
target_include_directories(dBehaviors PUBLIC "."
|
||||
"${PROJECT_SOURCE_DIR}/dGame/dGameMessages" # via BehaviorContext.h
|
||||
PRIVATE
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "DestroyableComponent.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <ranges>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
@@ -28,7 +27,7 @@
|
||||
#include "CDPhysicsComponentTable.h"
|
||||
#include "dNavMesh.h"
|
||||
|
||||
BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id) : Component(parent) {
|
||||
BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id): Component(parent) {
|
||||
m_Target = LWOOBJID_EMPTY;
|
||||
m_DirtyStateOrTarget = true;
|
||||
m_State = AiState::spawn;
|
||||
@@ -38,7 +37,6 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id)
|
||||
m_Disabled = false;
|
||||
m_SkillEntries = {};
|
||||
m_SoftTimer = 5.0f;
|
||||
m_ForcedTetherTime = 0.0f;
|
||||
|
||||
//Grab the aggro information from BaseCombatAI:
|
||||
auto componentQuery = CDClientDatabase::CreatePreppedStmt(
|
||||
@@ -172,17 +170,6 @@ void BaseCombatAIComponent::Update(const float deltaTime) {
|
||||
GameMessages::SendStopFXEffect(m_Parent, true, "tether");
|
||||
m_TetherEffectActive = false;
|
||||
}
|
||||
m_ForcedTetherTime -= deltaTime;
|
||||
if (m_ForcedTetherTime >= 0) return;
|
||||
}
|
||||
|
||||
for (auto entry = m_RemovedThreatList.begin(); entry != m_RemovedThreatList.end();) {
|
||||
entry->second -= deltaTime;
|
||||
if (entry->second <= 0.0f) {
|
||||
entry = m_RemovedThreatList.erase(entry);
|
||||
} else {
|
||||
++entry;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_SoftTimer <= 0.0f) {
|
||||
@@ -300,7 +287,40 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
|
||||
}
|
||||
|
||||
if (!m_TetherEffectActive && m_OutOfCombat && (m_OutOfCombatTime -= deltaTime) <= 0) {
|
||||
TetherLogic();
|
||||
auto* destroyableComponent = m_Parent->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (destroyableComponent != nullptr && destroyableComponent->HasFaction(4)) {
|
||||
auto serilizationRequired = false;
|
||||
|
||||
if (destroyableComponent->GetHealth() != destroyableComponent->GetMaxHealth()) {
|
||||
destroyableComponent->SetHealth(destroyableComponent->GetMaxHealth());
|
||||
|
||||
serilizationRequired = true;
|
||||
}
|
||||
|
||||
if (destroyableComponent->GetArmor() != destroyableComponent->GetMaxArmor()) {
|
||||
destroyableComponent->SetArmor(destroyableComponent->GetMaxArmor());
|
||||
|
||||
serilizationRequired = true;
|
||||
}
|
||||
|
||||
if (serilizationRequired) {
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
GameMessages::SendPlayFXEffect(m_Parent->GetObjectID(), 6270, u"tether", "tether");
|
||||
|
||||
m_TetherEffectActive = true;
|
||||
|
||||
m_TetherTime = 3.0f;
|
||||
}
|
||||
|
||||
// Speed towards start position
|
||||
if (m_MovementAI != nullptr) {
|
||||
m_MovementAI->SetHaltDistance(0);
|
||||
m_MovementAI->SetMaxSpeed(m_PursuitSpeed);
|
||||
m_MovementAI->SetDestination(m_StartPosition);
|
||||
}
|
||||
|
||||
m_OutOfCombat = false;
|
||||
m_OutOfCombatTime = 0.0f;
|
||||
@@ -479,7 +499,7 @@ std::vector<LWOOBJID> BaseCombatAIComponent::GetTargetWithinAggroRange() const {
|
||||
|
||||
const auto distance = Vector3::DistanceSquared(m_Parent->GetPosition(), other->GetPosition());
|
||||
|
||||
if (distance > m_AggroRadius * m_AggroRadius || m_RemovedThreatList.contains(id)) continue;
|
||||
if (distance > m_AggroRadius * m_AggroRadius) continue;
|
||||
|
||||
targets.push_back(id);
|
||||
}
|
||||
@@ -606,7 +626,6 @@ const NiPoint3& BaseCombatAIComponent::GetStartPosition() const {
|
||||
|
||||
void BaseCombatAIComponent::ClearThreat() {
|
||||
m_ThreatEntries.clear();
|
||||
m_Target = LWOOBJID_EMPTY;
|
||||
|
||||
m_DirtyThreat = true;
|
||||
}
|
||||
@@ -787,55 +806,3 @@ void BaseCombatAIComponent::Wake() {
|
||||
m_dpEntity->SetSleeping(false);
|
||||
m_dpEntityEnemy->SetSleeping(false);
|
||||
}
|
||||
|
||||
void BaseCombatAIComponent::TetherLogic() {
|
||||
auto* destroyableComponent = m_Parent->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (destroyableComponent != nullptr && destroyableComponent->HasFaction(4)) {
|
||||
auto serilizationRequired = false;
|
||||
|
||||
if (destroyableComponent->GetHealth() != destroyableComponent->GetMaxHealth()) {
|
||||
destroyableComponent->SetHealth(destroyableComponent->GetMaxHealth());
|
||||
|
||||
serilizationRequired = true;
|
||||
}
|
||||
|
||||
if (destroyableComponent->GetArmor() != destroyableComponent->GetMaxArmor()) {
|
||||
destroyableComponent->SetArmor(destroyableComponent->GetMaxArmor());
|
||||
|
||||
serilizationRequired = true;
|
||||
}
|
||||
|
||||
if (serilizationRequired) {
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
GameMessages::SendPlayFXEffect(m_Parent->GetObjectID(), 6270, u"tether", "tether");
|
||||
|
||||
m_TetherEffectActive = true;
|
||||
|
||||
m_TetherTime = 3.0f;
|
||||
}
|
||||
|
||||
// Speed towards start position
|
||||
if (m_MovementAI != nullptr) {
|
||||
m_MovementAI->SetHaltDistance(0);
|
||||
m_MovementAI->SetMaxSpeed(m_PursuitSpeed);
|
||||
m_MovementAI->SetDestination(m_StartPosition);
|
||||
}
|
||||
}
|
||||
|
||||
void BaseCombatAIComponent::ForceTether() {
|
||||
SetTarget(LWOOBJID_EMPTY);
|
||||
m_ThreatEntries.clear();
|
||||
TetherLogic();
|
||||
m_ForcedTetherTime = m_TetherTime;
|
||||
|
||||
SetAiState(AiState::aggro);
|
||||
}
|
||||
|
||||
void BaseCombatAIComponent::IgnoreThreat(const LWOOBJID threat, const float value) {
|
||||
m_RemovedThreatList[threat] = value;
|
||||
SetThreat(threat, 0.0f);
|
||||
m_Target = LWOOBJID_EMPTY;
|
||||
}
|
||||
|
||||
@@ -224,16 +224,6 @@ public:
|
||||
*/
|
||||
void Wake();
|
||||
|
||||
// Force this entity to tether and ignore all other actions
|
||||
void ForceTether();
|
||||
|
||||
// heals the entity to full health and armor
|
||||
// and tethers them to their spawn point
|
||||
void TetherLogic();
|
||||
|
||||
// Ignore a threat for a certain amount of time
|
||||
void IgnoreThreat(const LWOOBJID target, const float time);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Returns the current target or the target that currently is the largest threat to this entity
|
||||
@@ -392,12 +382,6 @@ private:
|
||||
*/
|
||||
bool m_DirtyStateOrTarget = false;
|
||||
|
||||
// The amount of time the entity will be forced to tether for
|
||||
float m_ForcedTetherTime = 0.0f;
|
||||
|
||||
// The amount of time a removed threat will be ignored for.
|
||||
std::map<LWOOBJID, float> m_RemovedThreatList;
|
||||
|
||||
/**
|
||||
* Whether the current entity is a mech enemy, needed as mechs tether radius works differently
|
||||
* @return whether this entity is a mech
|
||||
|
||||
@@ -79,4 +79,4 @@ target_include_directories(dComponents PUBLIC "."
|
||||
)
|
||||
target_precompile_headers(dComponents REUSE_FROM dGameBase)
|
||||
|
||||
target_link_libraries(dComponents PUBLIC magic_enum::magic_enum INTERFACE dBehaviors)
|
||||
target_link_libraries(dComponents INTERFACE dBehaviors)
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
#include "Component.h"
|
||||
|
||||
|
||||
Component::Component(Entity* parent) {
|
||||
m_Parent = parent;
|
||||
}
|
||||
|
||||
Component::~Component() {
|
||||
|
||||
}
|
||||
|
||||
Entity* Component::GetParent() const {
|
||||
return m_Parent;
|
||||
}
|
||||
|
||||
void Component::Update(float deltaTime) {
|
||||
|
||||
}
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
|
||||
#include "tinyxml2.h"
|
||||
|
||||
namespace RakNet {
|
||||
class BitStream;
|
||||
};
|
||||
|
||||
class Entity;
|
||||
|
||||
/**
|
||||
@@ -13,15 +9,14 @@ class Entity;
|
||||
*/
|
||||
class Component {
|
||||
public:
|
||||
Component() = default;
|
||||
Component(Entity* parent) : m_Parent{ parent } {}
|
||||
virtual ~Component() = default;
|
||||
Component(Entity* parent);
|
||||
virtual ~Component();
|
||||
|
||||
/**
|
||||
* Gets the owner of this component
|
||||
* @return the owner of this component
|
||||
*/
|
||||
Entity* GetParent() const { return m_Parent; }
|
||||
Entity* GetParent() const;
|
||||
|
||||
/**
|
||||
* Updates the component in the game loop
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "LevelProgressionComponent.h"
|
||||
#include "eStateChangeType.h"
|
||||
|
||||
ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity, int32_t componentId) : PhysicsComponent(entity, componentId) {
|
||||
ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity) : PhysicsComponent(entity) {
|
||||
m_Velocity = {};
|
||||
m_AngularVelocity = {};
|
||||
m_InJetpackMode = false;
|
||||
|
||||
@@ -23,7 +23,7 @@ class ControllablePhysicsComponent : public PhysicsComponent {
|
||||
public:
|
||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::CONTROLLABLE_PHYSICS;
|
||||
|
||||
ControllablePhysicsComponent(Entity* entity, int32_t componentId);
|
||||
ControllablePhysicsComponent(Entity* entity);
|
||||
~ControllablePhysicsComponent() override;
|
||||
|
||||
void Update(float deltaTime) override;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "HavokVehiclePhysicsComponent.h"
|
||||
#include "EntityManager.h"
|
||||
|
||||
HavokVehiclePhysicsComponent::HavokVehiclePhysicsComponent(Entity* parent, int32_t componentId) : PhysicsComponent(parent, componentId) {
|
||||
HavokVehiclePhysicsComponent::HavokVehiclePhysicsComponent(Entity* parent) : PhysicsComponent(parent) {
|
||||
m_Velocity = NiPoint3Constant::ZERO;
|
||||
m_AngularVelocity = NiPoint3Constant::ZERO;
|
||||
m_IsOnGround = true;
|
||||
|
||||
@@ -13,7 +13,7 @@ class HavokVehiclePhysicsComponent : public PhysicsComponent {
|
||||
public:
|
||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::HAVOK_VEHICLE_PHYSICS;
|
||||
|
||||
HavokVehiclePhysicsComponent(Entity* parentEntity, int32_t componentId);
|
||||
HavokVehiclePhysicsComponent(Entity* parentEntity);
|
||||
|
||||
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
||||
|
||||
|
||||
@@ -1141,25 +1141,6 @@ void InventoryComponent::AddItemSkills(const LOT lot) {
|
||||
SetSkill(slot, skill);
|
||||
}
|
||||
|
||||
void InventoryComponent::FixInvisibleItems() {
|
||||
const auto numberItemsLoadedPerFrame = 12.0f;
|
||||
const auto callbackTime = 0.125f;
|
||||
const auto arbitaryInventorySize = 300.0f; // max in live + dlu is less than 300, seems like a good number.
|
||||
auto* const items = GetInventory(eInventoryType::ITEMS);
|
||||
if (!items) return;
|
||||
|
||||
// Add an extra update to make sure the client can see all the items.
|
||||
const auto something = static_cast<int32_t>(std::ceil(items->GetItems().size() / arbitaryInventorySize)) + 1;
|
||||
LOG_DEBUG("Fixing invisible items with %i updates", something);
|
||||
|
||||
for (int32_t i = 1; i < something + 1; i++) {
|
||||
// client loads 12 items every 1/8 seconds, we're adding a small hack to fix invisible inventory items due to closing the news screen too fast.
|
||||
m_Parent->AddCallbackTimer((arbitaryInventorySize / numberItemsLoadedPerFrame) * callbackTime * i, [this]() {
|
||||
GameMessages::SendUpdateInventoryUi(m_Parent->GetObjectID(), m_Parent->GetSystemAddress());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void InventoryComponent::RemoveItemSkills(const LOT lot) {
|
||||
const auto info = Inventory::FindItemComponent(lot);
|
||||
|
||||
|
||||
@@ -404,8 +404,6 @@ public:
|
||||
void UpdateGroup(const GroupUpdate& groupUpdate);
|
||||
void RemoveGroup(const std::string& groupId);
|
||||
|
||||
void FixInvisibleItems();
|
||||
|
||||
~InventoryComponent() override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "dpShapeBox.h"
|
||||
#include "dpShapeSphere.h"
|
||||
|
||||
PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent, int32_t componentId) : PhysicsComponent(parent, componentId) {
|
||||
PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : PhysicsComponent(parent) {
|
||||
m_Position = m_Parent->GetDefaultPosition();
|
||||
m_Rotation = m_Parent->GetDefaultRotation();
|
||||
m_Scale = m_Parent->GetDefaultScale();
|
||||
|
||||
@@ -30,7 +30,7 @@ class PhantomPhysicsComponent final : public PhysicsComponent {
|
||||
public:
|
||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::PHANTOM_PHYSICS;
|
||||
|
||||
PhantomPhysicsComponent(Entity* parent, int32_t componentId);
|
||||
PhantomPhysicsComponent(Entity* parent);
|
||||
~PhantomPhysicsComponent() override;
|
||||
void Update(float deltaTime) override;
|
||||
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
||||
|
||||
@@ -14,21 +14,10 @@
|
||||
|
||||
#include "EntityInfo.h"
|
||||
|
||||
PhysicsComponent::PhysicsComponent(Entity* parent, int32_t componentId) : Component(parent) {
|
||||
PhysicsComponent::PhysicsComponent(Entity* parent) : Component(parent) {
|
||||
m_Position = NiPoint3Constant::ZERO;
|
||||
m_Rotation = NiQuaternionConstant::IDENTITY;
|
||||
m_DirtyPosition = false;
|
||||
|
||||
CDPhysicsComponentTable* physicsComponentTable = CDClientManager::GetTable<CDPhysicsComponentTable>();
|
||||
|
||||
if (physicsComponentTable) {
|
||||
auto* info = physicsComponentTable->GetByID(componentId);
|
||||
if (info) {
|
||||
m_CollisionGroup = info->collisionGroup;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_Parent->HasVar(u"CollisionGroupID")) m_CollisionGroup = m_Parent->GetVar<int32_t>(u"CollisionGroupID");
|
||||
}
|
||||
|
||||
void PhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) {
|
||||
|
||||
@@ -15,7 +15,7 @@ class dpEntity;
|
||||
|
||||
class PhysicsComponent : public Component {
|
||||
public:
|
||||
PhysicsComponent(Entity* parent, int32_t componentId);
|
||||
PhysicsComponent(Entity* parent);
|
||||
virtual ~PhysicsComponent() = default;
|
||||
|
||||
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
||||
@@ -25,9 +25,6 @@ public:
|
||||
|
||||
const NiQuaternion& GetRotation() const { return m_Rotation; }
|
||||
virtual void SetRotation(const NiQuaternion& rot) { if (m_Rotation == rot) return; m_Rotation = rot; m_DirtyPosition = true; }
|
||||
|
||||
int32_t GetCollisionGroup() const noexcept { return m_CollisionGroup; }
|
||||
void SetCollisionGroup(int32_t group) noexcept { m_CollisionGroup = group; }
|
||||
protected:
|
||||
dpEntity* CreatePhysicsEntity(eReplicaComponentType type);
|
||||
|
||||
@@ -40,8 +37,6 @@ protected:
|
||||
NiQuaternion m_Rotation;
|
||||
|
||||
bool m_DirtyPosition;
|
||||
|
||||
int32_t m_CollisionGroup{};
|
||||
};
|
||||
|
||||
#endif //!__PHYSICSCOMPONENT__H__
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "dpShapeSphere.h"
|
||||
#include"EntityInfo.h"
|
||||
|
||||
RigidbodyPhantomPhysicsComponent::RigidbodyPhantomPhysicsComponent(Entity* parent, int32_t componentId) : PhysicsComponent(parent, componentId) {
|
||||
RigidbodyPhantomPhysicsComponent::RigidbodyPhantomPhysicsComponent(Entity* parent) : PhysicsComponent(parent) {
|
||||
m_Position = m_Parent->GetDefaultPosition();
|
||||
m_Rotation = m_Parent->GetDefaultRotation();
|
||||
m_Scale = m_Parent->GetDefaultScale();
|
||||
|
||||
@@ -21,7 +21,7 @@ class RigidbodyPhantomPhysicsComponent : public PhysicsComponent {
|
||||
public:
|
||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS;
|
||||
|
||||
RigidbodyPhantomPhysicsComponent(Entity* parent, int32_t componentId);
|
||||
RigidbodyPhantomPhysicsComponent(Entity* parent);
|
||||
|
||||
void Update(const float deltaTime) override;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include "Entity.h"
|
||||
|
||||
SimplePhysicsComponent::SimplePhysicsComponent(Entity* parent, int32_t componentID) : PhysicsComponent(parent, componentID) {
|
||||
SimplePhysicsComponent::SimplePhysicsComponent(Entity* parent, uint32_t componentID) : PhysicsComponent(parent) {
|
||||
m_Position = m_Parent->GetDefaultPosition();
|
||||
m_Rotation = m_Parent->GetDefaultRotation();
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class SimplePhysicsComponent : public PhysicsComponent {
|
||||
public:
|
||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SIMPLE_PHYSICS;
|
||||
|
||||
SimplePhysicsComponent(Entity* parent, int32_t componentID);
|
||||
SimplePhysicsComponent(Entity* parent, uint32_t componentID);
|
||||
~SimplePhysicsComponent() override;
|
||||
|
||||
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
||||
|
||||
@@ -6,7 +6,7 @@ set(DGAME_DGAMEMESSAGES_SOURCES
|
||||
|
||||
add_library(dGameMessages OBJECT ${DGAME_DGAMEMESSAGES_SOURCES})
|
||||
target_link_libraries(dGameMessages
|
||||
PUBLIC magic_enum::magic_enum dDatabase
|
||||
PUBLIC dDatabase
|
||||
INTERFACE dGameBase # TradingManager
|
||||
)
|
||||
target_include_directories(dGameMessages PUBLIC "."
|
||||
|
||||
@@ -104,18 +104,6 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream& inStream, const System
|
||||
break;
|
||||
}
|
||||
|
||||
// Currently not actually used for our implementation, however its used right now to get around invisible inventory items in the client.
|
||||
case MessageType::Game::SELECT_SKILL: {
|
||||
auto var = entity->GetVar<bool>(u"dlu_first_time_load");
|
||||
if (var) {
|
||||
entity->SetVar<bool>(u"dlu_first_time_load", false);
|
||||
InventoryComponent* inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||
|
||||
if (inventoryComponent) inventoryComponent->FixInvisibleItems();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case MessageType::Game::PLAYER_LOADED: {
|
||||
GameMessages::SendRestoreToPostLoadStats(entity, sysAddr);
|
||||
entity->SetPlayerReadyForUpdates();
|
||||
|
||||
@@ -982,7 +982,7 @@ void GameMessages::SendResurrect(Entity* entity) {
|
||||
destroyableComponent->SetImagination(imaginationToRestore);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
CBITSTREAM;
|
||||
CMSGHEADER;
|
||||
@@ -5080,12 +5080,6 @@ void GameMessages::HandleSetFlag(RakNet::BitStream& inStream, Entity* entity) {
|
||||
|
||||
auto character = entity->GetCharacter();
|
||||
if (character) character->SetPlayerFlag(iFlagID, bFlag);
|
||||
|
||||
// This is always set the first time a player loads into a world from character select
|
||||
// and is used to know when to refresh the players inventory items so they show up.
|
||||
if (iFlagID == ePlayerFlag::IS_NEWS_SCREEN_VISIBLE && bFlag) {
|
||||
entity->SetVar<bool>(u"dlu_first_time_load", true);
|
||||
}
|
||||
}
|
||||
|
||||
void GameMessages::HandleRespondToMission(RakNet::BitStream& inStream, Entity* entity) {
|
||||
@@ -5153,12 +5147,12 @@ void GameMessages::HandleMissionDialogOK(RakNet::BitStream& inStream, Entity* en
|
||||
}
|
||||
|
||||
if (Game::config->GetValue("allow_players_to_skip_cinematics") != "1"
|
||||
|| !player->GetCharacter()
|
||||
|| !player->GetCharacter()->GetPlayerFlag(ePlayerFlag::DLU_SKIP_CINEMATICS)) return;
|
||||
|| !player->GetCharacter()
|
||||
|| !player->GetCharacter()->GetPlayerFlag(ePlayerFlag::DLU_SKIP_CINEMATICS)) return;
|
||||
player->AddCallbackTimer(0.5f, [player]() {
|
||||
if (!player) return;
|
||||
GameMessages::SendEndCinematic(player->GetObjectID(), u"", player->GetSystemAddress());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void GameMessages::HandleRequestLinkedMission(RakNet::BitStream& inStream, Entity* entity) {
|
||||
@@ -6330,48 +6324,3 @@ void GameMessages::SendForceCameraTargetCycle(Entity* entity, bool bForceCycling
|
||||
auto sysAddr = entity->GetSystemAddress();
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
||||
|
||||
void GameMessages::SendUpdateInventoryUi(LWOOBJID objectId, const SystemAddress& sysAddr) {
|
||||
CBITSTREAM;
|
||||
CMSGHEADER;
|
||||
|
||||
bitStream.Write(objectId);
|
||||
bitStream.Write(MessageType::Game::UPDATE_INVENTORY_UI);
|
||||
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
||||
void GameMessages::DisplayTooltip::Send() const {
|
||||
CBITSTREAM;
|
||||
CMSGHEADER;
|
||||
|
||||
bitStream.Write(target);
|
||||
bitStream.Write(msgId);
|
||||
|
||||
bitStream.Write(doOrDie);
|
||||
bitStream.Write(noRepeat);
|
||||
bitStream.Write(noRevive);
|
||||
bitStream.Write(isPropertyTooltip);
|
||||
bitStream.Write(show);
|
||||
bitStream.Write(translate);
|
||||
bitStream.Write(time);
|
||||
bitStream.Write<int32_t>(id.size());
|
||||
bitStream.Write(id);
|
||||
|
||||
std::string toWrite;
|
||||
for (const auto* item : localizeParams) {
|
||||
toWrite += item->GetString() + "\n";
|
||||
}
|
||||
if (!toWrite.empty()) toWrite.pop_back();
|
||||
bitStream.Write<int32_t>(toWrite.size());
|
||||
bitStream.Write(GeneralUtils::ASCIIToUTF16(toWrite));
|
||||
if (!toWrite.empty()) bitStream.Write<uint16_t>(0x00); // Null Terminator
|
||||
|
||||
bitStream.Write<int32_t>(imageName.size());
|
||||
bitStream.Write(imageName);
|
||||
bitStream.Write<int32_t>(text.size());
|
||||
bitStream.Write(text);
|
||||
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "eCyclingMode.h"
|
||||
#include "eLootSourceType.h"
|
||||
#include "Brick.h"
|
||||
#include "MessageType/Game.h"
|
||||
|
||||
class AMFBaseValue;
|
||||
class Entity;
|
||||
@@ -21,7 +20,6 @@ class User;
|
||||
class Leaderboard;
|
||||
class PropertySelectQueryProperty;
|
||||
class TradeItem;
|
||||
class LDFBaseData;
|
||||
|
||||
enum class eAnimationFlags : uint32_t;
|
||||
|
||||
@@ -49,15 +47,6 @@ enum class eCameraTargetCyclingMode : int32_t {
|
||||
};
|
||||
|
||||
namespace GameMessages {
|
||||
struct GameMsg {
|
||||
GameMsg(MessageType::Game gmId) : msgId{ gmId } {}
|
||||
virtual ~GameMsg() = default;
|
||||
virtual void Send() const {}
|
||||
MessageType::Game msgId;
|
||||
LWOOBJID target{ LWOOBJID_EMPTY };
|
||||
SystemAddress sysAddr{ UNASSIGNED_SYSTEM_ADDRESS };
|
||||
};
|
||||
|
||||
class PropertyDataMessage;
|
||||
void SendFireEventClientSide(const LWOOBJID& objectID, const SystemAddress& sysAddr, std::u16string args, const LWOOBJID& object, int64_t param1, int param2, const LWOOBJID& sender);
|
||||
void SendTeleport(const LWOOBJID& objectID, const NiPoint3& pos, const NiQuaternion& rot, const SystemAddress& sysAddr, bool bSetRotation = false);
|
||||
@@ -688,25 +677,6 @@ namespace GameMessages {
|
||||
void HandleUpdateInventoryGroup(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
void HandleUpdateInventoryGroupContents(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
void SendForceCameraTargetCycle(Entity* entity, bool bForceCycling, eCameraTargetCyclingMode cyclingMode, LWOOBJID optionalTargetID);
|
||||
|
||||
// This is a client gm however its default values are exactly what we need to get around the invisible inventory item issues.
|
||||
void SendUpdateInventoryUi(LWOOBJID objectId, const SystemAddress& sysAddr);
|
||||
|
||||
struct DisplayTooltip : public GameMsg {
|
||||
DisplayTooltip() : GameMsg(MessageType::Game::DISPLAY_TOOLTIP) {}
|
||||
bool doOrDie{};
|
||||
bool noRepeat{};
|
||||
bool noRevive{};
|
||||
bool isPropertyTooltip{};
|
||||
bool show{};
|
||||
bool translate{};
|
||||
int32_t time{};
|
||||
std::u16string id{};
|
||||
std::vector<LDFBaseData*> localizeParams{};
|
||||
std::u16string imageName{};
|
||||
std::u16string text{};
|
||||
void Send() const override;
|
||||
};
|
||||
};
|
||||
|
||||
#endif // GAMEMESSAGES_H
|
||||
|
||||
@@ -24,7 +24,6 @@ target_include_directories(dInventory PUBLIC "."
|
||||
"${PROJECT_SOURCE_DIR}/dGame/dMission" # via MissionComponent.h
|
||||
"${PROJECT_SOURCE_DIR}/dZoneManager" # via Item.cpp
|
||||
)
|
||||
target_link_libraries(dInventory PUBLIC magic_enum::magic_enum)
|
||||
target_precompile_headers(dInventory REUSE_FROM dGameBase)
|
||||
# Workaround for compiler bug where the optimized code could result in a memcpy of 0 bytes, even though that isnt possible.
|
||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97185
|
||||
|
||||
@@ -8,6 +8,8 @@ class AMFArrayValue;
|
||||
/**
|
||||
* @brief Sent when a player moves a Behavior A at position B to their inventory.
|
||||
*/
|
||||
#pragma message("MoveToInventory.h This Control Behavior Message does not have a test yet. Non-developers can ignore this warning.")
|
||||
|
||||
class MoveToInventoryMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
MoveToInventoryMessage(const AMFArrayValue& arguments);
|
||||
|
||||
@@ -137,7 +137,7 @@ bool Precondition::CheckValue(Entity* player, const uint32_t value, bool evaluat
|
||||
|
||||
return inventoryComponent->GetLotCount(value) >= count;
|
||||
case PreconditionType::DoesNotHaveItem:
|
||||
return inventoryComponent->IsEquipped(value) && count > 0;
|
||||
return (inventoryComponent->IsEquipped(value) ? 1 : 0) < count;
|
||||
case PreconditionType::HasAchievement:
|
||||
if (missionComponent == nullptr) return false;
|
||||
return missionComponent->GetMissionState(value) >= eMissionState::COMPLETE;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#define _VARIADIC_MAX 10
|
||||
#include "dCommonVars.h"
|
||||
#include "dNetCommon.h"
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include "magic_enum.hpp"
|
||||
|
||||
enum class ServerType : uint32_t;
|
||||
enum class eLoginResponse : uint8_t;
|
||||
|
||||
@@ -8,7 +8,7 @@ set(DNET_SOURCES "AuthPackets.cpp"
|
||||
"ZoneInstanceManager.cpp")
|
||||
|
||||
add_library(dNet STATIC ${DNET_SOURCES})
|
||||
target_link_libraries(dNet PUBLIC magic_enum::magic_enum PRIVATE bcrypt MD5)
|
||||
target_link_libraries(dNet PRIVATE bcrypt MD5)
|
||||
target_include_directories(dNet PRIVATE
|
||||
"${PROJECT_SOURCE_DIR}/dCommon"
|
||||
"${PROJECT_SOURCE_DIR}/dCommon/dEnums"
|
||||
|
||||
@@ -65,13 +65,13 @@ void RandomSpawnerFin::OnStartup(Entity* self) {
|
||||
};
|
||||
|
||||
sectionMultipliers = {
|
||||
{"secA", 1},
|
||||
{"secB", 1},
|
||||
{"secA", 1.0f},
|
||||
{"secB", 1.0f},
|
||||
{"secC", 1.2f},
|
||||
{"secD", 1.3f},
|
||||
{"secE", 1.6f},
|
||||
{"secF", 1},
|
||||
{"secG", 1},
|
||||
{"secF", 1.0f},
|
||||
{"secG", 1.0f},
|
||||
{"secH", 1.2f},
|
||||
};
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ void RandomSpawnerPit::OnStartup(Entity* self) {
|
||||
};
|
||||
|
||||
sectionMultipliers = {
|
||||
{"secA", 1},
|
||||
{"secA", 1.0f},
|
||||
{"secB", 1.2f},
|
||||
{"secC", 1.2f},
|
||||
{"secD", 1},
|
||||
|
||||
@@ -65,8 +65,8 @@ void RandomSpawnerStr::OnStartup(Entity* self) {
|
||||
};
|
||||
|
||||
sectionMultipliers = {
|
||||
{"secA", 1},
|
||||
{"secB", 1},
|
||||
{"secA", 1.0f},
|
||||
{"secB", 1.0f},
|
||||
{"secC", 1.2f},
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL
|
||||
"BankInteractServer.cpp"
|
||||
"BaseInteractDropLootServer.cpp"
|
||||
"Binoculars.cpp"
|
||||
"EnemyClearThreat.cpp"
|
||||
"ExplodingAsset.cpp"
|
||||
"FrictionVolumeServer.cpp"
|
||||
"ForceVolumeServer.cpp"
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
#include "EnemyClearThreat.h"
|
||||
|
||||
#include "BaseCombatAIComponent.h"
|
||||
#include "PhysicsComponent.h"
|
||||
|
||||
void EnemyClearThreat::OnCollisionPhantom(Entity* self, Entity* target) {
|
||||
if (!target) return;
|
||||
|
||||
const auto colGroup = target->GetCollisionGroup();
|
||||
if (colGroup == 12) { // enemy
|
||||
auto* const baseCombatAiComponent = target->GetComponent<BaseCombatAIComponent>();
|
||||
if (!baseCombatAiComponent) return;
|
||||
|
||||
baseCombatAiComponent->ClearThreat();
|
||||
baseCombatAiComponent->ForceTether();
|
||||
} else if (colGroup == 10) { // player
|
||||
const auto enemies = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::BASE_COMBAT_AI);
|
||||
for (const auto& enemy : enemies) {
|
||||
auto* const baseCombatAiComponent = enemy->GetComponent<BaseCombatAIComponent>();
|
||||
if (!baseCombatAiComponent) continue;
|
||||
|
||||
baseCombatAiComponent->IgnoreThreat(target->GetObjectID(), 3.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#ifndef ENEMYCLEARTHREAT_H
|
||||
#define ENEMYCLEARTHREAT_H
|
||||
|
||||
#include "CppScripts.h"
|
||||
|
||||
class EnemyClearThreat : public CppScripts::Script {
|
||||
public:
|
||||
void OnCollisionPhantom(Entity* self, Entity* target) override;
|
||||
};
|
||||
|
||||
#endif //!ENEMYCLEARTHREAT_H
|
||||
@@ -327,8 +327,6 @@
|
||||
#include "VisToggleNotifierServer.h"
|
||||
#include "LupGenericInteract.h"
|
||||
#include "WblRobotCitizen.h"
|
||||
#include "EnemyClearThreat.h"
|
||||
#include "AgSpiderBossMessage.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
@@ -688,22 +686,8 @@ namespace {
|
||||
{"scripts\\zone\\LUPs\\RobotCity Intro\\WBL_RCIntro_RobotCitizenOrange.lua", []() {return new WblRobotCitizen();}},
|
||||
{"scripts\\zone\\LUPs\\RobotCity Intro\\WBL_RCIntro_RobotCitizenRed.lua", []() {return new WblRobotCitizen();}},
|
||||
{"scripts\\zone\\LUPs\\RobotCity Intro\\WBL_RCIntro_RobotCitizenYellow.lua", []() {return new WblRobotCitizen();}},
|
||||
{"scripts\\02_server\\Map\\General\\L_ENEMY_CLEAR_THREAT.lua", []() {return new EnemyClearThreat();}},
|
||||
{"scripts\\ai\\AG\\L_AG_SPIDER_BOSS_MESSAGE.lua", []() {return new AgSpiderBossMessage();}},
|
||||
|
||||
};
|
||||
|
||||
std::set<std::string> g_ExcludedScripts = {
|
||||
"scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua",
|
||||
"scripts\\02_server\\Enemy\\General\\L_BASE_ENEMY_SPIDERLING.lua",
|
||||
"scripts\\ai\\AG\\L_AG_SENTINEL_GUARD.lua",
|
||||
"scripts\\ai\\FV\\L_ACT_NINJA_STUDENT.lua",
|
||||
"scripts\\ai\\WILD\\L_WILD_GF_FROG.lua",
|
||||
"scripts\\empty.lua",
|
||||
"scripts\\zone\\AG\\L_ZONE_AG.lua",
|
||||
"scripts\\zone\\NS\\L_ZONE_NS.lua",
|
||||
"scripts\\zone\\GF\\L_ZONE_GF.lua",
|
||||
};
|
||||
};
|
||||
|
||||
CppScripts::Script* const CppScripts::GetScript(Entity* parent, const std::string& scriptName) {
|
||||
@@ -715,8 +699,14 @@ CppScripts::Script* const CppScripts::GetScript(Entity* parent, const std::strin
|
||||
const auto itrTernary = scriptLoader.find(scriptName);
|
||||
Script* script = itrTernary != scriptLoader.cend() ? itrTernary->second() : &InvalidToReturn;
|
||||
|
||||
if (script == &InvalidToReturn && !scriptName.empty() && !g_ExcludedScripts.contains(scriptName)) {
|
||||
LOG_DEBUG("LOT %i attempted to load CppScript for '%s', but returned InvalidScript.", parent->GetLOT(), scriptName.c_str());
|
||||
if (script == &InvalidToReturn) {
|
||||
if ((scriptName.length() > 0) && !((scriptName == "scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua") ||
|
||||
(scriptName == "scripts\\02_server\\Enemy\\General\\L_BASE_ENEMY_SPIDERLING.lua") ||
|
||||
(scriptName == "scripts\\ai\\FV\\L_ACT_NINJA_STUDENT.lua") ||
|
||||
(scriptName == "scripts\\ai\\WILD\\L_WILD_GF_FROG.lua") ||
|
||||
(scriptName == "scripts\\empty.lua") ||
|
||||
(scriptName == "scripts\\ai\\AG\\L_AG_SENTINEL_GUARD.lua")
|
||||
)) LOG_DEBUG("LOT %i attempted to load CppScript for '%s', but returned InvalidScript.", parent->GetLOT(), scriptName.c_str());
|
||||
}
|
||||
|
||||
g_Scripts[scriptName] = script;
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
#include "AgSpiderBossMessage.h"
|
||||
|
||||
#include "Entity.h"
|
||||
#include "GameMessages.h"
|
||||
|
||||
#include "RenderComponent.h"
|
||||
|
||||
Box AgSpiderBossMessage::GetBox(Entity* self) const {
|
||||
return self->GetVar<Box>(u"box");
|
||||
}
|
||||
|
||||
void AgSpiderBossMessage::SetBox(Entity* self, const Box& box) const {
|
||||
self->SetVar(u"box", box);
|
||||
}
|
||||
|
||||
void AgSpiderBossMessage::MakeBox(Entity* self) const {
|
||||
auto box = GetBox(self);
|
||||
if (box.boxTarget == LWOOBJID_EMPTY || box.isDisplayed || box.boxSelf == LWOOBJID_EMPTY) return;
|
||||
|
||||
box.isDisplayed = true;
|
||||
SetBox(self, box);
|
||||
self->AddTimer("BoxTimer", box.boxTime);
|
||||
|
||||
const auto* const tgt = Game::entityManager->GetEntity(box.boxTarget);
|
||||
if (!tgt) return;
|
||||
GameMessages::DisplayTooltip tooltip;
|
||||
tooltip.target = tgt->GetObjectID();
|
||||
tooltip.sysAddr = tgt->GetSystemAddress();
|
||||
tooltip.show = true;
|
||||
tooltip.text = box.boxText;
|
||||
tooltip.time = box.boxTime * 1000; // to ms
|
||||
tooltip.Send();
|
||||
}
|
||||
|
||||
void AgSpiderBossMessage::OnCollisionPhantom(Entity* self, Entity* target) {
|
||||
if (!target || !target->IsPlayer()) return;
|
||||
|
||||
auto box = GetBox(self);
|
||||
// knockback the target
|
||||
auto forward = target->GetRotation().GetForwardVector();
|
||||
box.boxTarget = target->GetObjectID();
|
||||
GameMessages::SendPlayFXEffect(target->GetObjectID(), 1378, u"create", "pushBack");
|
||||
RenderComponent::PlayAnimation(target, "knockback-recovery");
|
||||
forward.y += 15;
|
||||
forward.x *= 100;
|
||||
forward.z *= 100;
|
||||
GameMessages::SendKnockback(target->GetObjectID(), self->GetObjectID(), self->GetObjectID(), 0, forward);
|
||||
|
||||
if (box.isTouch || box.isDisplayed) return;
|
||||
box.boxSelf = self->GetObjectID();
|
||||
box.isTouch = true;
|
||||
box.boxText = u"%[SPIDER_CAVE_MESSAGE]";
|
||||
SetBox(self, box);
|
||||
self->AddTimer("EventTimer", 0.1f);
|
||||
}
|
||||
|
||||
void AgSpiderBossMessage::OnOffCollisionPhantom(Entity* self, Entity* target) {
|
||||
if (!target) return;
|
||||
auto box = GetBox(self);
|
||||
box.isTouch = false;
|
||||
box.Reset();
|
||||
SetBox(self, box);
|
||||
}
|
||||
|
||||
void AgSpiderBossMessage::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName == "BoxTimer") {
|
||||
auto box = GetBox(self);
|
||||
box.isDisplayed = false;
|
||||
SetBox(self, box);
|
||||
ResetBox(self);
|
||||
} else if (timerName == "EventTimer") {
|
||||
auto box = GetBox(self);
|
||||
MakeBox(self);
|
||||
}
|
||||
}
|
||||
|
||||
void AgSpiderBossMessage::ResetBox(Entity* self) const {
|
||||
auto box = GetBox(self);
|
||||
box.Reset();
|
||||
SetBox(self, box);
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
#ifndef AGSPIDERBOSSMESSAGE_H
|
||||
#define AGSPIDERBOSSMESSAGE_H
|
||||
|
||||
#include "CppScripts.h"
|
||||
|
||||
struct Box {
|
||||
LWOOBJID boxTarget{};
|
||||
bool isDisplayed{};
|
||||
bool isTouch{};
|
||||
bool isFirst{};
|
||||
LWOOBJID boxSelf{};
|
||||
std::u16string boxText{};
|
||||
int32_t boxTime{ 1 };
|
||||
|
||||
void Reset() {
|
||||
boxTarget = LWOOBJID_EMPTY;
|
||||
isDisplayed = false;
|
||||
isTouch = false;
|
||||
isFirst = false;
|
||||
boxSelf = LWOOBJID_EMPTY;
|
||||
boxText.clear();
|
||||
boxTime = 1;
|
||||
}
|
||||
};
|
||||
|
||||
class AgSpiderBossMessage : public CppScripts::Script {
|
||||
public:
|
||||
Box GetBox(Entity* self) const;
|
||||
void SetBox(Entity* self, const Box& box) const;
|
||||
void MakeBox(Entity* self) const;
|
||||
void OnCollisionPhantom(Entity* self, Entity* target) override;
|
||||
void OnOffCollisionPhantom(Entity* self, Entity* target) override;
|
||||
void OnTimerDone(Entity* self, std::string timerName) override;
|
||||
void ResetBox(Entity* self) const;
|
||||
};
|
||||
|
||||
#endif //!AGSPIDERBOSSMESSAGE_H
|
||||
@@ -1,7 +1,6 @@
|
||||
set(DSCRIPTS_SOURCES_AI_AG
|
||||
"AgShipPlayerDeathTrigger.cpp"
|
||||
"AgSpaceStuff.cpp"
|
||||
"AgSpiderBossMessage.cpp"
|
||||
"AgShipShake.cpp"
|
||||
"AgShipPlayerShockServer.cpp"
|
||||
"AgImagSmashable.cpp"
|
||||
|
||||
@@ -13,7 +13,7 @@ target_include_directories(WorldServer PRIVATE
|
||||
"${PROJECT_SOURCE_DIR}/dServer" # BinaryPathFinder.h
|
||||
)
|
||||
|
||||
target_link_libraries(WorldServer PUBLIC ${COMMON_LIBRARIES}
|
||||
target_link_libraries(WorldServer ${COMMON_LIBRARIES}
|
||||
dScripts
|
||||
dGameBase
|
||||
dComponents
|
||||
|
||||
@@ -6,5 +6,4 @@ include(GoogleTest)
|
||||
|
||||
# Add the subdirectories
|
||||
add_subdirectory(dCommonTests)
|
||||
add_subdirectory(dECSTests)
|
||||
add_subdirectory(dGameTests)
|
||||
|
||||
@@ -21,7 +21,7 @@ add_executable(dCommonTests ${DCOMMONTEST_SOURCES})
|
||||
# Needs to be in binary dir for ctest
|
||||
if(APPLE)
|
||||
add_custom_target(dCommonTestsLink
|
||||
${CMAKE_COMMAND} -E copy $<TARGET_FILE:MariaDB::ConnCpp> ${CMAKE_CURRENT_BINARY_DIR})
|
||||
${CMAKE_COMMAND} -E copy $<TARGET_FILE:mariadb_cpp_connector> ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_dependencies(dCommonTests dCommonTestsLink)
|
||||
endif()
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "Game.h"
|
||||
#include "MessageType/Game.h"
|
||||
#include "MessageType/World.h"
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include "magic_enum.hpp"
|
||||
|
||||
#define ENUM_EQ(e, y, z)\
|
||||
LOG("%s %s", StringifiedEnum::ToString(static_cast<e>(y)).data(), #z);\
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
add_executable(dECSTests
|
||||
"TestECS.cpp"
|
||||
)
|
||||
|
||||
# Link needed libraries
|
||||
target_link_libraries(dECSTests PRIVATE dCommon dGame dECS GTest::gtest_main)
|
||||
|
||||
# Discover the tests
|
||||
gtest_discover_tests(dECSTests)
|
||||
@@ -1,220 +0,0 @@
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <span>
|
||||
#include <optional>
|
||||
#include <gtest/gtest.h>
|
||||
#include "Core.h"
|
||||
#include <dComponents/Component.h>
|
||||
#include <eReplicaComponentType.h>
|
||||
|
||||
using namespace dECS;
|
||||
|
||||
namespace TestECS {
|
||||
using LegacyComponent = ::Component;
|
||||
|
||||
namespace Component {
|
||||
using enum eReplicaComponentType;
|
||||
|
||||
void* NULL_PARENT = nullptr;
|
||||
|
||||
struct Legacy : public LegacyComponent {
|
||||
static constexpr eReplicaComponentType ComponentType = CHANGLING;
|
||||
|
||||
Legacy() = default;
|
||||
|
||||
void Update(float deltaTime) {
|
||||
std::printf("Legacy updated!\n");
|
||||
}
|
||||
};
|
||||
|
||||
struct Invalid {
|
||||
static constexpr eReplicaComponentType ComponentType = INVALID;
|
||||
|
||||
int value;
|
||||
};
|
||||
|
||||
struct Destroyable {
|
||||
static constexpr eReplicaComponentType ComponentType = DESTROYABLE;
|
||||
|
||||
using FactionId = int32_t;
|
||||
|
||||
float health;
|
||||
float maxHealth;
|
||||
float armor;
|
||||
float maxArmor;
|
||||
float imag;
|
||||
float maxImag;
|
||||
uint32_t damageToAbsorb;
|
||||
bool immune;
|
||||
bool gmImmune;
|
||||
bool shielded;
|
||||
float actualMaxHealth;
|
||||
float actualMaxArmor;
|
||||
float actualMaxImagination;
|
||||
std::vector<FactionId> factionIds;
|
||||
bool smashable;
|
||||
};
|
||||
}
|
||||
|
||||
struct IFakeSystem {
|
||||
virtual ~IFakeSystem() = default;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr virtual size_t Count() const noexcept = 0;
|
||||
|
||||
constexpr virtual void EmplaceBack() = 0;
|
||||
};
|
||||
|
||||
template <typename... Cs>
|
||||
struct FakeSystem : public IFakeSystem {
|
||||
template <typename C>
|
||||
using Storage = std::vector<std::remove_const_t<C>>;
|
||||
|
||||
std::tuple<Storage<Cs>...> data;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr size_t Count() const noexcept override {
|
||||
return std::get<0>(data).size();
|
||||
}
|
||||
|
||||
constexpr void EmplaceBack() override {
|
||||
(std::get<Storage<Cs>>(data).emplace_back(), ...);
|
||||
}
|
||||
|
||||
template <typename C>
|
||||
requires std::disjunction_v<std::is_same<C, Cs>...>
|
||||
[[nodiscard]]
|
||||
std::span<C> Get() {
|
||||
return std::get<Storage<C>>(data);
|
||||
}
|
||||
|
||||
template <typename C>
|
||||
requires std::disjunction_v<std::is_same<C, Cs>...>
|
||||
[[nodiscard]]
|
||||
std::span<const C> Get() const {
|
||||
return std::get<Storage<C>>(data);
|
||||
}
|
||||
|
||||
template <typename Fn>
|
||||
requires std::is_invocable_r_v<void, Fn(Cs...), Cs...>
|
||||
void ForEach(Fn&& fn);
|
||||
};
|
||||
|
||||
class FakeIter {
|
||||
public:
|
||||
constexpr FakeIter(const IFakeSystem& fakeSys) noexcept
|
||||
: m_System{ fakeSys }
|
||||
{}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool Next() {
|
||||
return m_Count++ > m_System.Count();
|
||||
}
|
||||
|
||||
private:
|
||||
size_t m_Count;
|
||||
const IFakeSystem& m_System;
|
||||
};
|
||||
|
||||
template <typename... Cs>
|
||||
template <typename Fn>
|
||||
requires std::is_invocable_r_v<void, Fn(Cs...), Cs...>
|
||||
void FakeSystem<Cs...>::ForEach(Fn&& fn){
|
||||
for (size_t i = 0; i < Count(); ++i) {
|
||||
fn(Get<Cs>()[i]...);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test that entity IDs increment correctly
|
||||
TEST(ECSTest, IncrementEntityIdsSingleThread) {
|
||||
auto w = World{};
|
||||
|
||||
auto ea = w.MakeEntity();
|
||||
ASSERT_EQ(ea.GetObjectID(), 1);
|
||||
|
||||
auto eb = w.MakeEntity();
|
||||
ASSERT_EQ(eb.GetObjectID(), 2);
|
||||
|
||||
auto ec = w.MakeEntity();
|
||||
ASSERT_EQ(ec.GetObjectID(), 3);
|
||||
}
|
||||
|
||||
// Test adding and getting components
|
||||
TEST(ECSTest, MakeOneEntityAndAddComponents) {
|
||||
using namespace TestECS::Component;
|
||||
|
||||
auto w = World{};
|
||||
auto e = w.MakeEntity();
|
||||
ASSERT_EQ(e.GetObjectID(), 1);
|
||||
|
||||
// add component
|
||||
auto* const testCompPtr = e.AddComponent<Invalid>();
|
||||
ASSERT_NE(testCompPtr, nullptr);
|
||||
ASSERT_EQ(testCompPtr->ComponentType, Invalid::ComponentType);
|
||||
ASSERT_EQ(testCompPtr->value, 0);
|
||||
testCompPtr->value = 15;
|
||||
|
||||
// try getting the same component we just added
|
||||
auto* const gotTestCompPtr = e.GetComponent<Invalid>();
|
||||
ASSERT_NE(gotTestCompPtr, nullptr);
|
||||
ASSERT_EQ(gotTestCompPtr, testCompPtr);
|
||||
ASSERT_NE(gotTestCompPtr->value, 0);
|
||||
ASSERT_EQ(gotTestCompPtr->value, 15);
|
||||
}
|
||||
|
||||
// Test world scoping
|
||||
TEST(ECSTest, WorldScope) {
|
||||
using namespace TestECS::Component;
|
||||
|
||||
auto e = std::optional<dECS::Entity>{};
|
||||
|
||||
{
|
||||
auto w = World{};
|
||||
e.emplace(w.MakeEntity());
|
||||
ASSERT_EQ(e->GetObjectID(), 1);
|
||||
|
||||
// add component within scope
|
||||
auto* const cPtr = e->AddComponent<Invalid>();
|
||||
ASSERT_NE(cPtr, nullptr);
|
||||
}
|
||||
|
||||
// Attempting to access this component should return nullptr
|
||||
// now that the world has gone out of scope
|
||||
ASSERT_EQ(e->GetComponent<Invalid>(), nullptr);
|
||||
}
|
||||
|
||||
// Create and iterate over a system
|
||||
TEST(ECSTest, CreateAndIterateOverSystem) {
|
||||
using namespace TestECS::Component;
|
||||
|
||||
auto w = World{};
|
||||
auto s = w.MakeSystem<Destroyable, const Invalid>("DestInvalid");
|
||||
|
||||
size_t count = 0;
|
||||
s.ForEach([&](Destroyable& d, const Invalid& i) {
|
||||
std::printf("i = %ld: d.health = %f\n", ++count, d.health);
|
||||
d.health += 1;
|
||||
});
|
||||
}
|
||||
|
||||
TEST(ECSTest, FakeIterationForTestingPurposes) {
|
||||
using namespace TestECS;
|
||||
using namespace TestECS::Component;
|
||||
|
||||
auto s = FakeSystem<Legacy, Destroyable>{};
|
||||
|
||||
auto const r = 2 + std::rand() % 8;
|
||||
for (size_t i = 0; i < r; ++i) {
|
||||
s.EmplaceBack();
|
||||
}
|
||||
|
||||
size_t count = 0;
|
||||
s.ForEach([&](Legacy& l, Destroyable& d) {
|
||||
l.Update(0.0f);
|
||||
std::printf("i = %ld: d.health = %f\n", ++count, d.health);
|
||||
d.health += 1;
|
||||
});
|
||||
std::printf("Total count = %ld\n", count);
|
||||
ASSERT_EQ(r, count);
|
||||
}
|
||||
@@ -16,7 +16,7 @@ add_executable(dGameTests ${DGAMETEST_SOURCES})
|
||||
|
||||
if(APPLE)
|
||||
add_custom_target(dGameTestsLink
|
||||
${CMAKE_COMMAND} -E copy $<TARGET_FILE:MariaDB::ConnCpp> ${CMAKE_CURRENT_BINARY_DIR})
|
||||
${CMAKE_COMMAND} -E copy $<TARGET_FILE:mariadb_cpp_connector> ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_dependencies(dGameTests dGameTestsLink)
|
||||
endif()
|
||||
|
||||
3
thirdparty/CMakeLists.txt
vendored
3
thirdparty/CMakeLists.txt
vendored
@@ -34,6 +34,9 @@ target_include_directories(bcrypt PRIVATE "libbcrypt/src")
|
||||
# Source code for sqlite
|
||||
add_subdirectory(SQLite)
|
||||
|
||||
# Source code for magic_enum
|
||||
add_subdirectory(magic_enum)
|
||||
|
||||
# Create our third party library objects
|
||||
add_subdirectory(raknet)
|
||||
|
||||
|
||||
1
thirdparty/magic_enum
vendored
Submodule
1
thirdparty/magic_enum
vendored
Submodule
Submodule thirdparty/magic_enum added at e55b9b54d5
Reference in New Issue
Block a user