mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-12-31 00:49:35 -06:00
Compare commits
10 Commits
dll-mode
...
entity-cle
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81b4f84d03 | ||
|
|
6ed6efa921 | ||
|
|
dcc9e023a6 | ||
|
|
8509ec8856 | ||
|
|
18295017c1 | ||
|
|
e8f011b830 | ||
|
|
a787673baf | ||
|
|
e869c0ad03 | ||
|
|
b2af3fa9d4 | ||
|
|
2560bb00da |
2
.github/workflows/build-and-push-docker.yml
vendored
2
.github/workflows/build-and-push-docker.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: Build and Update Docker
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
26
.github/workflows/build-and-test.yml
vendored
26
.github/workflows/build-and-test.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: Build And Test
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -14,13 +14,6 @@ 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
|
||||
@@ -40,13 +33,20 @@ jobs:
|
||||
- name: cmake
|
||||
uses: lukka/run-cmake@v10
|
||||
with:
|
||||
configurePreset: "${{matrix.configureType}}"
|
||||
buildPreset: "ci-${{matrix.os}}"
|
||||
testPreset: "ci-${{matrix.os}}"
|
||||
|
||||
workflowPreset: "ci-${{matrix.os}}"
|
||||
- name: artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-${{matrix.os}}
|
||||
path: |
|
||||
build/*
|
||||
build/*/*Server*
|
||||
build/*/*.ini
|
||||
build/*/*.so
|
||||
build/*/*.dll
|
||||
build/*/*.dylib
|
||||
build/*/vanity/
|
||||
build/*/navmeshes/
|
||||
build/*/migrations/
|
||||
build/*/*.dcf
|
||||
!build/*/*.pdb
|
||||
!build/*/d*/
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -112,8 +112,6 @@ CMakeFiles/TargetDirectories.txt
|
||||
*.sln
|
||||
*.recipe
|
||||
|
||||
CMakeUserPresets.json
|
||||
|
||||
# clangd
|
||||
.cache
|
||||
thirdparty/zlib-1.2.11/
|
||||
|
||||
@@ -19,14 +19,6 @@ 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)
|
||||
@@ -80,7 +72,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" "-Wno-error=implicit-function-declaration" "-Wno-error=int-conversion")
|
||||
add_compile_options("-static-libgcc" "-lstdc++fs")
|
||||
endif()
|
||||
|
||||
if(${DYNAMIC} AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
@@ -98,11 +90,10 @@ elseif(WIN32)
|
||||
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
# 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})
|
||||
# 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
|
||||
|
||||
# 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})
|
||||
@@ -117,15 +108,6 @@ 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
|
||||
@@ -134,11 +116,18 @@ 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")
|
||||
@@ -209,15 +198,15 @@ endforeach()
|
||||
message(STATUS "Resource file integrity check complete")
|
||||
|
||||
# if navmeshes directory does not exist, create it
|
||||
if(NOT EXISTS ${CMAKE_BINARY_DIR}/navmeshes)
|
||||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/navmeshes)
|
||||
if(NOT EXISTS ${PROJECT_BINARY_DIR}/navmeshes)
|
||||
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/navmeshes)
|
||||
endif()
|
||||
|
||||
# Copy navmesh data on first build and extract it
|
||||
configure_file(${CMAKE_SOURCE_DIR}/resources/navmeshes.zip ${CMAKE_BINARY_DIR}/navmeshes.zip COPYONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/resources/navmeshes.zip ${PROJECT_BINARY_DIR}/navmeshes.zip COPYONLY)
|
||||
|
||||
file(ARCHIVE_EXTRACT INPUT ${CMAKE_BINARY_DIR}/navmeshes.zip DESTINATION ${CMAKE_BINARY_DIR}/navmeshes)
|
||||
file(REMOVE ${CMAKE_BINARY_DIR}/navmeshes.zip)
|
||||
file(ARCHIVE_EXTRACT INPUT ${PROJECT_BINARY_DIR}/navmeshes.zip DESTINATION ${PROJECT_BINARY_DIR}/navmeshes)
|
||||
file(REMOVE ${PROJECT_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")
|
||||
@@ -227,21 +216,8 @@ foreach(file ${VANITY_FILES})
|
||||
endforeach()
|
||||
|
||||
# Move our migrations for MasterServer to run
|
||||
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()
|
||||
file(REMOVE_RECURSE ${PROJECT_BINARY_DIR}/migrations)
|
||||
file(COPY ${CMAKE_SOURCE_DIR}/migrations DESTINATION ${CMAKE_BINARY_DIR})
|
||||
|
||||
# Add system specfic includes for Apple, Windows and Other Unix OS' (including Linux)
|
||||
if (APPLE)
|
||||
@@ -343,10 +319,6 @@ 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}
|
||||
|
||||
@@ -11,37 +11,72 @@
|
||||
"displayName": "Default configure step",
|
||||
"description": "Use 'build' dir and Unix makefiles",
|
||||
"binaryDir": "${sourceDir}/build",
|
||||
"generator": "Unix Makefiles",
|
||||
"hidden": true
|
||||
"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"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-default",
|
||||
"inherits": "default",
|
||||
"displayName": "Windows Default Configure Settings",
|
||||
"inherits": "windows-msvc",
|
||||
"displayName": "Windows only Configure Settings",
|
||||
"description": "Sets build and install directories",
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"generator": "Ninja",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Windows"
|
||||
},
|
||||
"hidden": true
|
||||
"architecture": {
|
||||
"value": "x64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"name": "linux-config",
|
||||
"inherits": "default",
|
||||
"hidden": true,
|
||||
"condition": {
|
||||
@@ -51,74 +86,553 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"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-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-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": "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": "macos",
|
||||
"inherits": "default",
|
||||
"displayName": "MacOS",
|
||||
"displayName": "[Multi] MacOS",
|
||||
"description": "Create a build for MacOS",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Darwin"
|
||||
}
|
||||
},
|
||||
"binaryDir": "${sourceDir}/build/macos"
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{ "name": "ci-ubuntu-22.04", "configurePreset": "linux-gnu" },
|
||||
{ "name": "ci-macos-13", "configurePreset": "macos" },
|
||||
{ "name": "ci-windows-2022", "configurePreset": "windows-msvc" }
|
||||
{
|
||||
"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"
|
||||
}
|
||||
],
|
||||
"testPresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"hidden": true,
|
||||
"execution": {
|
||||
"jobs": 2
|
||||
},
|
||||
"output": {
|
||||
"outputOnFailure": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ci-ubuntu-22.04",
|
||||
"configurePreset": "linux-gnu",
|
||||
"displayName": "CI Tests on Linux",
|
||||
"inherits": "default"
|
||||
"name": "default",
|
||||
"configurePreset": "default",
|
||||
"execution": {
|
||||
"jobs": 2
|
||||
},
|
||||
"output": {
|
||||
"outputOnFailure": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ci-macos-13",
|
||||
"configurePreset": "macos",
|
||||
"displayName": "CI Tests on MacOS",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "ci-windows-2022",
|
||||
"name": "windows-msvc-test",
|
||||
"inherits": "default",
|
||||
"configurePreset": "windows-msvc",
|
||||
"displayName": "CI Tests on windows",
|
||||
"inherits": "default",
|
||||
|
||||
"configuration": "RelWithDebInfo",
|
||||
"hidden": true,
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
PROJECT_VERSION_MAJOR=2
|
||||
PROJECT_VERSION_MINOR=3
|
||||
PROJECT_VERSION_MAJOR=3
|
||||
PROJECT_VERSION_MINOR=0
|
||||
PROJECT_VERSION_PATCH=0
|
||||
|
||||
# Debugging
|
||||
@@ -30,6 +30,3 @@ 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
|
||||
|
||||
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/Linux-x86_64/GNU/Release/mariadbcpp/libmariadbcpp.so /usr/local/lib/
|
||||
COPY --from=build /app/build/mariadbcpp/libmariadbcpp.so /usr/local/lib/
|
||||
RUN ldconfig
|
||||
|
||||
# Server bins
|
||||
COPY --from=build /app/build/Linux-x86_64/GNU/Release/*Server /app/
|
||||
COPY --from=build /app/build/*Server /app/
|
||||
|
||||
# Necessary suplimentary files
|
||||
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/
|
||||
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/
|
||||
|
||||
# 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/Linux-x86_64/GNU/Release/*.ini /app/default-configs/
|
||||
COPY --from=build /app/build/Linux-x86_64/GNU/Release/vanity/*.* /app/default-vanity/
|
||||
COPY --from=build /app/build/*.ini /app/default-configs/
|
||||
COPY --from=build /app/build/vanity/*.* /app/default-vanity/
|
||||
|
||||
# needed as the container runs with the root user
|
||||
# and therefore sudo doesn't exist
|
||||
|
||||
@@ -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 "${CMAKE_BINARY_DIR}/msi")
|
||||
set(MARIADB_CONNECTOR_DIR "${CMAKE_BINARY_DIR}/mariadbcpp")
|
||||
set(MARIADB_MSI_DIR "${PROJECT_BINARY_DIR}/msi")
|
||||
set(MARIADB_CONNECTOR_DIR "${PROJECT_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}"
|
||||
"${CMAKE_BINARY_DIR}")
|
||||
"${PROJECT_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 ${CMAKE_BINARY_DIR}/prefix)
|
||||
set(MARIADBCPP_LIBRARY_DIR ${CMAKE_BINARY_DIR}/mariadbcpp)
|
||||
set(MARIADBCPP_INSTALL_DIR ${PROJECT_BINARY_DIR}/prefix)
|
||||
set(MARIADBCPP_LIBRARY_DIR ${PROJECT_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 "${CMAKE_BINARY_DIR}/thirdparty/mariadb-connector-cpp"
|
||||
PREFIX "${PROJECT_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_cpp_connector SHARED IMPORTED GLOBAL)
|
||||
add_dependencies(mariadb_cpp_connector mariadb_connector_cpp)
|
||||
set_target_properties(mariadb_cpp_connector PROPERTIES
|
||||
add_library(MariaDB::ConnCpp SHARED IMPORTED GLOBAL)
|
||||
add_dependencies(MariaDB::ConnCpp mariadb_connector_cpp)
|
||||
set_target_properties(MariaDB::ConnCpp PROPERTIES
|
||||
IMPORTED_LOCATION "${MARIADBCPP_SHARED_LIBRARY_LOCATION}")
|
||||
|
||||
if(WIN32)
|
||||
set_target_properties(mariadb_cpp_connector PROPERTIES
|
||||
set_target_properties(MariaDB::ConnCpp PROPERTIES
|
||||
IMPORTED_IMPLIB "${MARIADB_IMPLIB_LOCATION}")
|
||||
elseif(APPLE)
|
||||
set_target_properties(mariadb_cpp_connector PROPERTIES
|
||||
set_target_properties(MariaDB::ConnCpp PROPERTIES
|
||||
IMPORTED_SONAME "libmariadbcpp")
|
||||
endif()
|
||||
|
||||
# Add directories to include lists
|
||||
target_include_directories(mariadb_cpp_connector SYSTEM INTERFACE ${MARIADB_INCLUDE_DIR})
|
||||
target_include_directories(MariaDB::ConnCpp SYSTEM INTERFACE ${MARIADB_INCLUDE_DIR})
|
||||
|
||||
set(mariadb_found TRUE)
|
||||
set(MariaDB_FOUND TRUE)
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Game {
|
||||
|
||||
void HandlePacket(Packet* packet);
|
||||
|
||||
int start(int argc, char** argv) {
|
||||
int main(int argc, char** argv) {
|
||||
constexpr uint32_t authFramerate = mediumFramerate;
|
||||
constexpr uint32_t authFrameDelta = mediumFrameDelta;
|
||||
Diagnostics::SetProcessName("Auth");
|
||||
@@ -161,43 +161,6 @@ int start(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;
|
||||
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
|
||||
if (WIN32 AND LOCAL_SERVER)
|
||||
add_library(AuthServer SHARED "AuthServer.cpp")
|
||||
else()
|
||||
add_executable(AuthServer "AuthServer.cpp")
|
||||
endif()
|
||||
add_executable(AuthServer "AuthServer.cpp")
|
||||
|
||||
target_link_libraries(AuthServer ${COMMON_LIBRARIES} dServer)
|
||||
|
||||
|
||||
@@ -4,13 +4,7 @@ set(DCHATSERVER_SOURCES
|
||||
"PlayerContainer.cpp"
|
||||
)
|
||||
|
||||
|
||||
if (WIN32 AND LOCAL_SERVER)
|
||||
add_library(ChatServer SHARED "ChatServer.cpp")
|
||||
else()
|
||||
add_executable(ChatServer "ChatServer.cpp")
|
||||
endif()
|
||||
|
||||
add_executable(ChatServer "ChatServer.cpp")
|
||||
target_include_directories(ChatServer PRIVATE "${PROJECT_SOURCE_DIR}/dChatFilter")
|
||||
add_compile_definitions(ChatServer PRIVATE PROJECT_VERSION="\"${PROJECT_VERSION}\"")
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Game {
|
||||
|
||||
void HandlePacket(Packet* packet);
|
||||
|
||||
int start(int argc, char** argv) {
|
||||
int main(int argc, char** argv) {
|
||||
constexpr uint32_t chatFramerate = mediumFramerate;
|
||||
constexpr uint32_t chatFrameDelta = mediumFrameDelta;
|
||||
Diagnostics::SetProcessName("Chat");
|
||||
@@ -178,43 +178,6 @@ int start(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) {
|
||||
|
||||
@@ -2,16 +2,25 @@
|
||||
#include <string>
|
||||
|
||||
//For reading null-terminated strings
|
||||
std::string BinaryIO::ReadString(std::istream& instream) {
|
||||
std::string toReturn;
|
||||
char buffer;
|
||||
template<typename StringType>
|
||||
StringType ReadString(std::istream& instream) {
|
||||
StringType toReturn{};
|
||||
typename StringType::value_type buffer{};
|
||||
|
||||
BinaryIO::BinaryRead(instream, buffer);
|
||||
|
||||
while (buffer != 0x00) {
|
||||
toReturn += buffer;
|
||||
BinaryRead(instream, buffer);
|
||||
BinaryIO::BinaryRead(instream, buffer);
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
std::string BinaryIO::ReadString(std::istream& instream) {
|
||||
return ::ReadString<std::string>(instream);
|
||||
}
|
||||
|
||||
std::u8string BinaryIO::ReadU8String(std::istream& instream) {
|
||||
return ::ReadString<std::u8string>(instream);
|
||||
}
|
||||
|
||||
@@ -65,6 +65,8 @@ namespace BinaryIO {
|
||||
|
||||
std::string ReadString(std::istream& instream);
|
||||
|
||||
std::u8string ReadU8String(std::istream& instream);
|
||||
|
||||
inline bool DoesFileExist(const std::string& name) {
|
||||
std::ifstream f(name.c_str());
|
||||
return f.good();
|
||||
|
||||
@@ -44,15 +44,11 @@ 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/zlib-ng/zlib-ng/archive/refs/tags/2.2.2.zip
|
||||
URL_HASH MD5=2cf9199fb785ea579a2a9905a75c38b3
|
||||
URL https://github.com/madler/zlib/archive/refs/tags/v1.2.11.zip
|
||||
URL_HASH MD5=9d6a627693163bbbf3f26403a3a0b0b1
|
||||
)
|
||||
|
||||
# Disable warning about no project version.
|
||||
@@ -63,6 +59,7 @@ 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(
|
||||
|
||||
@@ -65,13 +65,14 @@ int64_t FdbToSqlite::Convert::ReadInt64(std::istream& cdClientBuffer) {
|
||||
return value;
|
||||
}
|
||||
|
||||
// cdclient is encoded in latin1
|
||||
std::string FdbToSqlite::Convert::ReadString(std::istream& cdClientBuffer) {
|
||||
int32_t prevPosition = SeekPointer(cdClientBuffer);
|
||||
|
||||
auto readString = BinaryIO::ReadString(cdClientBuffer);
|
||||
const auto readString = BinaryIO::ReadU8String(cdClientBuffer);
|
||||
|
||||
cdClientBuffer.seekg(prevPosition);
|
||||
return readString;
|
||||
return GeneralUtils::Latin1ToWTF8(readString);
|
||||
}
|
||||
|
||||
int32_t FdbToSqlite::Convert::SeekPointer(std::istream& cdClientBuffer) {
|
||||
|
||||
@@ -167,17 +167,19 @@ std::u16string GeneralUtils::ASCIIToUTF16(const std::string_view string, const s
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! Converts a (potentially-ill-formed) UTF-16 string to UTF-8
|
||||
|
||||
//! Converts a (potentially-ill-formed) Latin1 string to UTF-8
|
||||
//! See: <http://simonsapin.github.io/wtf-8/#decoding-ill-formed-utf-16>
|
||||
std::string GeneralUtils::UTF16ToWTF8(const std::u16string_view string, const size_t size) {
|
||||
template<typename StringType>
|
||||
std::string ToWTF8(const StringType string, const size_t size) {
|
||||
const size_t newSize = MinSize(size, string);
|
||||
std::string ret;
|
||||
ret.reserve(newSize);
|
||||
|
||||
for (size_t i = 0; i < newSize; ++i) {
|
||||
const char16_t u = string[i];
|
||||
const auto u = string[i];
|
||||
if (IsLeadSurrogate(u) && (i + 1) < newSize) {
|
||||
const char16_t next = string[i + 1];
|
||||
const auto next = string[i + 1];
|
||||
if (IsTrailSurrogate(next)) {
|
||||
i += 1;
|
||||
const char32_t cp = 0x10000
|
||||
@@ -194,6 +196,13 @@ std::string GeneralUtils::UTF16ToWTF8(const std::u16string_view string, const si
|
||||
|
||||
return ret;
|
||||
}
|
||||
std::string GeneralUtils::Latin1ToWTF8(const std::u8string_view string, const size_t size) {
|
||||
return ToWTF8(string, size);
|
||||
}
|
||||
|
||||
std::string GeneralUtils::UTF16ToWTF8(const std::u16string_view string, const size_t size) {
|
||||
return ToWTF8(string, size);
|
||||
}
|
||||
|
||||
bool GeneralUtils::CaseInsensitiveStringCompare(const std::string_view a, const std::string_view b) {
|
||||
return std::equal(a.begin(), a.end(), b.begin(), b.end(), [](char a, char b) { return tolower(a) == tolower(b); });
|
||||
|
||||
@@ -51,6 +51,14 @@ namespace GeneralUtils {
|
||||
bool _NextUTF8Char(std::string_view& slice, uint32_t& out);
|
||||
}
|
||||
|
||||
//! Converts a Latin1 string to a UTF-8 string
|
||||
/*!
|
||||
\param string The string to convert
|
||||
\param size A size to trim the string to. Default is SIZE_MAX (No trimming)
|
||||
\return An UTF-8 representation of the string
|
||||
*/
|
||||
std::string Latin1ToWTF8(const std::u8string_view string, const size_t size = SIZE_MAX);
|
||||
|
||||
//! Converts a UTF-16 string to a UTF-8 string
|
||||
/*!
|
||||
\param string The string to convert
|
||||
|
||||
@@ -9,7 +9,6 @@ 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,6 +4,8 @@
|
||||
#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.");
|
||||
@@ -80,7 +82,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<uint8_t*>(const_cast<char*>("\0\0\0\0")), 4);
|
||||
crc = crc32b(crc, reinterpret_cast<Bytef*>(const_cast<char*>("\0\0\0\0")), 4);
|
||||
|
||||
for (const auto& item : this->m_PackIndex->GetPackFileIndices()) {
|
||||
if (item.m_Crc == crc) {
|
||||
@@ -128,7 +130,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<uint8_t*>(const_cast<char*>("\0\0\0\0")), 4);
|
||||
crc = crc32b(crc, reinterpret_cast<Bytef*>(const_cast<char*>("\0\0\0\0")), 4);
|
||||
|
||||
for (const auto& item : this->m_PackIndex->GetPackFileIndices()) {
|
||||
if (item.m_Crc == crc) {
|
||||
|
||||
@@ -1253,6 +1253,7 @@ namespace MessageType {
|
||||
VEHICLE_NOTIFY_HIT_EXPLODER = 1385,
|
||||
CHECK_NEAREST_ROCKET_LAUNCH_PRE_CONDITIONS = 1386,
|
||||
REQUEST_NEAREST_ROCKET_LAUNCH_PRE_CONDITIONS = 1387,
|
||||
CONFIGURE_RACING_CONTROL = 1388,
|
||||
CONFIGURE_RACING_CONTROL_CLIENT = 1389,
|
||||
NOTIFY_RACING_CLIENT = 1390,
|
||||
RACING_PLAYER_HACK_CAR = 1391,
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#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
|
||||
|
||||
@@ -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_cpp_connector> ${CMAKE_BINARY_DIR})
|
||||
${CMAKE_COMMAND} -E copy $<TARGET_FILE:MariaDB::ConnCpp> ${PROJECT_BINARY_DIR})
|
||||
|
||||
add_dependencies(dDatabase conncpp_dylib)
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ target_include_directories(dDatabaseGame PUBLIC "."
|
||||
)
|
||||
|
||||
target_link_libraries(dDatabaseGame
|
||||
PUBLIC mariadb_cpp_connector
|
||||
INTERFACE dCommon)
|
||||
INTERFACE dCommon
|
||||
PRIVATE sqlite3 MariaDB::ConnCpp)
|
||||
|
||||
# Glob together all headers that need to be precompiled
|
||||
file(
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "dConfig.h"
|
||||
#include "Logger.h"
|
||||
#include "dPlatforms.h"
|
||||
#include "BinaryPathFinder.h"
|
||||
|
||||
// Static Variables
|
||||
|
||||
@@ -17,7 +18,14 @@ namespace {
|
||||
void SQLiteDatabase::Connect() {
|
||||
LOG("Using SQLite database");
|
||||
con = new CppSQLite3DB();
|
||||
con->open(Game::config->GetValue("sqlite_database_path").c_str());
|
||||
const auto path = BinaryPathFinder::GetBinaryDir() / Game::config->GetValue("sqlite_database_path");
|
||||
|
||||
if (!std::filesystem::exists(path)) {
|
||||
LOG("Creating sqlite path %s", path.string().c_str());
|
||||
std::filesystem::create_directories(path.parent_path());
|
||||
}
|
||||
|
||||
con->open(path.string().c_str());
|
||||
isConnected = true;
|
||||
|
||||
// Make sure wal is enabled for the database.
|
||||
|
||||
@@ -1378,7 +1378,7 @@ void Entity::OnCollisionPhantom(const LWOOBJID otherEntity) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!other->GetIsDead()) {
|
||||
if (!other->GetComponent<DestroyableComponent>()->GetIsDead()) {
|
||||
if (GetComponent<BaseCombatAIComponent>() != nullptr) {
|
||||
const auto index = std::find(m_TargetsInPhantom.begin(), m_TargetsInPhantom.end(), otherEntity);
|
||||
|
||||
@@ -1606,13 +1606,6 @@ void Entity::AddQuickBuildCompleteCallback(const std::function<void(Entity* user
|
||||
}
|
||||
}
|
||||
|
||||
bool Entity::GetIsDead() const {
|
||||
DestroyableComponent* dest = GetComponent<DestroyableComponent>();
|
||||
if (dest && dest->GetArmor() == 0 && dest->GetHealth() == 0) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Entity::AddLootItem(const Loot::Info& info) {
|
||||
if (!IsPlayer()) return;
|
||||
|
||||
|
||||
@@ -82,8 +82,6 @@ public:
|
||||
|
||||
const std::vector<LDFBaseData*>& GetNetworkSettings() const { return m_NetworkSettings; }
|
||||
|
||||
bool GetIsDead() const;
|
||||
|
||||
bool GetPlayerReadyForUpdates() const { return m_PlayerIsReadyForUpdates; }
|
||||
|
||||
bool GetIsGhostingCandidate() const;
|
||||
|
||||
@@ -227,7 +227,7 @@ void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet
|
||||
|
||||
bitStream.Write(armorDamageDealt);
|
||||
bitStream.Write(healthDamageDealt);
|
||||
bitStream.Write(targetEntity->GetIsDead());
|
||||
bitStream.Write(targetEntity->GetComponent<DestroyableComponent>()->GetIsDead());
|
||||
}
|
||||
|
||||
bitStream.Write(successState);
|
||||
|
||||
@@ -116,7 +116,7 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitS
|
||||
for (auto validTarget : validTargets) {
|
||||
if (targets.size() >= this->m_maxTargets) break;
|
||||
if (std::find(targets.begin(), targets.end(), validTarget) != targets.end()) continue;
|
||||
if (validTarget->GetIsDead()) continue;
|
||||
if (validTarget->GetComponent<DestroyableComponent>()->GetIsDead()) continue;
|
||||
|
||||
const auto targetPos = validTarget->GetPosition();
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ void BaseCombatAIComponent::Update(const float deltaTime) {
|
||||
m_SoftTimer -= deltaTime;
|
||||
}
|
||||
|
||||
if (m_Disabled || m_Parent->GetIsDead())
|
||||
if (m_Disabled || m_Parent->GetComponent<DestroyableComponent>()->GetIsDead())
|
||||
return;
|
||||
bool stunnedThisFrame = m_Stunned;
|
||||
CalculateCombat(deltaTime); // Putting this here for now
|
||||
|
||||
@@ -35,7 +35,8 @@
|
||||
RacingControlComponent::RacingControlComponent(Entity* parent)
|
||||
: Component(parent) {
|
||||
m_PathName = u"MainPath";
|
||||
m_RemainingLaps = 3;
|
||||
m_NumberOfLaps = 3;
|
||||
m_RemainingLaps = m_NumberOfLaps;
|
||||
m_LeadingPlayer = LWOOBJID_EMPTY;
|
||||
m_RaceBestTime = 0;
|
||||
m_RaceBestLap = 0;
|
||||
@@ -658,23 +659,9 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
}
|
||||
}
|
||||
|
||||
// Spawn imagination pickups
|
||||
auto* minSpawner = Game::zoneManager->GetSpawnersByName(
|
||||
"ImaginationSpawn_Min")[0];
|
||||
auto* medSpawner = Game::zoneManager->GetSpawnersByName(
|
||||
"ImaginationSpawn_Med")[0];
|
||||
auto* maxSpawner = Game::zoneManager->GetSpawnersByName(
|
||||
"ImaginationSpawn_Max")[0];
|
||||
|
||||
minSpawner->Activate();
|
||||
|
||||
if (m_LoadedPlayers > 2) {
|
||||
medSpawner->Activate();
|
||||
}
|
||||
|
||||
if (m_LoadedPlayers > 4) {
|
||||
maxSpawner->Activate();
|
||||
}
|
||||
GameMessages::ZoneLoadedInfo zoneLoadInfo{};
|
||||
zoneLoadInfo.maxPlayers = m_LoadedPlayers;
|
||||
m_Parent->GetScript()->OnZoneLoadedInfo(m_Parent, zoneLoadInfo);
|
||||
|
||||
// Reset players to their start location, without smashing them
|
||||
for (auto& player : m_RacingPlayers) {
|
||||
@@ -764,7 +751,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
// new checkpoint
|
||||
uint32_t respawnIndex = 0;
|
||||
for (const auto& waypoint : path->pathWaypoints) {
|
||||
if (player.lap == 3) {
|
||||
if (player.lap == m_NumberOfLaps) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -835,7 +822,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
// Progress lap time tasks
|
||||
missionComponent->Progress(eMissionTaskType::RACING, lapTime.count(), static_cast<LWOOBJID>(eRacingTaskParam::LAP_TIME));
|
||||
|
||||
if (player.lap == 3) {
|
||||
if (player.lap == m_NumberOfLaps) {
|
||||
m_Finished++;
|
||||
player.finished = m_Finished;
|
||||
|
||||
@@ -882,3 +869,20 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RacingControlComponent::MsgConfigureRacingControl(const GameMessages::ConfigureRacingControl& msg) {
|
||||
for (const auto& dataUnique : msg.racingSettings) {
|
||||
if (!dataUnique) continue;
|
||||
const auto* const data = dataUnique.get();
|
||||
if (data->GetKey() == u"Race_PathName" && data->GetValueType() == LDF_TYPE_UTF_16) {
|
||||
m_PathName = static_cast<const LDFData<std::u16string>*>(data)->GetValue();
|
||||
} else if (data->GetKey() == u"activityID" && data->GetValueType() == LDF_TYPE_S32) {
|
||||
m_ActivityID = static_cast<const LDFData<int32_t>*>(data)->GetValue();
|
||||
} else if (data->GetKey() == u"Number_of_Laps" && data->GetValueType() == LDF_TYPE_S32) {
|
||||
m_NumberOfLaps = static_cast<const LDFData<int32_t>*>(data)->GetValue();
|
||||
m_RemainingLaps = m_NumberOfLaps;
|
||||
} else if (data->GetKey() == u"Minimum_Players_for_Group_Achievements" && data->GetValueType() == LDF_TYPE_S32) {
|
||||
m_MinimumPlayersForGroupAchievements = static_cast<const LDFData<int32_t>*>(data)->GetValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,6 +152,8 @@ public:
|
||||
*/
|
||||
RacingPlayerInfo* GetPlayerData(LWOOBJID playerID);
|
||||
|
||||
void MsgConfigureRacingControl(const GameMessages::ConfigureRacingControl& msg);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@@ -161,11 +163,13 @@ private:
|
||||
|
||||
/**
|
||||
* The paths that are followed for the camera scenes
|
||||
* Configurable in the ConfigureRacingControl msg with the key `Race_PathName`.
|
||||
*/
|
||||
std::u16string m_PathName;
|
||||
|
||||
/**
|
||||
* The ID of the activity for participating in this race
|
||||
* Configurable in the ConfigureRacingControl msg with the key `activityID`.
|
||||
*/
|
||||
uint32_t m_ActivityID;
|
||||
|
||||
@@ -245,5 +249,20 @@ private:
|
||||
* Value for message box response to know if we are exiting the race via the activity dialogue
|
||||
*/
|
||||
const int32_t m_ActivityExitConfirm = 1;
|
||||
|
||||
bool m_AllPlayersReady = false;
|
||||
|
||||
/**
|
||||
* @brief The number of laps in this race. Configurable in the ConfigureRacingControl msg
|
||||
* with the key `Number_of_Laps`.
|
||||
*
|
||||
*/
|
||||
int32_t m_NumberOfLaps{ 3 };
|
||||
|
||||
/**
|
||||
* @brief The minimum number of players required to progress group achievements.
|
||||
* Configurable with the ConfigureRacingControl msg with the key `Minimum_Players_for_Group_Achievements`.
|
||||
*
|
||||
*/
|
||||
int32_t m_MinimumPlayersForGroupAchievements{ 2 };
|
||||
};
|
||||
|
||||
@@ -160,7 +160,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream& inStream, const System
|
||||
}
|
||||
|
||||
//Kill player if health == 0
|
||||
if (entity->GetIsDead()) {
|
||||
if (entity->GetComponent<DestroyableComponent>()->GetIsDead()) {
|
||||
entity->Smash(entity->GetObjectID());
|
||||
}
|
||||
|
||||
|
||||
@@ -717,6 +717,16 @@ namespace GameMessages {
|
||||
NiPoint3 targetPosition{};
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
struct ZoneLoadedInfo : public GameMsg {
|
||||
ZoneLoadedInfo() : GameMsg(MessageType::Game::ZONE_LOADED_INFO) {}
|
||||
int32_t maxPlayers{};
|
||||
};
|
||||
|
||||
struct ConfigureRacingControl : public GameMsg {
|
||||
ConfigureRacingControl() : GameMsg(MessageType::Game::CONFIGURE_RACING_CONTROL) {}
|
||||
std::vector<std::unique_ptr<LDFBaseData>> racingSettings{};
|
||||
};
|
||||
};
|
||||
|
||||
#endif // GAMEMESSAGES_H
|
||||
|
||||
@@ -8,8 +8,6 @@ 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) ? 1 : 0) < count;
|
||||
return inventoryComponent->IsEquipped(value) && count > 0;
|
||||
case PreconditionType::HasAchievement:
|
||||
if (missionComponent == nullptr) return false;
|
||||
return missionComponent->GetMissionState(value) >= eMissionState::COMPLETE;
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
set(DLOCAL_SERVER_SOURCES
|
||||
"dllmain.cpp"
|
||||
)
|
||||
|
||||
add_library(dLocalServer OBJECT ${DLOCAL_SERVER_SOURCES})
|
||||
|
||||
target_link_libraries(dLocalServer)
|
||||
@@ -1,32 +0,0 @@
|
||||
#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.
|
||||
}
|
||||
@@ -1,23 +1,11 @@
|
||||
set(DMASTERSERVER_SOURCES
|
||||
"InstanceManager.cpp"
|
||||
"PersistentIDManager.cpp"
|
||||
"StartLocal.cpp"
|
||||
"Start.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})
|
||||
|
||||
if (WIN32 AND LOCAL_SERVER)
|
||||
add_library(MasterServer SHARED "MasterServer.cpp")
|
||||
else()
|
||||
add_executable(MasterServer "MasterServer.cpp")
|
||||
endif()
|
||||
|
||||
add_executable(MasterServer "MasterServer.cpp")
|
||||
target_compile_definitions(MasterServer PRIVATE PROJECT_VERSION="\"${PROJECT_VERSION}\"")
|
||||
target_include_directories(dMasterServer PUBLIC "."
|
||||
"${PROJECT_SOURCE_DIR}/dZoneManager" # InstanceManager.h uses dZMCommon.h
|
||||
|
||||
@@ -62,7 +62,7 @@ std::map<uint32_t, std::string> activeSessions;
|
||||
SystemAddress authServerMasterPeerSysAddr;
|
||||
SystemAddress chatServerMasterPeerSysAddr;
|
||||
|
||||
int start(int argc, char** argv) {
|
||||
int main(int argc, char** argv) {
|
||||
constexpr uint32_t masterFramerate = mediumFramerate;
|
||||
constexpr uint32_t masterFrameDelta = mediumFrameDelta;
|
||||
Diagnostics::SetProcessName("Master");
|
||||
@@ -84,6 +84,24 @@ int start(int argc, char** argv) {
|
||||
Server::SetupLogger("MasterServer");
|
||||
if (!Game::logger) return EXIT_FAILURE;
|
||||
|
||||
auto folders = { "navmeshes", "migrations", "vanity" };
|
||||
|
||||
for (const auto folder : folders) {
|
||||
if (!std::filesystem::exists(BinaryPathFinder::GetBinaryDir() / folder)) {
|
||||
std::string msg = "The (" +
|
||||
std::string(folder) +
|
||||
") folder was not copied to the binary directory. Please copy the (" +
|
||||
std::string(folder) +
|
||||
") folder from your download to the binary directory or re-run cmake.";
|
||||
LOG("%s", msg.c_str());
|
||||
// toss an error box up for windows users running the download
|
||||
#ifdef DARKFLAME_PLATFORM_WIN32
|
||||
MessageBoxA(nullptr, msg.c_str(), "Missing Folder", MB_OK | MB_ICONERROR);
|
||||
#endif
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dConfig::Exists("authconfig.ini")) LOG("Could not find authconfig.ini, using default settings");
|
||||
if (!dConfig::Exists("chatconfig.ini")) LOG("Could not find chatconfig.ini, using default settings");
|
||||
if (!dConfig::Exists("masterconfig.ini")) LOG("Could not find masterconfig.ini, using default settings");
|
||||
@@ -177,7 +195,7 @@ int start(int argc, char** argv) {
|
||||
}
|
||||
|
||||
// Run migrations should any need to be run.
|
||||
MigrationRunner::RunSQLiteMigrations();
|
||||
MigrationRunner::RunSQLiteMigrations();
|
||||
|
||||
//If the first command line argument is -a or --account then make the user
|
||||
//input a username and password, with the password being hidden.
|
||||
@@ -429,44 +447,6 @@ int start(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) {
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
#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));
|
||||
}
|
||||
@@ -16,7 +16,7 @@ void BaseEnemyApe::OnStartup(Entity* self) {
|
||||
|
||||
void BaseEnemyApe::OnDie(Entity* self, Entity* killer) {
|
||||
auto* anchor = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"QB"));
|
||||
if (anchor != nullptr && !anchor->GetIsDead()) {
|
||||
if (anchor != nullptr && !anchor->GetComponent<DestroyableComponent>()->GetIsDead()) {
|
||||
anchor->Smash(self->GetObjectID(), eKillType::SILENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,13 +152,13 @@ void AmSkullkinDrill::FreezePlayer(Entity* self, Entity* player, bool bFreeze) {
|
||||
auto StateChangeType = eStateChangeType::POP;
|
||||
|
||||
if (bFreeze) {
|
||||
if (player->GetIsDead()) {
|
||||
if (player->GetComponent<DestroyableComponent>()->GetIsDead()) {
|
||||
return;
|
||||
}
|
||||
|
||||
StateChangeType = eStateChangeType::PUSH;
|
||||
} else {
|
||||
if (player->GetIsDead()) {
|
||||
if (player->GetComponent<DestroyableComponent>()->GetIsDead()) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,13 +65,13 @@ void RandomSpawnerFin::OnStartup(Entity* self) {
|
||||
};
|
||||
|
||||
sectionMultipliers = {
|
||||
{"secA", 1.0f},
|
||||
{"secB", 1.0f},
|
||||
{"secA", 1},
|
||||
{"secB", 1},
|
||||
{"secC", 1.2f},
|
||||
{"secD", 1.3f},
|
||||
{"secE", 1.6f},
|
||||
{"secF", 1.0f},
|
||||
{"secG", 1.0f},
|
||||
{"secF", 1},
|
||||
{"secG", 1},
|
||||
{"secH", 1.2f},
|
||||
};
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ void RandomSpawnerPit::OnStartup(Entity* self) {
|
||||
};
|
||||
|
||||
sectionMultipliers = {
|
||||
{"secA", 1.0f},
|
||||
{"secA", 1},
|
||||
{"secB", 1.2f},
|
||||
{"secC", 1.2f},
|
||||
{"secD", 1},
|
||||
|
||||
@@ -65,8 +65,8 @@ void RandomSpawnerStr::OnStartup(Entity* self) {
|
||||
};
|
||||
|
||||
sectionMultipliers = {
|
||||
{"secA", 1.0f},
|
||||
{"secB", 1.0f},
|
||||
{"secA", 1},
|
||||
{"secB", 1},
|
||||
{"secC", 1.2f},
|
||||
};
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ void AgSurvivalBuffStation::OnTimerDone(Entity* self, std::string timerName) {
|
||||
auto team = self->GetVar<std::vector<LWOOBJID>>(u"BuilderTeam");
|
||||
for (auto memberID : team) {
|
||||
auto member = Game::entityManager->GetEntity(memberID);
|
||||
if (member != nullptr && !member->GetIsDead()) {
|
||||
if (member != nullptr && !member->GetComponent<DestroyableComponent>()->GetIsDead()) {
|
||||
GameMessages::SendDropClientLoot(member, self->GetObjectID(), powerupToDrop, 0, self->GetPosition());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ bool BaseSurvivalServer::CheckAllPlayersDead() {
|
||||
|
||||
for (const auto& playerID : state.players) {
|
||||
auto* player = Game::entityManager->GetEntity(playerID);
|
||||
if (player == nullptr || player->GetIsDead()) {
|
||||
if (player == nullptr || player->GetComponent<DestroyableComponent>()->GetIsDead()) {
|
||||
deadPlayers++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ bool BaseWavesServer::CheckAllPlayersDead() {
|
||||
|
||||
for (const auto& playerID : state.players) {
|
||||
auto* player = Game::entityManager->GetEntity(playerID);
|
||||
if (player == nullptr || player->GetIsDead()) {
|
||||
if (player == nullptr || player->GetComponent<DestroyableComponent>()->GetIsDead()) {
|
||||
deadPlayers++;
|
||||
}
|
||||
}
|
||||
@@ -431,7 +431,7 @@ void BaseWavesServer::SpawnWave(Entity* self) {
|
||||
|
||||
for (const auto& playerID : state.players) {
|
||||
auto* player = Game::entityManager->GetEntity(playerID);
|
||||
if (player && player->GetIsDead()) {
|
||||
if (player && player->GetComponent<DestroyableComponent>()->GetIsDead()) {
|
||||
player->Resurrect();
|
||||
}
|
||||
}
|
||||
@@ -501,7 +501,7 @@ bool BaseWavesServer::UpdateSpawnedEnemies(Entity* self, LWOOBJID enemyID, uint3
|
||||
|
||||
for (const auto& playerID : state.players) {
|
||||
auto* player = Game::entityManager->GetEntity(playerID);
|
||||
if (player != nullptr && !player->GetIsDead()) {
|
||||
if (player != nullptr && !player->GetComponent<DestroyableComponent>()->GetIsDead()) {
|
||||
SetActivityValue(self, playerID, 1, currentTime);
|
||||
SetActivityValue(self, playerID, 2, state.waveNumber);
|
||||
|
||||
|
||||
@@ -330,6 +330,7 @@
|
||||
#include "EnemyClearThreat.h"
|
||||
#include "AgSpiderBossMessage.h"
|
||||
#include "GfRaceInstancer.h"
|
||||
#include "NsRaceServer.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
@@ -692,6 +693,7 @@ namespace {
|
||||
{"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();}},
|
||||
{"scripts\\ai\\GF\\L_GF_RACE_INSTANCER.lua", []() {return new GfRaceInstancer();}},
|
||||
{"scripts\\ai\\RACING\\TRACK_NS\\NS_RACE_SERVER.lua", []() {return new NsRaceServer();}},
|
||||
|
||||
};
|
||||
|
||||
@@ -704,9 +706,12 @@ namespace {
|
||||
"scripts\\empty.lua",
|
||||
"scripts\\zone\\AG\\L_ZONE_AG.lua",
|
||||
"scripts\\zone\\NS\\L_ZONE_NS.lua",
|
||||
"scripts\\zone\\GF\\L_ZONE_GF.lua",
|
||||
"scripts\\ai\\GF\\L_ZONE_GF.lua",
|
||||
"scripts\\ai\\AG\\CONCERT_STAGE.lua",
|
||||
"scripts\\ai\\NS\\L_NS_CAR_MODULAR_BUILD.lua", // In our implementation, this is done in GameMessages.cpp
|
||||
"scripts\\ai\\PETS\\PET_BLOCKER.lua",
|
||||
"scripts\\ai\\PETS\\PET_FLEA_MISSION.lua",
|
||||
"scripts\\ai\\ACT\\L_ACT_PET_INSTANCE_EXIT.lua",
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -355,6 +355,8 @@ namespace CppScripts {
|
||||
* @param canceled if it was done via the cancel button
|
||||
*/
|
||||
virtual void OnRequestActivityExit(Entity* sender, LWOOBJID player, bool canceled) {};
|
||||
|
||||
virtual void OnZoneLoadedInfo(Entity* self, const GameMessages::ZoneLoadedInfo& info) {};
|
||||
};
|
||||
|
||||
Script* const GetScript(Entity* parent, const std::string& scriptName);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "ActPlayerDeathTrigger.h"
|
||||
|
||||
#include "DestroyableComponent.h"
|
||||
#include "Entity.h"
|
||||
|
||||
void ActPlayerDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) {
|
||||
if (!target->IsPlayer() || target->GetIsDead() || !target->GetPlayerReadyForUpdates()) return; //Don't kill already dead players or players not ready
|
||||
if (!target->IsPlayer() || target->GetComponent<DestroyableComponent>()->GetIsDead() || !target->GetPlayerReadyForUpdates()) return; //Don't kill already dead players or players not ready
|
||||
|
||||
target->Smash(self->GetObjectID(), eKillType::SILENT);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "ActSharkPlayerDeathTrigger.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "MissionComponent.h"
|
||||
#include "eMissionTaskType.h"
|
||||
#include "Entity.h"
|
||||
@@ -11,7 +12,7 @@ void ActSharkPlayerDeathTrigger::OnFireEventServerSide(Entity* self, Entity* sen
|
||||
|
||||
missionComponent->Progress(eMissionTaskType::SCRIPT, 8419);
|
||||
|
||||
if (sender->GetIsDead() || !sender->GetPlayerReadyForUpdates()) return; //Don't kill already dead players or players not ready
|
||||
if (sender->GetComponent<DestroyableComponent>()->GetIsDead() || !sender->GetPlayerReadyForUpdates()) return; //Don't kill already dead players or players not ready
|
||||
|
||||
if (sender->GetCharacter()) {
|
||||
sender->Smash(self->GetObjectID(), eKillType::VIOLENT, u"big-shark-death");
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#include "AgShipPlayerDeathTrigger.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "Entity.h"
|
||||
|
||||
void AgShipPlayerDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) {
|
||||
if (target->GetLOT() == 1 && !target->GetIsDead()) {
|
||||
if (target->GetLOT() == 1 && !target->GetComponent<DestroyableComponent>()->GetIsDead()) {
|
||||
target->Smash(self->GetObjectID(), eKillType::VIOLENT, u"electro-shock-death");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "TriggerGas.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "SkillComponent.h"
|
||||
#include "Entity.h"
|
||||
@@ -28,7 +29,7 @@ void TriggerGas::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName != this->m_TimerName) return;
|
||||
auto players = self->GetVar<std::vector<Entity*>>(u"players");
|
||||
for (auto player : players) {
|
||||
if (player->GetIsDead() || !player){
|
||||
if (player->GetComponent<DestroyableComponent>()->GetIsDead() || !player){
|
||||
auto position = std::find(players.begin(), players.end(), player);
|
||||
if (position != players.end()) players.erase(position);
|
||||
continue;
|
||||
@@ -46,4 +47,3 @@ void TriggerGas::OnTimerDone(Entity* self, std::string timerName) {
|
||||
self->SetVar(u"players", players);
|
||||
self->AddTimer(this->m_TimerName, this->m_Time);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "PetDigBuild.h"
|
||||
#include "EntityManager.h"
|
||||
#include "EntityInfo.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "MissionComponent.h"
|
||||
#include "eMissionState.h"
|
||||
|
||||
@@ -45,7 +46,7 @@ void PetDigBuild::OnDie(Entity* self, Entity* killer) {
|
||||
return;
|
||||
|
||||
// If the quick build expired and the treasure was not collected, hide the treasure
|
||||
if (!treasure->GetIsDead()) {
|
||||
if (!treasure->GetComponent<DestroyableComponent>()->GetIsDead()) {
|
||||
treasure->Smash(self->GetObjectID(), eKillType::SILENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ void NsConcertInstrument::OnQuickBuildNotifyState(Entity* self, eQuickBuildState
|
||||
}
|
||||
|
||||
void NsConcertInstrument::OnQuickBuildComplete(Entity* self, Entity* target) {
|
||||
if (!target->GetIsDead()) {
|
||||
if (!target->GetComponent<DestroyableComponent>()->GetIsDead()) {
|
||||
self->SetVar<LWOOBJID>(u"activePlayer", target->GetObjectID());
|
||||
|
||||
self->AddCallbackTimer(0.2f, [self, target]() {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
set(DSCRIPTS_SOURCES_AI_RACING)
|
||||
set(DSCRIPTS_SOURCES_AI_RACING
|
||||
"RaceImaginationServer.cpp")
|
||||
|
||||
add_subdirectory(OBJECTS)
|
||||
|
||||
@@ -6,6 +7,12 @@ foreach(file ${DSCRIPTS_SOURCES_AI_RACING_OBJECTS})
|
||||
set(DSCRIPTS_SOURCES_AI_RACING ${DSCRIPTS_SOURCES_AI_RACING} "OBJECTS/${file}")
|
||||
endforeach()
|
||||
|
||||
add_subdirectory(TRACK_NS)
|
||||
|
||||
foreach(file ${DSCRIPTS_SOURCES_AI_RACING_TRACK_NS})
|
||||
set(DSCRIPTS_SOURCES_AI_RACING ${DSCRIPTS_SOURCES_AI_RACING} "TRACK_NS/${file}")
|
||||
endforeach()
|
||||
|
||||
add_library(dScriptsAiRacing OBJECT ${DSCRIPTS_SOURCES_AI_RACING})
|
||||
target_include_directories(dScriptsAiRacing PUBLIC "." "OBJECTS")
|
||||
target_include_directories(dScriptsAiRacing PUBLIC "." "OBJECTS" "TRACK_NS")
|
||||
target_precompile_headers(dScriptsAiRacing REUSE_FROM dScriptsBase)
|
||||
|
||||
19
dScripts/ai/RACING/RaceImaginationServer.cpp
Normal file
19
dScripts/ai/RACING/RaceImaginationServer.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "RaceImaginationServer.h"
|
||||
#include "dZoneManager.h"
|
||||
|
||||
void StartSpawner(const std::vector<Spawner*>& spawner) {
|
||||
for (auto* const entity : spawner) {
|
||||
entity->Activate();
|
||||
}
|
||||
}
|
||||
|
||||
void RaceImaginationServer::OnZoneLoadedInfo(Entity* self, const GameMessages::ZoneLoadedInfo& info) {
|
||||
// Spawn imagination pickups
|
||||
StartSpawner(Game::zoneManager->GetSpawnersByName("ImaginationSpawn_Min"));
|
||||
if (info.maxPlayers > 2) {
|
||||
StartSpawner(Game::zoneManager->GetSpawnersByName("ImaginationSpawn_Med"));
|
||||
}
|
||||
if (info.maxPlayers > 4) {
|
||||
StartSpawner(Game::zoneManager->GetSpawnersByName("ImaginationSpawn_Max"));
|
||||
}
|
||||
}
|
||||
11
dScripts/ai/RACING/RaceImaginationServer.h
Normal file
11
dScripts/ai/RACING/RaceImaginationServer.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef RACEIMAGINATIONSERVER_H
|
||||
#define RACEIMAGINATIONSERVER_H
|
||||
|
||||
#include "CppScripts.h"
|
||||
|
||||
class RaceImaginationServer : public virtual CppScripts::Script {
|
||||
public:
|
||||
void OnZoneLoadedInfo(Entity* self, const GameMessages::ZoneLoadedInfo& info) override;
|
||||
};
|
||||
|
||||
#endif //!RACEIMAGINATIONSERVER_H
|
||||
3
dScripts/ai/RACING/TRACK_NS/CMakeLists.txt
Normal file
3
dScripts/ai/RACING/TRACK_NS/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
set(DSCRIPTS_SOURCES_AI_RACING_TRACK_NS
|
||||
"NsRaceServer.cpp"
|
||||
PARENT_SCOPE)
|
||||
54
dScripts/ai/RACING/TRACK_NS/NsRaceServer.cpp
Normal file
54
dScripts/ai/RACING/TRACK_NS/NsRaceServer.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#include "NsRaceServer.h"
|
||||
|
||||
#include "RacingControlComponent.h"
|
||||
#include "Entity.h"
|
||||
|
||||
using std::unique_ptr;
|
||||
using std::make_unique;
|
||||
|
||||
void NsRaceServer::OnStartup(Entity* self) {
|
||||
GameMessages::ConfigureRacingControl config;
|
||||
auto& raceSet = config.racingSettings;
|
||||
|
||||
raceSet.push_back(make_unique<LDFData<std::u16string>>(u"GameType", u"Racing"));
|
||||
raceSet.push_back(make_unique<LDFData<std::u16string>>(u"GameState", u"Starting"));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Number_Of_PlayersPerTeam", 6));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Minimum_Players_to_Start", 2));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Minimum_Players_for_Group_Achievements", 2));
|
||||
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Car_Object", 7703));
|
||||
raceSet.push_back(make_unique<LDFData<std::u16string>>(u"Race_PathName", u"MainPath"));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Current_Lap", 1));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Number_of_Laps", 3));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"activityID", 42));
|
||||
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Place_1", 100));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Place_2", 90));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Place_3", 80));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Place_4", 70));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Place_5", 60));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Place_6", 50));
|
||||
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Num_of_Players_1", 15));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Num_of_Players_2", 25));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Num_of_Players_3", 50));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Num_of_Players_4", 85));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Num_of_Players_5", 90));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Num_of_Players_6", 100));
|
||||
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Number_of_Spawn_Groups", 1));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Red_Spawners", 4847));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Blue_Spawners", 4848));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Blue_Flag", 4850));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Red_Flag", 4851));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Red_Point", 4846));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Blue_Point", 4845));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Red_Mark", 4844));
|
||||
raceSet.push_back(make_unique<LDFData<int32_t>>(u"Blue_Mark", 4843));
|
||||
|
||||
std::vector<Entity*> racingControllers = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::RACING_CONTROL);
|
||||
for (auto* const racingController : racingControllers) {
|
||||
auto* racingComponent = racingController->GetComponent<RacingControlComponent>();
|
||||
if (racingComponent) racingComponent->MsgConfigureRacingControl(config);
|
||||
}
|
||||
}
|
||||
12
dScripts/ai/RACING/TRACK_NS/NsRaceServer.h
Normal file
12
dScripts/ai/RACING/TRACK_NS/NsRaceServer.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef NSRACESERVER_H
|
||||
#define NSRACESERVER_H
|
||||
|
||||
#include "CppScripts.h"
|
||||
#include "RaceImaginationServer.h"
|
||||
|
||||
class NsRaceServer : public RaceImaginationServer {
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
};
|
||||
|
||||
#endif //!NSRACESERVER_H
|
||||
@@ -5,12 +5,7 @@ set(DWORLDSERVER_SOURCES
|
||||
add_library(dWorldServer OBJECT ${DWORLDSERVER_SOURCES})
|
||||
target_link_libraries(dWorldServer PUBLIC dGameBase dCommon)
|
||||
|
||||
if (WIN32 AND LOCAL_SERVER)
|
||||
add_library(WorldServer SHARED "WorldServer.cpp")
|
||||
else()
|
||||
add_executable(WorldServer "WorldServer.cpp")
|
||||
endif()
|
||||
|
||||
add_executable(WorldServer "WorldServer.cpp")
|
||||
target_include_directories(WorldServer PRIVATE "${PROJECT_SOURCE_DIR}/dChatFilter")
|
||||
add_compile_definitions(WorldServer PRIVATE PROJECT_VERSION="\"${PROJECT_VERSION}\"")
|
||||
|
||||
|
||||
@@ -120,8 +120,7 @@ uint32_t instanceID = 0;
|
||||
uint32_t g_CloneID = 0;
|
||||
std::string databaseChecksum = "";
|
||||
|
||||
|
||||
int start(int argc, char** argv) {
|
||||
int main(int argc, char** argv) {
|
||||
Diagnostics::SetProcessName("World");
|
||||
Diagnostics::SetProcessFileName(argv[0]);
|
||||
Diagnostics::Initialize();
|
||||
@@ -527,50 +526,10 @@ int start(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) {
|
||||
|
||||
@@ -28,7 +28,8 @@ client_location=
|
||||
|
||||
# The maximum outgoing bandwidth in bits. If your clients are having
|
||||
# issues with enemies taking a while to catch up to them, increse this value.
|
||||
maximum_outgoing_bandwidth=80000
|
||||
# Empty or 0 means no limit
|
||||
maximum_outgoing_bandwidth=0
|
||||
|
||||
# The Maximum Translation Unit (MTU) size for packets. If players are
|
||||
# getting stuck at 55% on the loading screen, lower this number to
|
||||
|
||||
@@ -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_cpp_connector> ${CMAKE_CURRENT_BINARY_DIR})
|
||||
${CMAKE_COMMAND} -E copy $<TARGET_FILE:MariaDB::ConnCpp> ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_dependencies(dCommonTests dCommonTestsLink)
|
||||
endif()
|
||||
|
||||
@@ -16,7 +16,7 @@ add_executable(dGameTests ${DGAMETEST_SOURCES})
|
||||
|
||||
if(APPLE)
|
||||
add_custom_target(dGameTestsLink
|
||||
${CMAKE_COMMAND} -E copy $<TARGET_FILE:mariadb_cpp_connector> ${CMAKE_CURRENT_BINARY_DIR})
|
||||
${CMAKE_COMMAND} -E copy $<TARGET_FILE:MariaDB::ConnCpp> ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_dependencies(dGameTests dGameTestsLink)
|
||||
endif()
|
||||
|
||||
4
thirdparty/CMakeLists.txt
vendored
4
thirdparty/CMakeLists.txt
vendored
@@ -31,10 +31,6 @@ 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
2
thirdparty/hijackkit/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
.vs/
|
||||
out/
|
||||
11
thirdparty/hijackkit/CMakeLists.txt
vendored
11
thirdparty/hijackkit/CMakeLists.txt
vendored
@@ -1,11 +0,0 @@
|
||||
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
1
thirdparty/hijackkit/README.txt
vendored
@@ -1 +0,0 @@
|
||||
https://github.com/Jettford/HijackKit
|
||||
18
thirdparty/hijackkit/include/memory.h
vendored
18
thirdparty/hijackkit/include/memory.h
vendored
@@ -1,18 +0,0 @@
|
||||
#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
46
thirdparty/hijackkit/include/tricks.h
vendored
@@ -1,46 +0,0 @@
|
||||
#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
10
thirdparty/hijackkit/include/utils.h
vendored
@@ -1,10 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace hjiack {
|
||||
namespace utils {
|
||||
uintptr_t GetModuleBaseAddress(const wchar_t* moduleName);
|
||||
void AllocateConsole();
|
||||
}
|
||||
}
|
||||
28
thirdparty/hijackkit/source/memory.cpp
vendored
28
thirdparty/hijackkit/source/memory.cpp
vendored
@@ -1,28 +0,0 @@
|
||||
#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
45
thirdparty/hijackkit/source/utils.cpp
vendored
@@ -1,45 +0,0 @@
|
||||
#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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user