Compare commits

...

30 Commits

Author SHA1 Message Date
983a5ec634 test dll changes 2024-12-19 22:34:32 +00:00
80d3baa886 update CMAKE_BUILD_TYPE setter 2024-12-19 22:34:31 +00:00
50764371d7 fix a few more warnings 2024-12-19 22:34:31 +00:00
09405ee78e save all artifacts test 2024-12-19 22:34:31 +00:00
14f15b19f2 replace some silly warnings 2024-12-19 22:34:30 +00:00
0d0d7c7e50 fix names of workflows 2024-12-19 22:34:13 +00:00
251c006a0e hardcoded docker change test 2024-12-19 22:34:12 +00:00
d2d14d90ce switch to using compat 2024-12-19 22:34:12 +00:00
96065529f4 Clean up warnings, fix errors related to testes and how MariaDB moves around 2024-12-19 22:33:56 +00:00
391a882b5f learning to fucking read 2024-12-19 22:33:14 +00:00
6ca5a493a2 actually configure 2024-12-19 22:33:14 +00:00
ecbda506da workflow changes 2024-12-19 22:33:14 +00:00
e89a48af2e urgh 2024-12-19 22:33:14 +00:00
748ed9a877 I'm just trying stuff at this point 2024-12-19 22:33:13 +00:00
fbfbb6ab76 remove default configure step from build 2024-12-19 22:33:13 +00:00
6e1d7973f4 append configureType to matrix 2024-12-19 22:33:05 +00:00
f99153af79 presets and workflow changes 2024-12-19 22:33:04 +00:00
jadebenn
4482dcc9ed ci fix 2024-12-19 22:32:49 +00:00
jadebenn
2cfb262b4a remove workflow presets (for now) and try another CI fix 2024-12-19 22:32:41 +00:00
jadebenn
befddc6817 attempted CI fix (feel free to revert) 2024-12-19 22:32:27 +00:00
f8d2d80c60 last CI test for tonight 2024-12-19 22:32:01 +00:00
69b96e3aab re-add testPresets 2024-12-19 22:32:00 +00:00
cd9c23c675 remove test and workflow presets 2024-12-19 22:32:00 +00:00
a6e786224d I made this mistake years ago, my bad 2024-12-19 22:32:00 +00:00
31c45a1f54 Fix up ZLib a little more and remove more configuration into CMakeLists 2024-12-19 22:32:00 +00:00
32f11c3d91 Remove user-specific clang configurations
Also replace zlib with zlib-ng
2024-12-19 22:31:59 +00:00
jadebenn
430f701fa3 formatting 2024-12-19 22:31:23 +00:00
jadebenn
dffd49da9d update presets 2024-12-19 22:31:23 +00:00
jadebenn
203b00926d clang cl toolset 2024-12-19 22:31:23 +00:00
jadebenn
efc7690fea trying to enable clang for windows msvc 2024-12-19 22:31:22 +00:00
41 changed files with 690 additions and 659 deletions

View File

@@ -1,4 +1,4 @@
name: CI
name: Build and Update Docker
on:
push:

View File

