From 4133008d9cf2a8b55f8ac8069a7aa22082a3666f Mon Sep 17 00:00:00 2001 From: Jettford Date: Wed, 11 Dec 2024 15:18:45 +0000 Subject: [PATCH] Clean up warnings, fix errors related to testes and how MariaDB moves around --- CMakeLists.txt | 18 +++++----- cmake/FindMariaDB.cmake | 26 +++++++------- dCommon/ZCompression.cpp | 35 ++++++++++++++----- dDatabase/CMakeLists.txt | 2 +- dDatabase/GameDatabase/CMakeLists.txt | 2 +- .../MoveToInventoryMessage.h | 2 +- tests/dCommonTests/CMakeLists.txt | 2 +- tests/dGameTests/CMakeLists.txt | 2 +- 8 files changed, 54 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac08daf1..69509b53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -202,15 +202,15 @@ endforeach() message(STATUS "Resource file integrity check complete") # if navmeshes directory does not exist, create it -if(NOT EXISTS ${PROJECT_BINARY_DIR}/navmeshes) - file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/navmeshes) +if(NOT EXISTS ${CMAKE_BINARY_DIR}/navmeshes) + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/navmeshes) endif() # Copy navmesh data on first build and extract it -configure_file(${CMAKE_SOURCE_DIR}/resources/navmeshes.zip ${PROJECT_BINARY_DIR}/navmeshes.zip COPYONLY) +configure_file(${CMAKE_SOURCE_DIR}/resources/navmeshes.zip ${CMAKE_BINARY_DIR}/navmeshes.zip COPYONLY) -file(ARCHIVE_EXTRACT INPUT ${PROJECT_BINARY_DIR}/navmeshes.zip DESTINATION ${PROJECT_BINARY_DIR}/navmeshes) -file(REMOVE ${PROJECT_BINARY_DIR}/navmeshes.zip) +file(ARCHIVE_EXTRACT INPUT ${CMAKE_BINARY_DIR}/navmeshes.zip DESTINATION ${CMAKE_BINARY_DIR}/navmeshes) +file(REMOVE ${CMAKE_BINARY_DIR}/navmeshes.zip) # Copy vanity files on first build set(VANITY_FILES "CREDITS.md" "INFO.md" "TESTAMENT.md" "root.xml" "dev-tribute.xml" "atm.xml" "demo.xml") @@ -220,20 +220,20 @@ foreach(file ${VANITY_FILES}) endforeach() # Move our migrations for MasterServer to run -file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/migrations/dlu/) +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/migrations/dlu/) file(GLOB SQL_FILES ${CMAKE_SOURCE_DIR}/migrations/dlu/*.sql) foreach(file ${SQL_FILES}) get_filename_component(file ${file} NAME) - configure_file(${CMAKE_SOURCE_DIR}/migrations/dlu/${file} ${PROJECT_BINARY_DIR}/migrations/dlu/${file}) + configure_file(${CMAKE_SOURCE_DIR}/migrations/dlu/${file} ${CMAKE_BINARY_DIR}/migrations/dlu/${file}) endforeach() -file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/migrations/cdserver/) +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/migrations/cdserver/) file(GLOB SQL_FILES ${CMAKE_SOURCE_DIR}/migrations/cdserver/*.sql) foreach(file ${SQL_FILES}) get_filename_component(file ${file} NAME) - configure_file(${CMAKE_SOURCE_DIR}/migrations/cdserver/${file} ${PROJECT_BINARY_DIR}/migrations/cdserver/${file}) + configure_file(${CMAKE_SOURCE_DIR}/migrations/cdserver/${file} ${CMAKE_BINARY_DIR}/migrations/cdserver/${file}) endforeach() # Add system specfic includes for Apple, Windows and Other Unix OS' (including Linux) diff --git a/cmake/FindMariaDB.cmake b/cmake/FindMariaDB.cmake index d3f89931..4593b4f7 100644 --- a/cmake/FindMariaDB.cmake +++ b/cmake/FindMariaDB.cmake @@ -2,8 +2,8 @@ # On Windows ClangCL can't compile the connector from source but can link to an msvc compiled one, # so prefer the prebuilt binaries unless MARIADB_BUILD_SOURCE is specified if(WIN32 AND NOT MARIADB_BUILD_SOURCE) - set(MARIADB_MSI_DIR "${PROJECT_BINARY_DIR}/msi") - set(MARIADB_CONNECTOR_DIR "${PROJECT_BINARY_DIR}/mariadbcpp") + set(MARIADB_MSI_DIR "${CMAKE_BINARY_DIR}/msi") + set(MARIADB_CONNECTOR_DIR "${CMAKE_BINARY_DIR}/mariadbcpp") set(MARIADB_C_CONNECTOR_DIR "${MARIADB_CONNECTOR_DIR}/MariaDB/MariaDB Connector C 64-bit") set(MARIADB_CPP_CONNECTOR_DIR "${MARIADB_CONNECTOR_DIR}/MariaDB/MariaDB C++ Connector 64-bit") @@ -59,7 +59,7 @@ if(WIN32 AND NOT MARIADB_BUILD_SOURCE) COMMAND ${CMAKE_COMMAND} -E copy_if_different "${MARIADBCPP_SHARED_LIBRARY_LOCATION}" "${MARIADBC_SHARED_LIBRARY_LOCATION}" - "${PROJECT_BINARY_DIR}") + "${CMAKE_BINARY_DIR}") # MariaDB uses plugins that the database needs to load, the prebuilt binaries by default will try to find the libraries in system directories, # so set this define and the servers will set the MARIADB_PLUGIN_DIR environment variable to the appropriate directory. @@ -86,13 +86,13 @@ else() # Build from source -DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0) endif() - set(MARIADBCPP_INSTALL_DIR ${PROJECT_BINARY_DIR}/prefix) - set(MARIADBCPP_LIBRARY_DIR ${PROJECT_BINARY_DIR}/mariadbcpp) + set(MARIADBCPP_INSTALL_DIR ${CMAKE_BINARY_DIR}/prefix) + set(MARIADBCPP_LIBRARY_DIR ${CMAKE_BINARY_DIR}/mariadbcpp) set(MARIADBCPP_PLUGIN_DIR ${MARIADBCPP_LIBRARY_DIR}/plugin) set(MARIADBCPP_SOURCE_DIR ${PROJECT_SOURCE_DIR}/thirdparty/mariadb-connector-cpp) set(MARIADB_INCLUDE_DIR "${MARIADBCPP_SOURCE_DIR}/include") ExternalProject_Add(mariadb_connector_cpp - PREFIX "${PROJECT_BINARY_DIR}/thirdparty/mariadb-connector-cpp" + PREFIX "${CMAKE_BINARY_DIR}/thirdparty/mariadb-connector-cpp" SOURCE_DIR ${MARIADBCPP_SOURCE_DIR} INSTALL_DIR ${MARIADBCPP_INSTALL_DIR} CMAKE_ARGS -Wno-dev @@ -127,20 +127,20 @@ else() # Build from source endif() # Create mariadb connector library object -add_library(MariaDB::ConnCpp SHARED IMPORTED GLOBAL) -add_dependencies(MariaDB::ConnCpp mariadb_connector_cpp) -set_target_properties(MariaDB::ConnCpp PROPERTIES +add_library(mariadb_cpp_connector SHARED IMPORTED GLOBAL) +add_dependencies(mariadb_cpp_connector mariadb_connector_cpp) +set_target_properties(mariadb_cpp_connector PROPERTIES IMPORTED_LOCATION "${MARIADBCPP_SHARED_LIBRARY_LOCATION}") if(WIN32) - set_target_properties(MariaDB::ConnCpp PROPERTIES + set_target_properties(mariadb_cpp_connector PROPERTIES IMPORTED_IMPLIB "${MARIADB_IMPLIB_LOCATION}") elseif(APPLE) - set_target_properties(MariaDB::ConnCpp PROPERTIES + set_target_properties(mariadb_cpp_connector PROPERTIES IMPORTED_SONAME "libmariadbcpp") endif() # Add directories to include lists -target_include_directories(MariaDB::ConnCpp SYSTEM INTERFACE ${MARIADB_INCLUDE_DIR}) +target_include_directories(mariadb_cpp_connector SYSTEM INTERFACE ${MARIADB_INCLUDE_DIR}) -set(MariaDB_FOUND TRUE) +set(mariadb_found TRUE) diff --git a/dCommon/ZCompression.cpp b/dCommon/ZCompression.cpp index 85b92e59..f5a09c71 100644 --- a/dCommon/ZCompression.cpp +++ b/dCommon/ZCompression.cpp @@ -1,7 +1,25 @@ #include "ZCompression.h" +#ifdef DARKFLAME_PLATFORM_WIN32 #include "zlib-ng.h" +// Yes, I know there is a "zlib compat mode", it doesn't work, it's really fucking dumb + +#define z_stream zng_stream + +#define z_deflateInit zng_deflateInit +#define z_deflate zng_deflate +#define z_deflateEnd zng_deflateEnd + +#define z_inflateInit zng_inflateInit +#define z_inflate zng_inflate +#define z_inflateEnd zng_inflateEnd + + +#else +#include "zlib.h" +#endif + namespace ZCompression { int32_t GetMaxCompressedLength(int32_t nLenSrc) { int32_t n16kBlocks = (nLenSrc + 16383) / 16384; // round up any fraction of a block @@ -9,41 +27,42 @@ namespace ZCompression { } int32_t Compress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst) { - zng_stream zInfo = { 0 }; + + z_stream zInfo = { 0 }; zInfo.total_in = zInfo.avail_in = nLenSrc; zInfo.total_out = zInfo.avail_out = nLenDst; zInfo.next_in = const_cast(abSrc); zInfo.next_out = abDst; int nErr, nRet = -1; - nErr = zng_deflateInit(&zInfo, Z_DEFAULT_COMPRESSION); // zlib function + nErr = z_deflateInit(&zInfo, Z_DEFAULT_COMPRESSION); // zlib function if (nErr == Z_OK) { - nErr = zng_deflate(&zInfo, Z_FINISH); // zlib function + nErr = z_deflate(&zInfo, Z_FINISH); // zlib function if (nErr == Z_STREAM_END) { nRet = zInfo.total_out; } } - zng_deflateEnd(&zInfo); // zlib function + z_deflateEnd(&zInfo); // zlib function return(nRet); } int32_t Decompress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst, int32_t& nErr) { // Get the size of the decompressed data - zng_stream zInfo = { 0 }; + z_stream zInfo = { 0 }; zInfo.total_in = zInfo.avail_in = nLenSrc; zInfo.total_out = zInfo.avail_out = nLenDst; zInfo.next_in = const_cast(abSrc); zInfo.next_out = abDst; int nRet = -1; - nErr = zng_inflateInit(&zInfo); // zlib function + nErr = z_inflateInit(&zInfo); // zlib function if (nErr == Z_OK) { - nErr = zng_inflate(&zInfo, Z_FINISH); // zlib function + nErr = z_inflate(&zInfo, Z_FINISH); // zlib function if (nErr == Z_STREAM_END) { nRet = zInfo.total_out; } } - zng_inflateEnd(&zInfo); // zlib function + z_inflateEnd(&zInfo); // zlib function return(nRet); } } diff --git a/dDatabase/CMakeLists.txt b/dDatabase/CMakeLists.txt index 42bdb983..84d827c6 100644 --- a/dDatabase/CMakeLists.txt +++ b/dDatabase/CMakeLists.txt @@ -4,7 +4,7 @@ add_subdirectory(GameDatabase) add_library(dDatabase STATIC "MigrationRunner.cpp") add_custom_target(conncpp_dylib - ${CMAKE_COMMAND} -E copy $ ${PROJECT_BINARY_DIR}) + ${CMAKE_COMMAND} -E copy $ ${CMAKE_BINARY_DIR}) add_dependencies(dDatabase conncpp_dylib) diff --git a/dDatabase/GameDatabase/CMakeLists.txt b/dDatabase/GameDatabase/CMakeLists.txt index 32fe414a..98df08c3 100644 --- a/dDatabase/GameDatabase/CMakeLists.txt +++ b/dDatabase/GameDatabase/CMakeLists.txt @@ -21,7 +21,7 @@ target_include_directories(dDatabaseGame PUBLIC "." "${PROJECT_SOURCE_DIR}/dCommon/dEnums" ) target_link_libraries(dDatabaseGame - PUBLIC MariaDB::ConnCpp + PUBLIC mariadb_cpp_connector INTERFACE dCommon) # Glob together all headers that need to be precompiled diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.h index e1f88713..c7888b90 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.h +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.h @@ -8,7 +8,7 @@ class AMFArrayValue; /** * @brief Sent when a player moves a Behavior A at position B to their inventory. */ -#pragma warning("This Control Behavior Message does not have a test yet. Non-developers can ignore this warning.") +#pragma message("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); diff --git a/tests/dCommonTests/CMakeLists.txt b/tests/dCommonTests/CMakeLists.txt index 17b31ced..a94b4406 100644 --- a/tests/dCommonTests/CMakeLists.txt +++ b/tests/dCommonTests/CMakeLists.txt @@ -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 $ ${CMAKE_CURRENT_BINARY_DIR}) + ${CMAKE_COMMAND} -E copy $ ${CMAKE_CURRENT_BINARY_DIR}) add_dependencies(dCommonTests dCommonTestsLink) endif() diff --git a/tests/dGameTests/CMakeLists.txt b/tests/dGameTests/CMakeLists.txt index f4749ce8..e466e65d 100644 --- a/tests/dGameTests/CMakeLists.txt +++ b/tests/dGameTests/CMakeLists.txt @@ -16,7 +16,7 @@ add_executable(dGameTests ${DGAMETEST_SOURCES}) if(APPLE) add_custom_target(dGameTestsLink - ${CMAKE_COMMAND} -E copy $ ${CMAKE_CURRENT_BINARY_DIR}) + ${CMAKE_COMMAND} -E copy $ ${CMAKE_CURRENT_BINARY_DIR}) add_dependencies(dGameTests dGameTestsLink) endif()