diff --git a/CMakeLists.txt b/CMakeLists.txt index 6acca4d8..1a977a64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,12 @@ set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT # Echo the version message(STATUS "Version: ${PROJECT_VERSION}") +# Disable demo, tests and examples for recastNavigation. Turn these to ON if you want to use them +# This has to be done here to prevent a rare build error due to missing dependencies on the initial generations. +set(RECASTNAVIGATION_DEMO OFF CACHE BOOL "" FORCE) +set(RECASTNAVIGATION_TESTS OFF CACHE BOOL "" FORCE) +set(RECASTNAVIGATION_EXAMPLES OFF CACHE BOOL "" FORCE) + # Compiler flags: # Disabled deprecated warnings as the MySQL includes have deprecated code in them. # Disabled misleading indentation as DL_LinkedList from RakNet has a weird indent. @@ -54,7 +60,7 @@ if(UNIX) else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17 -O2 -Wuninitialized -D_GLIBCXX_USE_CXX11_ABI=0 -D_GLIBCXX_USE_CXX17_ABI=0 -static-libgcc -fPIC") endif() - if (__dynamic) + if (__dynamic AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic") endif() if (__ggdb) @@ -137,8 +143,7 @@ set(INCLUDED_DIRECTORIES "thirdparty/raknet/Source" "thirdparty/tinyxml2" - "thirdparty/recastnavigation/Recast/Include" - "thirdparty/recastnavigation/Detour/Include" + "thirdparty/recastnavigation" "thirdparty/SQLite" "thirdparty/cpplinq" ) diff --git a/Docker.md b/Docker.md index 7d5f7bc6..54d0ce19 100644 --- a/Docker.md +++ b/Docker.md @@ -25,8 +25,7 @@ **NOTE #4**: Make sure to run the following in the repo root directory after cloning so submodules are also downloaded. ``` -git submodule init -git submodule update +git submodule update --init --recursive ``` **NOTE #5**: If DarkflameSetup fails due to not having cdclient.fdb, rename CDClient.fdb (in the same folder) to cdclient.fdb diff --git a/build.sh b/build.sh index 31eaa2c7..e61c1cb4 100755 --- a/build.sh +++ b/build.sh @@ -5,8 +5,8 @@ cd build # Run cmake to generate make files cmake .. -# Run make to build the project. To build utilizing multiple cores, append `-j` and the amount of cores to utilize, for example `make -j8` -make +# To build utilizing multiple cores, append `-j` and the amount of cores to utilize, for example `cmake --build . --config Release -j8' +cmake --build . --config Release # Run migrations ./MasterServer -m diff --git a/dCommon/CMakeLists.txt b/dCommon/CMakeLists.txt index 7262bfef..028eb29f 100644 --- a/dCommon/CMakeLists.txt +++ b/dCommon/CMakeLists.txt @@ -19,7 +19,7 @@ include_directories(${PROJECT_SOURCE_DIR}/dCommon/) add_library(dCommon STATIC ${DCOMMON_SOURCES}) -target_link_libraries(dCommon libbcrypt) +target_link_libraries(dCommon bcrypt) if (UNIX) find_package(ZLIB REQUIRED) diff --git a/dCommon/dCommonVars.h b/dCommon/dCommonVars.h index 986f1c18..4c0e15fa 100644 --- a/dCommon/dCommonVars.h +++ b/dCommon/dCommonVars.h @@ -628,6 +628,7 @@ enum ePlayerFlags { GF_BINOC_IN_CROC_AREA = 1308, GF_BINOC_IN_JAIL_AREA = 1309, GF_BINOC_TELESCOPE_NEXT_TO_CAPTAIN_JACK = 1310, + NT_PLINTH_REBUILD = 1919, NT_FACTION_SPY_DUKE = 1974, NT_FACTION_SPY_OVERBUILD = 1976, NT_FACTION_SPY_HAEL = 1977, diff --git a/dGame/CMakeLists.txt b/dGame/CMakeLists.txt index 5acdba31..6b31802e 100644 --- a/dGame/CMakeLists.txt +++ b/dGame/CMakeLists.txt @@ -56,4 +56,4 @@ endforeach() add_library(dGame STATIC ${DGAME_SOURCES}) -target_link_libraries(dGame dDatabase) +target_link_libraries(dGame dDatabase Recast Detour) diff --git a/dGame/Character.cpp b/dGame/Character.cpp index 0b92f0aa..440c30c1 100644 --- a/dGame/Character.cpp +++ b/dGame/Character.cpp @@ -301,9 +301,9 @@ void Character::SaveXMLToDatabase() { character->SetAttribute("gm", m_GMLevel); character->SetAttribute("cc", m_Coins); + auto zoneInfo = dZoneManager::Instance()->GetZone()->GetZoneID(); // lzid garbage, binary concat of zoneID, zoneInstance and zoneClone - if (Game::server->GetZoneID() != 0) { - auto zoneInfo = dZoneManager::Instance()->GetZone()->GetZoneID(); + if (zoneInfo.GetMapID() != 0 && zoneInfo.GetCloneID() == 0) { uint64_t lzidConcat = zoneInfo.GetCloneID(); lzidConcat = (lzidConcat << 16) | uint16_t(zoneInfo.GetInstanceID()); lzidConcat = (lzidConcat << 16) | uint16_t(zoneInfo.GetMapID()); diff --git a/dGame/dComponents/ControllablePhysicsComponent.cpp b/dGame/dComponents/ControllablePhysicsComponent.cpp index 19c17035..471b9ca1 100644 --- a/dGame/dComponents/ControllablePhysicsComponent.cpp +++ b/dGame/dComponents/ControllablePhysicsComponent.cpp @@ -11,6 +11,7 @@ #include "CDClientManager.h" #include "EntityManager.h" #include "Character.h" +#include "dZoneManager.h" ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity) : Component(entity) { m_Position = {}; @@ -163,13 +164,17 @@ void ControllablePhysicsComponent::UpdateXml(tinyxml2::XMLDocument* doc) { return; } - character->SetAttribute("lzx", m_Position.x); - character->SetAttribute("lzy", m_Position.y); - character->SetAttribute("lzz", m_Position.z); - character->SetAttribute("lzrx", m_Rotation.x); - character->SetAttribute("lzry", m_Rotation.y); - character->SetAttribute("lzrz", m_Rotation.z); - character->SetAttribute("lzrw", m_Rotation.w); + auto zoneInfo = dZoneManager::Instance()->GetZone()->GetZoneID(); + + if (zoneInfo.GetMapID() != 0 && zoneInfo.GetCloneID() == 0) { + character->SetAttribute("lzx", m_Position.x); + character->SetAttribute("lzy", m_Position.y); + character->SetAttribute("lzz", m_Position.z); + character->SetAttribute("lzrx", m_Rotation.x); + character->SetAttribute("lzry", m_Rotation.y); + character->SetAttribute("lzrz", m_Rotation.z); + character->SetAttribute("lzrw", m_Rotation.w); + } } void ControllablePhysicsComponent::SetPosition(const NiPoint3& pos) { diff --git a/dGame/dComponents/PhantomPhysicsComponent.cpp b/dGame/dComponents/PhantomPhysicsComponent.cpp index 430acf3c..cef9cc36 100644 --- a/dGame/dComponents/PhantomPhysicsComponent.cpp +++ b/dGame/dComponents/PhantomPhysicsComponent.cpp @@ -162,7 +162,10 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par dpWorld::Instance().AddEntity(m_dpEntity); } else if (info->physicsAsset == "miscellaneous\\misc_phys_640x640.hkx") { - m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 640.0f, 20.0f, 640.0f); + // Move this down by 13.521004 units so it is still effectively at the same height as before + m_Position = m_Position - NiPoint3::UNIT_Y * 13.521004f; + // TODO Fix physics simulation to do simulation at high velocities due to bullet through paper problem... + m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 1638.4f, 13.521004f * 2.0f, 1638.4f); m_dpEntity->SetScale(m_Scale); m_dpEntity->SetRotation(m_Rotation); diff --git a/dNavigation/CMakeLists.txt b/dNavigation/CMakeLists.txt index 5891c77d..4c03d24b 100644 --- a/dNavigation/CMakeLists.txt +++ b/dNavigation/CMakeLists.txt @@ -7,4 +7,4 @@ foreach(file ${DNAVIGATIONS_DTERRAIN_SOURCES}) endforeach() add_library(dNavigation STATIC ${DNAVIGATION_SOURCES}) -target_link_libraries(dNavigation detour recast) +target_link_libraries(dNavigation Detour Recast) diff --git a/dPhysics/CMakeLists.txt b/dPhysics/CMakeLists.txt index 383393cc..5fe6adaa 100644 --- a/dPhysics/CMakeLists.txt +++ b/dPhysics/CMakeLists.txt @@ -7,3 +7,4 @@ set(DPHYSICS_SOURCES "dpCollisionChecks.cpp" "dpWorld.cpp") add_library(dPhysics STATIC ${DPHYSICS_SOURCES}) +target_link_libraries(dPhysics Recast Detour) diff --git a/dScripts/CMakeLists.txt b/dScripts/CMakeLists.txt index 1fa177ba..4476ad7c 100644 --- a/dScripts/CMakeLists.txt +++ b/dScripts/CMakeLists.txt @@ -106,6 +106,7 @@ set(DSCRIPT_SOURCES "ActivityManager.cpp" "FvPassThroughWall.cpp" "FvRaceSmashEggImagineServer.cpp" "GfApeSmashingQB.cpp" + "GfArchway.cpp" "GfBanana.cpp" "GfBananaCluster.cpp" "GfCampfire.cpp" @@ -177,6 +178,7 @@ set(DSCRIPT_SOURCES "ActivityManager.cpp" "NtFactionSpyServer.cpp" "NtHaelServer.cpp" "NtImagBeamBuffer.cpp" + "NtImagimeterVisibility.cpp" "NtOverbuildServer.cpp" "NtParadoxPanelServer.cpp" "NtParadoxTeleServer.cpp" diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index fbcb660a..82cd2ebc 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -116,6 +116,7 @@ #include "BaseEnemyApe.h" #include "GfApeSmashingQB.h" #include "ZoneGfProperty.h" +#include "GfArchway.h" // SG Scripts #include "SGCannon.h" @@ -201,6 +202,7 @@ #include "ForceVolumeServer.h" #include "NtXRayServer.h" #include "NtSleepingGuard.h" +#include "NtImagimeterVisibility.h" // DLU Scripts #include "DLUVanityNPC.h" @@ -493,6 +495,9 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr script = new GfApeSmashingQB(); else if (scriptName == "scripts\\zone\\PROPERTY\\GF\\L_ZONE_GF_PROPERTY.lua") script = new ZoneGfProperty(); + else if (scriptName == "scripts\\ai\\GF\\L_GF_ARCHWAY.lua") { + script = new GfArchway(); + } // SG else if (scriptName == "scripts\\ai\\MINIGAME\\SG_GF\\SERVER\\SG_CANNON.lua") @@ -661,6 +666,9 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr script = new NtXRayServer(); else if (scriptName == "scripts\\02_server\\Map\\NT\\L_NT_SLEEPING_GUARD.lua") script = new NtSleepingGuard(); + else if (scriptName == "scripts\\02_server\\Map\\NT\\L_NT_IMAGIMETER_VISIBILITY_SERVER.lua") { + script = new NTImagimeterVisibility(); + } //AM: else if (scriptName == "scripts\\02_server\\Map\\AM\\L_AM_CONSOLE_TELEPORT_SERVER.lua") diff --git a/dScripts/GfArchway.cpp b/dScripts/GfArchway.cpp new file mode 100644 index 00000000..429f62ae --- /dev/null +++ b/dScripts/GfArchway.cpp @@ -0,0 +1,8 @@ +#include "GfArchway.h" +#include "Entity.h" +#include "SkillComponent.h" + +void GfArchway::OnRebuildComplete(Entity* self, Entity* target) { + auto* skillComponent = target->GetComponent(); + if (skillComponent) skillComponent->CalculateBehavior(SHIELDING_SKILL, SHIELDING_BEHAVIOR, target->GetObjectID(), true); +} diff --git a/dScripts/GfArchway.h b/dScripts/GfArchway.h new file mode 100644 index 00000000..b60b2a9f --- /dev/null +++ b/dScripts/GfArchway.h @@ -0,0 +1,10 @@ +#pragma once +#include "CppScripts.h" + +class GfArchway : public CppScripts::Script { +public: + void OnRebuildComplete(Entity* self, Entity* target) override; +private: + const uint32_t SHIELDING_SKILL = 863; + const uint32_t SHIELDING_BEHAVIOR = 3788; +}; diff --git a/dScripts/NtImagimeterVisibility.cpp b/dScripts/NtImagimeterVisibility.cpp new file mode 100644 index 00000000..c0f9bf51 --- /dev/null +++ b/dScripts/NtImagimeterVisibility.cpp @@ -0,0 +1,11 @@ +#include "NtImagimeterVisibility.h" +#include "GameMessages.h" +#include "Entity.h" +#include "Character.h" + +void NTImagimeterVisibility::OnRebuildComplete(Entity* self, Entity* target) { + auto* character = target->GetCharacter(); + if (character) character->SetPlayerFlag(ePlayerFlags::NT_PLINTH_REBUILD, true); + + GameMessages::SendNotifyClientObject(self->GetObjectID(), u"PlinthBuilt", 0, 0, LWOOBJID_EMPTY, "", target->GetSystemAddress()); +} diff --git a/dScripts/NtImagimeterVisibility.h b/dScripts/NtImagimeterVisibility.h new file mode 100644 index 00000000..04669d4b --- /dev/null +++ b/dScripts/NtImagimeterVisibility.h @@ -0,0 +1,7 @@ +#pragma once +#include "CppScripts.h" + +class NTImagimeterVisibility : public CppScripts::Script { +public: + void OnRebuildComplete(Entity* self, Entity* target) override; +}; diff --git a/dWorldServer/CMakeLists.txt b/dWorldServer/CMakeLists.txt index 05338960..fcf29838 100644 --- a/dWorldServer/CMakeLists.txt +++ b/dWorldServer/CMakeLists.txt @@ -3,4 +3,4 @@ set(DWORLDSERVER_SOURCES "ObjectIDManager.cpp" "WorldServer.cpp") add_executable(WorldServer ${DWORLDSERVER_SOURCES}) -target_link_libraries(WorldServer ${COMMON_LIBRARIES} dChatFilter dGame dZoneManager dPhysics detour recast tinyxml2 dNavigation) +target_link_libraries(WorldServer ${COMMON_LIBRARIES} dChatFilter dGame dZoneManager Detour Recast dPhysics tinyxml2 dNavigation) diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 119ce4fd..c7a27510 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -1,215 +1,27 @@ -# Source Code for raknet -file( - GLOB SOURCES_RAKNET - LIST_DIRECTORIES false - RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" - ${CMAKE_CURRENT_SOURCE_DIR}/raknet/Source/*.cpp -) - # Source Code for recast -file( - GLOB SOURCES_RECAST - LIST_DIRECTORIES false - RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" - ${CMAKE_CURRENT_SOURCE_DIR}/recastnavigation/Recast/Source/*.cpp -) - -# Source Code for detour -file( - GLOB SOURCES_DETOUR - LIST_DIRECTORIES false - RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" - ${CMAKE_CURRENT_SOURCE_DIR}/recastnavigation/Detour/Source/*.cpp -) +add_subdirectory(recastnavigation) +# Turn off tinyxml2 testing +set(tinyxml2_BUILD_TESTING OFF) # Source Code for tinyxml2 -file( - GLOB SOURCES_TINYXML2 - LIST_DIRECTORIES false - RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" - ${CMAKE_CURRENT_SOURCE_DIR}/tinyxml2/tinyxml2.cpp -) +add_subdirectory(tinyxml2) # Source Code for libbcrypt -file( - GLOB SOURCES_LIBBCRYPT - LIST_DIRECTORIES false - RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" - ${CMAKE_CURRENT_SOURCE_DIR}/libbcrypt/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/libbcrypt/src/*.c -) +# Disable warning about no project version. +set(CMAKE_POLICY_DEFAULT_CMP0048 NEW) +# Disable warning about the minimum version of cmake used for bcrypt being deprecated in the future +set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "" FORCE) -file( - GLOB SOURCES_SQLITE3 - LIST_DIRECTORIES false - RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" - ${CMAKE_CURRENT_SOURCE_DIR}/SQLite/*.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/SQLite/*.c -) +add_subdirectory(libbcrypt) -# mariadb connector cpp -# On Windows ClangCL can't compile the connector from source but can link to an msvc compiled one, -# so prefer the prebuilt binaries unless MARIADB_BUILD_SOURCE is specified -if(WIN32 AND NOT MARIADB_BUILD_SOURCE) - set(MARIADB_MSI_DIR "${PROJECT_BINARY_DIR}/msi") - set(MARIADB_CONNECTOR_DIR "${PROJECT_BINARY_DIR}/mariadbcpp") - set(MARIADB_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") +# Source code for sqlite +add_subdirectory(SQLite) - file(MAKE_DIRECTORY "${MARIADB_MSI_DIR}") - file(MAKE_DIRECTORY "${MARIADB_CONNECTOR_DIR}") - - if(NOT EXISTS "${MARIADB_MSI_DIR}/mariadb-connector-c-3.2.5-win64.msi" ) - message("Downloading mariadb connector/c") - file(DOWNLOAD https://dlm.mariadb.com/1936366/connectors/c/connector-c-3.2.5/mariadb-connector-c-3.2.5-win64.msi - "${MARIADB_MSI_DIR}/mariadb-connector-c-3.2.5-win64.msi" - EXPECTED_HASH MD5=09d418c290109068a5bea136dafca36b) - endif() - - if(NOT EXISTS "${MARIADB_MSI_DIR}/mariadb-connector-cpp-1.0.1-win64.msi" ) - message("Downloading mariadb connector/c++") - file(DOWNLOAD https://dlm.mariadb.com/1683453/connectors/cpp/connector-cpp-1.0.1/mariadb-connector-cpp-1.0.1-win64.msi - "${MARIADB_MSI_DIR}/mariadb-connector-cpp-1.0.1-win64.msi" - EXPECTED_HASH MD5=548e743fbf067d21d42b81d958bf4ed7) - endif() - - - file(TO_NATIVE_PATH "${MARIADB_CONNECTOR_DIR}" MSIEXEC_TARGETDIR) - # extract msi files without installing to users system - if(NOT EXISTS "${MARIADB_C_CONNECTOR_DIR}") - file(TO_NATIVE_PATH "${MARIADB_MSI_DIR}/mariadb-connector-c-3.2.5-win64.msi" MSI_DIR) - execute_process(COMMAND msiexec /a ${MSI_DIR} /qn TARGETDIR=${MSIEXEC_TARGETDIR}) - endif() - - if(NOT EXISTS "${MARIADB_CPP_CONNECTOR_DIR}") - file(TO_NATIVE_PATH "${MARIADB_MSI_DIR}/mariadb-connector-cpp-1.0.1-win64.msi" MSI_DIR) - execute_process(COMMAND msiexec /a ${MSI_DIR} /qn TARGETDIR=${MSIEXEC_TARGETDIR}) - endif() - - set(MARIADB_SHARED_LIBRARY_LOCATION "${MARIADB_CPP_CONNECTOR_DIR}/mariadbcpp.dll") - set(MARIADB_IMPLIB_LOCATION "${MARIADB_CPP_CONNECTOR_DIR}/mariadbcpp.lib") - set(MARIADB_INCLUDE_DIR "${MARIADB_CPP_CONNECTOR_DIR}/include/mariadb") - - add_custom_target(mariadb_connector_cpp) - add_custom_command(TARGET mariadb_connector_cpp POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${MARIADB_CPP_CONNECTOR_DIR}/mariadbcpp.dll" - "${MARIADB_C_CONNECTOR_DIR}/lib/libmariadb.dll" - "${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. - # Plugin directory is determined at dll load time (this will happen before main()) so we need to delay the dll load so that we can set the environment variable - add_link_options(/DELAYLOAD:${MARIADB_SHARED_LIBRARY_LOCATION}) - add_compile_definitions(MARIADB_PLUGIN_DIR_OVERRIDE="${MARIADB_CPP_CONNECTOR_DIR}/plugin") -else() # Build from source - - include(ExternalProject) - if(WIN32) - set(MARIADB_EXTRA_COMPILE_FLAGS /EHsc) - set(MARIADB_EXTRA_CMAKE_ARGS -DWITH_MSI=OFF) - elseif(APPLE) - set(MARIADB_EXTRA_COMPILE_FLAGS -D_GLIBCXX_USE_CXX11_ABI=0) - set(MARIADB_EXTRA_CMAKE_ARGS -DWITH_EXTERNAL_ZLIB=ON -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}) - else() - set(MARIADB_EXTRA_COMPILE_FLAGS -D_GLIBCXX_USE_CXX11_ABI=0) - endif() - - ExternalProject_Add(mariadb_connector_cpp - SOURCE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/mariadb-connector-cpp - CMAKE_ARGS "-DCMAKE_CXX_FLAGS:STRING= ${MARIADB_EXTRA_COMPILE_FLAGS}" - -DCMAKE_BUILD_RPATH_USE_ORIGIN=${CMAKE_BUILD_RPATH_USE_ORIGIN} - -DCMAKE_INSTALL_PREFIX=./mariadbcpp # Points the connector to the correct plugin directory - -DINSTALL_PLUGINDIR=plugin - ${MARIADB_EXTRA_CMAKE_ARGS} - PREFIX "${PROJECT_BINARY_DIR}/mariadbcpp" - BUILD_COMMAND cmake --build . --config RelWithDebInfo -j${__maria_db_connector_compile_jobs__} - INSTALL_COMMAND "") - - ExternalProject_Get_Property(mariadb_connector_cpp BINARY_DIR) - - if(WIN32) - set(MARIADB_SHARED_LIBRARY_NAME mariadbcpp.dll) - set(MARIADB_PLUGIN_SUFFIX .dll) - set(MARIADB_IMPLIB_LOCATION "${BINARY_DIR}/RelWithDebInfo/mariadbcpp.lib") - - # When built from source windows only seems to check same folder as exe instead specified folder, so use - # environment variable to force it - add_link_options(/DELAYLOAD:mariadbcpp.dll) - add_compile_definitions(MARIADB_PLUGIN_DIR_OVERRIDE="${PROJECT_BINARY_DIR}/mariadbcpp/plugin") - else() - set(MARIADB_SHARED_LIBRARY_NAME libmariadbcpp${CMAKE_SHARED_LIBRARY_SUFFIX}) - set(MARIADB_PLUGIN_SUFFIX .so) - endif() - - get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) - if(isMultiConfig) - set(MARIADB_SHARED_LIBRARY_LOCATION "${BINARY_DIR}/RelWithDebInfo/${MARIADB_SHARED_LIBRARY_NAME}") - set(MARIADB_SHARED_LIBRARY_COPY_LOCATION "${PROJECT_BINARY_DIR}/$") - set(MARIADB_PLUGINS_LOCATION "${BINARY_DIR}/libmariadb/RelWithDebInfo") - else() - set(MARIADB_SHARED_LIBRARY_LOCATION "${BINARY_DIR}/${MARIADB_SHARED_LIBRARY_NAME}") - set(MARIADB_SHARED_LIBRARY_COPY_LOCATION "${PROJECT_BINARY_DIR}") - set(MARIADB_PLUGINS_LOCATION "${BINARY_DIR}/libmariadb") - endif() - - set(MARIADB_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/thirdparty/mariadb-connector-cpp/include/") - - add_custom_command(TARGET mariadb_connector_cpp POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory - ${BINARY_DIR}/mariadbcpp/plugin - ${MARIADB_SHARED_LIBRARY_COPY_LOCATION} - - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${MARIADB_SHARED_LIBRARY_LOCATION} - ${MARIADB_SHARED_LIBRARY_COPY_LOCATION} - - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${MARIADB_PLUGINS_LOCATION}/caching_sha2_password${MARIADB_PLUGIN_SUFFIX} - ${MARIADB_PLUGINS_LOCATION}/client_ed25519${MARIADB_PLUGIN_SUFFIX} - ${MARIADB_PLUGINS_LOCATION}/dialog${MARIADB_PLUGIN_SUFFIX} - ${MARIADB_PLUGINS_LOCATION}/mysql_clear_password${MARIADB_PLUGIN_SUFFIX} - ${MARIADB_PLUGINS_LOCATION}/sha256_password${MARIADB_PLUGIN_SUFFIX} - ${BINARY_DIR}/mariadbcpp/plugin) -endif() - -# Remove the CMakeLists.txt file from the tests folder for the maria-db-connector so we dont compile the tests. -if(EXISTS "${CMAKE_SOURCE_DIR}/thirdparty/mariadb-connector-cpp/test/CMakeLists.txt") - file(REMOVE "${CMAKE_SOURCE_DIR}/thirdparty/mariadb-connector-cpp/test/CMakeLists.txt") -endif() - -# Create mariadb connector library object -add_library(mariadbConnCpp SHARED IMPORTED GLOBAL) -set_property(TARGET mariadbConnCpp PROPERTY IMPORTED_LOCATION ${MARIADB_SHARED_LIBRARY_LOCATION}) - -if(WIN32) - set_property(TARGET mariadbConnCpp PROPERTY IMPORTED_IMPLIB ${MARIADB_IMPLIB_LOCATION}) -endif() - -# Add directories to include lists -target_include_directories(mariadbConnCpp INTERFACE ${MARIADB_INCLUDE_DIR}) -add_dependencies(mariadbConnCpp mariadb_connector_cpp) +# MariaDB C++ Connector +include(CMakeMariaDBLists.txt) # Create our third party library objects -add_library(raknet ${SOURCES_RAKNET}) -add_library(tinyxml2 ${SOURCES_TINYXML2}) -add_library(detour ${SOURCES_DETOUR}) -add_library(recast ${SOURCES_RECAST}) -add_library(libbcrypt ${SOURCES_LIBBCRYPT}) -add_library(sqlite3 ${SOURCES_SQLITE3}) - -if(WIN32) - # Link Win Sockets 2 to RakNet - target_link_libraries(raknet ws2_32) -elseif(UNIX) - # Add warning disable flags and link Unix libraries to sqlite3 - target_link_libraries(sqlite3 pthread dl m) - - # -Wno-unused-result -Wno-unknown-pragmas -fpermissive - target_compile_options(sqlite3 PRIVATE "-Wno-return-local-addr" "-Wno-maybe-uninitialized") - target_compile_options(raknet PRIVATE "-Wno-write-strings" "-Wformat-overflow=0" "-Wformat=0") - target_compile_options(libbcrypt PRIVATE "-Wno-implicit-function-declaration" "-Wno-int-conversion") -endif() +add_subdirectory(raknet) # Download Backtrace if configured if(UNIX AND NOT APPLE) @@ -233,4 +45,4 @@ if(UNIX AND NOT APPLE) link_directories(${backtrace_SOURCE_DIR}/.libs/) include_directories(${backtrace_SOURCE_DIR}) endif() -endif() \ No newline at end of file +endif() diff --git a/thirdparty/CMakeMariaDBLists.txt b/thirdparty/CMakeMariaDBLists.txt new file mode 100644 index 00000000..55e95c4d --- /dev/null +++ b/thirdparty/CMakeMariaDBLists.txt @@ -0,0 +1,149 @@ +# mariadb connector cpp +# On Windows ClangCL can't compile the connector from source but can link to an msvc compiled one, +# so prefer the prebuilt binaries unless MARIADB_BUILD_SOURCE is specified +if(WIN32 AND NOT MARIADB_BUILD_SOURCE) + set(MARIADB_MSI_DIR "${PROJECT_BINARY_DIR}/msi") + set(MARIADB_CONNECTOR_DIR "${PROJECT_BINARY_DIR}/mariadbcpp") + set(MARIADB_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") + + file(MAKE_DIRECTORY "${MARIADB_MSI_DIR}") + file(MAKE_DIRECTORY "${MARIADB_CONNECTOR_DIR}") + + if(NOT EXISTS "${MARIADB_MSI_DIR}/mariadb-connector-c-3.2.5-win64.msi" ) + message("Downloading mariadb connector/c") + file(DOWNLOAD https://dlm.mariadb.com/1936366/connectors/c/connector-c-3.2.5/mariadb-connector-c-3.2.5-win64.msi + "${MARIADB_MSI_DIR}/mariadb-connector-c-3.2.5-win64.msi" + EXPECTED_HASH MD5=09d418c290109068a5bea136dafca36b) + endif() + + if(NOT EXISTS "${MARIADB_MSI_DIR}/mariadb-connector-cpp-1.0.1-win64.msi" ) + message("Downloading mariadb connector/c++") + file(DOWNLOAD https://dlm.mariadb.com/1683453/connectors/cpp/connector-cpp-1.0.1/mariadb-connector-cpp-1.0.1-win64.msi + "${MARIADB_MSI_DIR}/mariadb-connector-cpp-1.0.1-win64.msi" + EXPECTED_HASH MD5=548e743fbf067d21d42b81d958bf4ed7) + endif() + + + file(TO_NATIVE_PATH "${MARIADB_CONNECTOR_DIR}" MSIEXEC_TARGETDIR) + # extract msi files without installing to users system + if(NOT EXISTS "${MARIADB_C_CONNECTOR_DIR}") + file(TO_NATIVE_PATH "${MARIADB_MSI_DIR}/mariadb-connector-c-3.2.5-win64.msi" MSI_DIR) + execute_process(COMMAND msiexec /a ${MSI_DIR} /qn TARGETDIR=${MSIEXEC_TARGETDIR}) + endif() + + if(NOT EXISTS "${MARIADB_CPP_CONNECTOR_DIR}") + file(TO_NATIVE_PATH "${MARIADB_MSI_DIR}/mariadb-connector-cpp-1.0.1-win64.msi" MSI_DIR) + execute_process(COMMAND msiexec /a ${MSI_DIR} /qn TARGETDIR=${MSIEXEC_TARGETDIR}) + endif() + + set(MARIADB_SHARED_LIBRARY_LOCATION "${MARIADB_CPP_CONNECTOR_DIR}/mariadbcpp.dll") + set(MARIADB_IMPLIB_LOCATION "${MARIADB_CPP_CONNECTOR_DIR}/mariadbcpp.lib") + set(MARIADB_INCLUDE_DIR "${MARIADB_CPP_CONNECTOR_DIR}/include/mariadb") + + add_custom_target(mariadb_connector_cpp) + add_custom_command(TARGET mariadb_connector_cpp POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${MARIADB_CPP_CONNECTOR_DIR}/mariadbcpp.dll" + "${MARIADB_C_CONNECTOR_DIR}/lib/libmariadb.dll" + "${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. + # Plugin directory is determined at dll load time (this will happen before main()) so we need to delay the dll load so that we can set the environment variable + add_link_options(/DELAYLOAD:${MARIADB_SHARED_LIBRARY_LOCATION}) + add_compile_definitions(MARIADB_PLUGIN_DIR_OVERRIDE="${MARIADB_CPP_CONNECTOR_DIR}/plugin") +else() # Build from source + + include(ExternalProject) + if(WIN32) + set(MARIADB_EXTRA_CMAKE_ARGS + -DCMAKE_C_FLAGS=/w # disable zlib warnings + -DCMAKE_CXX_FLAGS=/EHsc + -DWITH_MSI=OFF) + elseif(APPLE) + set(MARIADB_EXTRA_CMAKE_ARGS + -DWITH_EXTERNAL_ZLIB=ON + -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} + -DCMAKE_C_FLAGS=-w # disable zlib warnings + -DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0) + else() + set(MARIADB_EXTRA_CMAKE_ARGS + -DCMAKE_C_FLAGS=-w # disable zlib warnings + -DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0) + endif() + + ExternalProject_Add(mariadb_connector_cpp + SOURCE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/mariadb-connector-cpp + CMAKE_ARGS -Wno-dev + -DCMAKE_BUILD_RPATH_USE_ORIGIN=${CMAKE_BUILD_RPATH_USE_ORIGIN} + -DCMAKE_INSTALL_PREFIX=./mariadbcpp # Points the connector to the correct plugin directory + -DINSTALL_PLUGINDIR=plugin + ${MARIADB_EXTRA_CMAKE_ARGS} + PREFIX "${PROJECT_BINARY_DIR}/mariadbcpp" + BUILD_COMMAND cmake --build . --config RelWithDebInfo -j${__maria_db_connector_compile_jobs__} + INSTALL_COMMAND "") + + ExternalProject_Get_Property(mariadb_connector_cpp BINARY_DIR) + + if(WIN32) + set(MARIADB_SHARED_LIBRARY_NAME mariadbcpp.dll) + set(MARIADB_PLUGIN_SUFFIX .dll) + set(MARIADB_IMPLIB_LOCATION "${BINARY_DIR}/RelWithDebInfo/mariadbcpp.lib") + + # When built from source windows only seems to check same folder as exe instead specified folder, so use + # environment variable to force it + add_link_options(/DELAYLOAD:mariadbcpp.dll) + add_compile_definitions(MARIADB_PLUGIN_DIR_OVERRIDE="${PROJECT_BINARY_DIR}/mariadbcpp/plugin") + else() + set(MARIADB_SHARED_LIBRARY_NAME libmariadbcpp${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(MARIADB_PLUGIN_SUFFIX .so) + endif() + + get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(isMultiConfig) + set(MARIADB_SHARED_LIBRARY_LOCATION "${BINARY_DIR}/RelWithDebInfo/${MARIADB_SHARED_LIBRARY_NAME}") + set(MARIADB_SHARED_LIBRARY_COPY_LOCATION "${PROJECT_BINARY_DIR}/$") + set(MARIADB_PLUGINS_LOCATION "${BINARY_DIR}/libmariadb/RelWithDebInfo") + else() + set(MARIADB_SHARED_LIBRARY_LOCATION "${BINARY_DIR}/${MARIADB_SHARED_LIBRARY_NAME}") + set(MARIADB_SHARED_LIBRARY_COPY_LOCATION "${PROJECT_BINARY_DIR}") + set(MARIADB_PLUGINS_LOCATION "${BINARY_DIR}/libmariadb") + endif() + + set(MARIADB_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/thirdparty/mariadb-connector-cpp/include/") + + add_custom_command(TARGET mariadb_connector_cpp POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory + ${BINARY_DIR}/mariadbcpp/plugin + ${MARIADB_SHARED_LIBRARY_COPY_LOCATION} + + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${MARIADB_SHARED_LIBRARY_LOCATION} + ${MARIADB_SHARED_LIBRARY_COPY_LOCATION} + + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${MARIADB_PLUGINS_LOCATION}/caching_sha2_password${MARIADB_PLUGIN_SUFFIX} + ${MARIADB_PLUGINS_LOCATION}/client_ed25519${MARIADB_PLUGIN_SUFFIX} + ${MARIADB_PLUGINS_LOCATION}/dialog${MARIADB_PLUGIN_SUFFIX} + ${MARIADB_PLUGINS_LOCATION}/mysql_clear_password${MARIADB_PLUGIN_SUFFIX} + ${MARIADB_PLUGINS_LOCATION}/sha256_password${MARIADB_PLUGIN_SUFFIX} + ${BINARY_DIR}/mariadbcpp/plugin) +endif() + +# Remove the CMakeLists.txt file from the tests folder for the maria-db-connector so we dont compile the tests. +if(EXISTS "${CMAKE_SOURCE_DIR}/thirdparty/mariadb-connector-cpp/test/CMakeLists.txt") + file(REMOVE "${CMAKE_SOURCE_DIR}/thirdparty/mariadb-connector-cpp/test/CMakeLists.txt") +endif() + +# Create mariadb connector library object +add_library(mariadbConnCpp SHARED IMPORTED GLOBAL) +set_property(TARGET mariadbConnCpp PROPERTY IMPORTED_LOCATION ${MARIADB_SHARED_LIBRARY_LOCATION}) + +if(WIN32) + set_property(TARGET mariadbConnCpp PROPERTY IMPORTED_IMPLIB ${MARIADB_IMPLIB_LOCATION}) +endif() + +# Add directories to include lists +target_include_directories(mariadbConnCpp INTERFACE ${MARIADB_INCLUDE_DIR}) +add_dependencies(mariadbConnCpp mariadb_connector_cpp) diff --git a/thirdparty/SQLite/CMakeLists.txt b/thirdparty/SQLite/CMakeLists.txt new file mode 100644 index 00000000..aa7a6423 --- /dev/null +++ b/thirdparty/SQLite/CMakeLists.txt @@ -0,0 +1,14 @@ +set (SQLITE3_SOURCES + "CppSQLite3.cpp" + "sqlite3.c" +) + +add_library (sqlite3 ${SQLITE3_SOURCES}) + +if(UNIX) + # Add warning disable flags and link Unix libraries to sqlite3 + target_link_libraries(sqlite3 pthread dl m) + + # -Wno-unused-result -Wno-unknown-pragmas -fpermissive + target_compile_options(sqlite3 PRIVATE "-Wno-return-local-addr" "-Wno-maybe-uninitialized") +endif() diff --git a/thirdparty/raknet/CMakeLists.txt b/thirdparty/raknet/CMakeLists.txt index 8d90f329..417e24dd 100644 --- a/thirdparty/raknet/CMakeLists.txt +++ b/thirdparty/raknet/CMakeLists.txt @@ -1,6 +1,4 @@ - - -PROJECT(RakNetStaticLib) +project(RakNetStaticLib) SET(RAKNET_SOURCES @@ -27,7 +25,7 @@ Source/FileList.cpp Source/RakMemoryOverride.cpp Source/ Source/FileListTransfer.cpp Source/RakNetCommandParser.cpp Source/TCPInterface.cpp Source/FileOperations.cpp Source/RakNetStatistics.cpp Source/TelnetTransport.cpp Source/_FindFirst.cpp Source/RakNetTransport.cpp Source/ThreadsafePacketLogger.cpp -Source/RakThread.cpp Source/SuperFastHash.cpp Source/Itoa.cpp +Source/RakThread.cpp Source/SuperFastHash.cpp Source/Itoa.cpp Source/HTTPConnection.cpp ) @@ -70,18 +68,25 @@ Source/DS_Tree.h Source/RakNetCommandParser.h S Source/DS_WeightedGraph.h Source/RakNetDefines.h Source/ThreadsafePacketLogger.h Source/EmailSender.h Source/RakNetStatistics.h Source/TransportInterface.h Source/EpochTimeToString.h Source/RakNetTransport.h Source/Types.h -Source/RakThread.h Source/SuperFastHash.h Source/Itoa.h -Source/HTTPConnection.h Kbhit.h\ +Source/RakThread.h Source/SuperFastHash.h Source/Itoa.h +Source/HTTPConnection.h Kbhit.h ) -ADD_LIBRARY(RakNet STATIC ${RAKNET_SOURCES}) +add_library(raknet STATIC ${RAKNET_SOURCES}) +target_compile_options(raknet PRIVATE + $<$,$,$>: + -w> + $<$: + /w>) +if(WIN32) + # Link Win Sockets 2 to RakNet + target_link_libraries(raknet ws2_32) +endif() -INSTALL(TARGETS RakNet +install(TARGETS raknet DESTINATION lib) -INSTALL(FILES ${RAKNET_HEADERS} +install(FILES ${RAKNET_HEADERS} DESTINATION include/raknet) - -