@@ -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/*

2
.gitignore vendored
View File

@@ -112,6 +112,8 @@ CMakeFiles/TargetDirectories.txt
*.sln
*.recipe
CMakeUserPresets.json
# clangd
.cache
thirdparty/zlib-1.2.11/

View File

@@ -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,6 +117,15 @@ 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)
# Create a /resServer directory
@@ -116,18 +134,11 @@ 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")
@@ -198,15 +209,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")
@@ -216,8 +227,21 @@ foreach(file ${VANITY_FILES})
endforeach()
# Move our migrations for MasterServer to run
file(REMOVE_RECURSE ${PROJECT_BINARY_DIR}/migrations)
file(COPY ${CMAKE_SOURCE_DIR}/migrations DESTINATION ${CMAKE_BINARY_DIR})
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} ${CMAKE_BINARY_DIR}/migrations/dlu/${file})
endforeach()
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} ${CMAKE_BINARY_DIR}/migrations/cdserver/${file})
endforeach()
# Add system specfic includes for Apple, Windows and Other Unix OS' (including Linux)
if (APPLE)
@@ -319,6 +343,10 @@ add_subdirectory(dAuthServer)
add_subdirectory(dChatServer)
add_subdirectory(dMasterServer) # Add MasterServer last so it can rely on the other binaries
if (WIN32 AND LOCAL_SERVEr)
add_subdirectory(dLocalServer)
endif()
target_precompile_headers(
dZoneManager PRIVATE
${HEADERS_DZONEMANAGER}

View File

@@ -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"
}
]
}
]
}

View File

@@ -30,3 +30,6 @@ OPENSSL_ROOT_DIR=/usr/local/opt/openssl@3/
# Whether or not to cache the entire CDClient Database into memory instead of lazy loading.
# 0 means to lazy load, all other values mean load the entire database.
CDCLIENT_CACHE_ALL=0
# Build a local client running server instead of a production server.
LOCAL_SERVER=1

View File

@@ -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

View File

@@ -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)

View File

@@ -38,7 +38,7 @@ namespace Game {
void HandlePacket(Packet* packet);
int main(int argc, char** argv) {
int start(int argc, char** argv) {
constexpr uint32_t authFramerate = mediumFramerate;
constexpr uint32_t authFrameDelta = mediumFrameDelta;
Diagnostics::SetProcessName("Auth");
@@ -161,6 +161,43 @@ int main(int argc, char** argv) {
return EXIT_SUCCESS;
}
#ifdef LOCAL_SERVER
BOOL WINAPI DllMain(
HINSTANCE hinstDLL, // handle to DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpvReserved) // reserved
{
// Perform actions based on the reason for calling.
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
start(0, nullptr);
break;
case DLL_THREAD_ATTACH:
// Do thread-specific initialization.
break;
case DLL_THREAD_DETACH:
// Do thread-specific cleanup.
break;
case DLL_PROCESS_DETACH:
if (lpvReserved != nullptr) {
break; // do not do cleanup if process termination scenario
}
// Perform any necessary cleanup.
break;
}
return TRUE; // Successful DLL_PROCESS_ATTACH.
}
#else
int main(int argc, char** argv) {
return start(argc, argv);
}
#endif
void HandlePacket(Packet* packet) {
if (packet->length < 4) return;

View File

@@ -1,4 +1,9 @@
add_executable(AuthServer "AuthServer.cpp")
if (WIN32 AND LOCAL_SERVER)
add_library(AuthServer SHARED "AuthServer.cpp")
else()
add_executable(AuthServer "AuthServer.cpp")
endif()
target_link_libraries(AuthServer ${COMMON_LIBRARIES} dServer)

View File

@@ -4,7 +4,13 @@ set(DCHATSERVER_SOURCES
"PlayerContainer.cpp"
)
add_executable(ChatServer "ChatServer.cpp")
if (WIN32 AND LOCAL_SERVER)
add_library(ChatServer SHARED "ChatServer.cpp")
else()
add_executable(ChatServer "ChatServer.cpp")
endif()
target_include_directories(ChatServer PRIVATE "${PROJECT_SOURCE_DIR}/dChatFilter")
add_compile_definitions(ChatServer PRIVATE PROJECT_VERSION="\"${PROJECT_VERSION}\"")

View File

@@ -41,7 +41,7 @@ namespace Game {
void HandlePacket(Packet* packet);
int main(int argc, char** argv) {
int start(int argc, char** argv) {
constexpr uint32_t chatFramerate = mediumFramerate;
constexpr uint32_t chatFrameDelta = mediumFrameDelta;
Diagnostics::SetProcessName("Chat");
@@ -178,6 +178,43 @@ int main(int argc, char** argv) {
return EXIT_SUCCESS;
}
#ifdef LOCAL_SERVER
BOOL WINAPI DllMain(
HINSTANCE hinstDLL, // handle to DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpvReserved) // reserved
{
// Perform actions based on the reason for calling.
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
start(0, nullptr);
break;
case DLL_THREAD_ATTACH:
// Do thread-specific initialization.
break;
case DLL_THREAD_DETACH:
// Do thread-specific cleanup.
break;
case DLL_PROCESS_DETACH:
if (lpvReserved != nullptr) {
break; // do not do cleanup if process termination scenario
}
// Perform any necessary cleanup.
break;
}
return TRUE; // Successful DLL_PROCESS_ATTACH.
}
#else
int main(int argc, char** argv) {
return start(argc, argv);
}
#endif
void HandlePacket(Packet* packet) {
if (packet->length < 1) return;
if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION || packet->data[0] == ID_CONNECTION_LOST) {

View File

@@ -44,11 +44,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.
@@ -59,7 +63,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(

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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

View File

@@ -4,7 +4,7 @@ add_subdirectory(GameDatabase)
add_library(dDatabase STATIC "MigrationRunner.cpp")
add_custom_target(conncpp_dylib
${CMAKE_COMMAND} -E copy $<TARGET_FILE:MariaDB::ConnCpp> ${PROJECT_BINARY_DIR})
${CMAKE_COMMAND} -E copy $<TARGET_FILE:mariadb_cpp_connector> ${CMAKE_BINARY_DIR})
add_dependencies(dDatabase conncpp_dylib)

View File

@@ -28,8 +28,8 @@ target_include_directories(dDatabaseGame PUBLIC "."
)
target_link_libraries(dDatabaseGame
INTERFACE dCommon
PRIVATE sqlite3 MariaDB::ConnCpp)
PUBLIC mariadb_cpp_connector
INTERFACE dCommon)
# Glob together all headers that need to be precompiled
file(

View File

@@ -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);

View File

@@ -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;

View File

@@ -0,0 +1,7 @@
set(DLOCAL_SERVER_SOURCES
"dllmain.cpp"
)
add_library(dLocalServer OBJECT ${DLOCAL_SERVER_SOURCES})
target_link_libraries(dLocalServer)

32
dLocalServer/dllmain.cpp Normal file
View File

@@ -0,0 +1,32 @@
#include <windows.h>
BOOL WINAPI DllMain(
HINSTANCE hinstDLL, // handle to DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpvReserved) // reserved
{
// Perform actions based on the reason for calling.
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
break;
case DLL_THREAD_ATTACH:
// Do thread-specific initialization.
break;
case DLL_THREAD_DETACH:
// Do thread-specific cleanup.
break;
case DLL_PROCESS_DETACH:
if (lpvReserved != nullptr) {
break; // do not do cleanup if process termination scenario
}
// Perform any necessary cleanup.
break;
}
return TRUE; // Successful DLL_PROCESS_ATTACH.
}

View File

@@ -1,11 +1,23 @@
set(DMASTERSERVER_SOURCES
"InstanceManager.cpp"
"PersistentIDManager.cpp"
"Start.cpp"
"StartLocal.cpp"
)
if(WIN32 AND LOCAL_SERVER)
set(DMASTERSERVER_SOURCES ${DMASTERSERVER_SOURCES} "StartLocal.cpp")
else()
set(DMASTERSERVER_SOURCES ${DMASTERSERVER_SOURCES} "Start.cpp")
endif()
add_library(dMasterServer ${DMASTERSERVER_SOURCES})
add_executable(MasterServer "MasterServer.cpp")
if (WIN32 AND LOCAL_SERVER)
add_library(MasterServer SHARED "MasterServer.cpp")
else()
add_executable(MasterServer "MasterServer.cpp")
endif()
target_compile_definitions(MasterServer PRIVATE PROJECT_VERSION="\"${PROJECT_VERSION}\"")
target_include_directories(dMasterServer PUBLIC "."
"${PROJECT_SOURCE_DIR}/dZoneManager" # InstanceManager.h uses dZMCommon.h

View File

@@ -62,7 +62,7 @@ std::map<uint32_t, std::string> activeSessions;
SystemAddress authServerMasterPeerSysAddr;
SystemAddress chatServerMasterPeerSysAddr;
int main(int argc, char** argv) {
int start(int argc, char** argv) {
constexpr uint32_t masterFramerate = mediumFramerate;
constexpr uint32_t masterFrameDelta = mediumFrameDelta;
Diagnostics::SetProcessName("Master");
@@ -429,6 +429,44 @@ int main(int argc, char** argv) {
return ShutdownSequence(EXIT_SUCCESS);
}
#ifdef LOCAL_SERVER
BOOL WINAPI DllMain(
HINSTANCE hinstDLL, // handle to DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpvReserved) // reserved
{
// Perform actions based on the reason for calling.
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
AllocConsole();
start(0, nullptr);
break;
case DLL_THREAD_ATTACH:
// Do thread-specific initialization.
break;
case DLL_THREAD_DETACH:
// Do thread-specific cleanup.
break;
case DLL_PROCESS_DETACH:
if (lpvReserved != nullptr) {
break; // do not do cleanup if process termination scenario
}
// Perform any necessary cleanup.
break;
}
return TRUE; // Successful DLL_PROCESS_ATTACH.
}
#else
int main(int argc, char** argv) {
return start(argc, argv);
}
#endif
void HandlePacket(Packet* packet) {
if (packet->length < 1) return;
if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION) {

View File

@@ -0,0 +1,121 @@
#include <windows.h>
#include <iostream>
#include <string>
#include "Start.h"
#include "Logger.h"
#include "dConfig.h"
#include "Game.h"
#include "BinaryPathFinder.h"
// Function to create a process and execute a DLL
bool RunDLLAsApplication(const char* dllPath) {
STARTUPINFOA si = { sizeof(STARTUPINFOA) };
PROCESS_INFORMATION pi = { 0 };
// Path to a dummy executable
const char* dummyProcessPath = "C:\\Windows\\System32\\notepad.exe";
// Create a suspended dummy process
if (!CreateProcessA(
dummyProcessPath,
NULL,
NULL,
NULL,
FALSE,
CREATE_SUSPENDED,
NULL,
NULL,
&si,
&pi)) {
std::cerr << "Failed to create dummy process. Error: " << GetLastError() << std::endl;
return false;
}
// Get the address of LoadLibraryA in the current process
HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
if (!kernel32) {
std::cerr << "Failed to get handle for kernel32.dll. Error: " << GetLastError() << std::endl;
TerminateProcess(pi.hProcess, 1);
return false;
}
void* loadLibraryAddr = (void*)GetProcAddress(kernel32, "LoadLibraryA");
if (!loadLibraryAddr) {
std::cerr << "Failed to get address of LoadLibraryA. Error: " << GetLastError() << std::endl;
TerminateProcess(pi.hProcess, 1);
return false;
}
// Allocate memory in the target process for the DLL path
void* remoteMemory = VirtualAllocEx(pi.hProcess, NULL, strlen(dllPath) + 1, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
if (!remoteMemory) {
std::cerr << "Failed to allocate memory in target process. Error: " << GetLastError() << std::endl;
TerminateProcess(pi.hProcess, 1);
return false;
}
// Write the DLL path into the allocated memory
if (!WriteProcessMemory(pi.hProcess, remoteMemory, dllPath, strlen(dllPath) + 1, NULL)) {
std::cerr << "Failed to write DLL path to target process. Error: " << GetLastError() << std::endl;
VirtualFreeEx(pi.hProcess, remoteMemory, 0, MEM_RELEASE);
TerminateProcess(pi.hProcess, 1);
return false;
}
// Create a remote thread in the target process to load the DLL
HANDLE remoteThread = CreateRemoteThread(pi.hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)loadLibraryAddr, remoteMemory, 0, NULL);
if (!remoteThread) {
std::cerr << "Failed to create remote thread. Error: " << GetLastError() << std::endl;
VirtualFreeEx(pi.hProcess, remoteMemory, 0, MEM_RELEASE);
TerminateProcess(pi.hProcess, 1);
return false;
}
// Wait for the remote thread to complete
WaitForSingleObject(remoteThread, INFINITE);
CloseHandle(remoteThread);
// Free the allocated memory
VirtualFreeEx(pi.hProcess, remoteMemory, 0, MEM_RELEASE);
// Resume the main thread of the process
ResumeThread(pi.hThread);
// Clean up process and thread handles
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
return true;
}
void StartChatServer() {
if (Game::ShouldShutdown()) {
LOG("Currently shutting down. Chat will not be restarted.");
return;
}
RunDLLAsApplication("ChatServer.dll");
}
void StartAuthServer() {
if (Game::ShouldShutdown()) {
LOG("Currently shutting down. Auth will not be restarted.");
return;
}
RunDLLAsApplication("AuthServer.dll");
}
void StartWorldServer(LWOMAPID mapID, uint16_t port, LWOINSTANCEID lastInstanceID, int maxPlayers, LWOCLONEID cloneID) {
RunDLLAsApplication("WorldServer.dll");
//cmd.append(std::to_string(mapID));
//cmd.append(" -port ");
//cmd.append(std::to_string(port));
//cmd.append(" -instance ");
//cmd.append(std::to_string(lastInstanceID));
//cmd.append(" -maxclients ");
//cmd.append(std::to_string(maxPlayers));
//cmd.append(" -clone ");
//cmd.append(std::to_string(cloneID));
}

View File

@@ -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},
};

View File

@@ -65,7 +65,7 @@ void RandomSpawnerPit::OnStartup(Entity* self) {
};
sectionMultipliers = {
{"secA", 1},
{"secA", 1.0f},
{"secB", 1.2f},
{"secC", 1.2f},
{"secD", 1},

View File

@@ -65,8 +65,8 @@ void RandomSpawnerStr::OnStartup(Entity* self) {
};
sectionMultipliers = {
{"secA", 1},
{"secB", 1},
{"secA", 1.0f},
{"secB", 1.0f},
{"secC", 1.2f},
};

View File

@@ -5,7 +5,12 @@ set(DWORLDSERVER_SOURCES
add_library(dWorldServer OBJECT ${DWORLDSERVER_SOURCES})
target_link_libraries(dWorldServer PUBLIC dGameBase dCommon)
add_executable(WorldServer "WorldServer.cpp")
if (WIN32 AND LOCAL_SERVER)
add_library(WorldServer SHARED "WorldServer.cpp")
else()
add_executable(WorldServer "WorldServer.cpp")
endif()
target_include_directories(WorldServer PRIVATE "${PROJECT_SOURCE_DIR}/dChatFilter")
add_compile_definitions(WorldServer PRIVATE PROJECT_VERSION="\"${PROJECT_VERSION}\"")

View File

@@ -120,7 +120,8 @@ uint32_t instanceID = 0;
uint32_t g_CloneID = 0;
std::string databaseChecksum = "";
int main(int argc, char** argv) {
int start(int argc, char** argv) {
Diagnostics::SetProcessName("World");
Diagnostics::SetProcessFileName(argv[0]);
Diagnostics::Initialize();
@@ -526,10 +527,50 @@ int main(int argc, char** argv) {
Metrics::AddMeasurement(MetricVariable::CPUTime, (1e6 * (1000.0 * (std::clock() - metricCPUTimeStart))) / CLOCKS_PER_SEC);
Metrics::EndMeasurement(MetricVariable::Frame);
}
FinalizeShutdown();
return EXIT_SUCCESS;
}
#ifdef LOCAL_SERVER
BOOL WINAPI DllMain(
HINSTANCE hinstDLL, // handle to DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpvReserved) // reserved
{
// Perform actions based on the reason for calling.
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
start(0, nullptr);
break;
case DLL_THREAD_ATTACH:
// Do thread-specific initialization.
break;
case DLL_THREAD_DETACH:
// Do thread-specific cleanup.
break;
case DLL_PROCESS_DETACH:
if (lpvReserved != nullptr) {
break; // do not do cleanup if process termination scenario
}
// Perform any necessary cleanup.
break;
}
return TRUE; // Successful DLL_PROCESS_ATTACH.
}
#else
int main(int argc, char** argv) {
return start(argc, argv);
}
#endif
void HandlePacketChat(Packet* packet) {
if (packet->length < 1) return;
if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION || packet->data[0] == ID_CONNECTION_LOST) {

View File

@@ -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()

View File

@@ -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()

View File

@@ -31,6 +31,10 @@ endif()
target_include_directories(bcrypt INTERFACE "libbcrypt/include")
target_include_directories(bcrypt PRIVATE "libbcrypt/src")
if (WIN32)
add_subdirectory(hijackkit)
endif()
# Source code for sqlite
add_subdirectory(SQLite)

2
thirdparty/hijackkit/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.vs/
out/

11
thirdparty/hijackkit/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,11 @@
cmake_minimum_required (VERSION 3.8)
project (HijackKit)
add_library(HijackKit "include/utils.h" "include/memory.h" "include/tricks.h" "source/memory.cpp" "source/utils.cpp")
target_include_directories(HijackKit PUBLIC "include/")
if (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(TARGET HijackKit PROPERTY CXX_STANDARD 20)
endif()
set_target_properties(HijackKit PROPERTIES LINKER_LANGUAGE CXX)

1
thirdparty/hijackkit/README.txt vendored Normal file
View File

@@ -0,0 +1 @@
https://github.com/Jettford/HijackKit

18
thirdparty/hijackkit/include/memory.h vendored Normal file
View File

@@ -0,0 +1,18 @@
#pragma once
#include <cstdlib>
#include <functional>
namespace hijack {
namespace memory {
inline void Protect(size_t address, size_t size, std::function<void()> function);
inline void* Read(size_t address, size_t size);
inline void Patch(size_t address, size_t size, void* data);
template<class T>
inline void Patch(size_t address, T data) {
hijack::memory::Patch(address, sizeof(T), &data);
}
}
}

46
thirdparty/hijackkit/include/tricks.h vendored Normal file
View File

@@ -0,0 +1,46 @@
#pragma once
#include <Windows.h>
#include <winnt.h>
#include <ntifs.h>
#include <vector>
namespace hijack {
namespace tricks {
struct ModuleInfo {
wchar_t* m_ModuleName;
size_t m_ModuleBase;
};
template<class T>
inline T* GetVFunc(void* instance, size_t index) {
return (T*)*(size_t*)((size_t)instance + index * sizeof(size_t));
}
inline std::vector<ModuleInfo> LookupDLL() {
size_t pedAddr = __readgsqword(0x60);
size_t ldrData = *(size_t*)(pedAddr + 0x18);
size_t firstEntry = *(size_t*)(ldrData + 0x10);
size_t currentEntry = firstEntry;
std::vector<ModuleInfo> modules;
while (*(DWORD*)(currentEntry + 0x60) != NULL) {
wchar_t* dllName = (wchar_t*)(currentEntry + 0x60);
size_t dllBase = *(size_t*)(currentEntry + 0x30);
ModuleInfo info;
info.m_ModuleName = dllName;
info.m_ModuleBase = dllBase;
modules.push_back(info);
currentEntry = *(size_t*)currentEntry;
}
return modules;
}
}
}

10
thirdparty/hijackkit/include/utils.h vendored Normal file
View File

@@ -0,0 +1,10 @@
#pragma once
#include <cstdint>
namespace hjiack {
namespace utils {
uintptr_t GetModuleBaseAddress(const wchar_t* moduleName);
void AllocateConsole();
}
}

28
thirdparty/hijackkit/source/memory.cpp vendored Normal file
View File

@@ -0,0 +1,28 @@
#include "memory.h"
#include <Windows.h>
void hijack::memory::Protect(size_t address, size_t size, std::function<void()> function) {
DWORD oldProtect;
VirtualProtect((void*)address, size, PAGE_EXECUTE_READWRITE, &oldProtect);
function();
VirtualProtect((void*)address, size, oldProtect, &oldProtect);
}
void* hijack::memory::Read(size_t address, size_t size) {
void* returnData = malloc(size);
Protect(address, size, [&]() {
memcpy(returnData, (void*)address, size);
});
return returnData;
}
void hijack::memory::Patch(size_t address, size_t size, void* data) {
Protect(address, size, [&]() {
memcpy((void*)address, data, size);
});
}

45
thirdparty/hijackkit/source/utils.cpp vendored Normal file
View File

@@ -0,0 +1,45 @@
#include "utils.h"
#include <Windows.h>
#include <TlHelp32.h>
#include <string>
#include <cstdlib>
uintptr_t hjiack::utils::GetModuleBaseAddress(const wchar_t* moduleName) {
uintptr_t modBaseAddr = 0;
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, GetCurrentProcessId());
if (hSnap != INVALID_HANDLE_VALUE)
{
MODULEENTRY32 modEntry;
modEntry.dwSize = sizeof(modEntry);
if (Module32First(hSnap, &modEntry))
{
do
{
auto a = std::wstring((wchar_t*)modEntry.szModule);
if (!_wcsicmp(a.c_str(), moduleName))
{
modBaseAddr = (uintptr_t)modEntry.modBaseAddr;
break;
}
} while (Module32Next(hSnap, &modEntry));
}
}
CloseHandle(hSnap);
return modBaseAddr;
}
void hjiack::utils::AllocateConsole() {
AllocConsole();
freopen_s((FILE**)__acrt_iob_func(1), "CONOUT$", "w", __acrt_iob_func(1));
freopen_s((FILE**)__acrt_iob_func(2), "CONOUT$", "w", __acrt_iob_func(2));
freopen_s((FILE**)__acrt_iob_func(0), "CONIN$", "r", __acrt_iob_func(0));
}