mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-22 13:33:35 +00:00
Clean up warnings, fix errors related to testes and how MariaDB moves around
This commit is contained in:
parent
391a882b5f
commit
96065529f4
@ -204,15 +204,15 @@ endforeach()
|
|||||||
message(STATUS "Resource file integrity check complete")
|
message(STATUS "Resource file integrity check complete")
|
||||||
|
|
||||||
# if navmeshes directory does not exist, create it
|
# if navmeshes directory does not exist, create it
|
||||||
if(NOT EXISTS ${PROJECT_BINARY_DIR}/navmeshes)
|
if(NOT EXISTS ${CMAKE_BINARY_DIR}/navmeshes)
|
||||||
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/navmeshes)
|
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/navmeshes)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Copy navmesh data on first build and extract it
|
# 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(ARCHIVE_EXTRACT INPUT ${CMAKE_BINARY_DIR}/navmeshes.zip DESTINATION ${CMAKE_BINARY_DIR}/navmeshes)
|
||||||
file(REMOVE ${PROJECT_BINARY_DIR}/navmeshes.zip)
|
file(REMOVE ${CMAKE_BINARY_DIR}/navmeshes.zip)
|
||||||
|
|
||||||
# Copy vanity files on first build
|
# Copy vanity files on first build
|
||||||
set(VANITY_FILES "CREDITS.md" "INFO.md" "TESTAMENT.md" "root.xml" "dev-tribute.xml" "atm.xml" "demo.xml")
|
set(VANITY_FILES "CREDITS.md" "INFO.md" "TESTAMENT.md" "root.xml" "dev-tribute.xml" "atm.xml" "demo.xml")
|
||||||
@ -222,8 +222,21 @@ foreach(file ${VANITY_FILES})
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Move our migrations for MasterServer to run
|
# Move our migrations for MasterServer to run
|
||||||
file(REMOVE_RECURSE ${PROJECT_BINARY_DIR}/migrations)
|
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/migrations/dlu/)
|
||||||
file(COPY ${CMAKE_SOURCE_DIR}/migrations DESTINATION ${CMAKE_BINARY_DIR})
|
file(GLOB SQL_FILES ${CMAKE_SOURCE_DIR}/migrations/dlu/*.sql)
|
||||||
|
|
||||||
|
foreach(file ${SQL_FILES})
|
||||||
|
get_filename_component(file ${file} NAME)
|
||||||
|
configure_file(${CMAKE_SOURCE_DIR}/migrations/dlu/${file} ${CMAKE_BINARY_DIR}/migrations/dlu/${file})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/migrations/cdserver/)
|
||||||
|
file(GLOB SQL_FILES ${CMAKE_SOURCE_DIR}/migrations/cdserver/*.sql)
|
||||||
|
|
||||||
|
foreach(file ${SQL_FILES})
|
||||||
|
get_filename_component(file ${file} NAME)
|
||||||
|
configure_file(${CMAKE_SOURCE_DIR}/migrations/cdserver/${file} ${CMAKE_BINARY_DIR}/migrations/cdserver/${file})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
# Add system specfic includes for Apple, Windows and Other Unix OS' (including Linux)
|
# Add system specfic includes for Apple, Windows and Other Unix OS' (including Linux)
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
# On Windows ClangCL can't compile the connector from source but can link to an msvc compiled one,
|
# 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
|
# so prefer the prebuilt binaries unless MARIADB_BUILD_SOURCE is specified
|
||||||
if(WIN32 AND NOT MARIADB_BUILD_SOURCE)
|
if(WIN32 AND NOT MARIADB_BUILD_SOURCE)
|
||||||
set(MARIADB_MSI_DIR "${PROJECT_BINARY_DIR}/msi")
|
set(MARIADB_MSI_DIR "${CMAKE_BINARY_DIR}/msi")
|
||||||
set(MARIADB_CONNECTOR_DIR "${PROJECT_BINARY_DIR}/mariadbcpp")
|
set(MARIADB_CONNECTOR_DIR "${CMAKE_BINARY_DIR}/mariadbcpp")
|
||||||
set(MARIADB_C_CONNECTOR_DIR "${MARIADB_CONNECTOR_DIR}/MariaDB/MariaDB Connector C 64-bit")
|
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")
|
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
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
"${MARIADBCPP_SHARED_LIBRARY_LOCATION}"
|
"${MARIADBCPP_SHARED_LIBRARY_LOCATION}"
|
||||||
"${MARIADBC_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,
|
# 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.
|
# 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)
|
-DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(MARIADBCPP_INSTALL_DIR ${PROJECT_BINARY_DIR}/prefix)
|
set(MARIADBCPP_INSTALL_DIR ${CMAKE_BINARY_DIR}/prefix)
|
||||||
set(MARIADBCPP_LIBRARY_DIR ${PROJECT_BINARY_DIR}/mariadbcpp)
|
set(MARIADBCPP_LIBRARY_DIR ${CMAKE_BINARY_DIR}/mariadbcpp)
|
||||||
set(MARIADBCPP_PLUGIN_DIR ${MARIADBCPP_LIBRARY_DIR}/plugin)
|
set(MARIADBCPP_PLUGIN_DIR ${MARIADBCPP_LIBRARY_DIR}/plugin)
|
||||||
set(MARIADBCPP_SOURCE_DIR ${PROJECT_SOURCE_DIR}/thirdparty/mariadb-connector-cpp)
|
set(MARIADBCPP_SOURCE_DIR ${PROJECT_SOURCE_DIR}/thirdparty/mariadb-connector-cpp)
|
||||||
set(MARIADB_INCLUDE_DIR "${MARIADBCPP_SOURCE_DIR}/include")
|
set(MARIADB_INCLUDE_DIR "${MARIADBCPP_SOURCE_DIR}/include")
|
||||||
ExternalProject_Add(mariadb_connector_cpp
|
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}
|
SOURCE_DIR ${MARIADBCPP_SOURCE_DIR}
|
||||||
INSTALL_DIR ${MARIADBCPP_INSTALL_DIR}
|
INSTALL_DIR ${MARIADBCPP_INSTALL_DIR}
|
||||||
CMAKE_ARGS -Wno-dev
|
CMAKE_ARGS -Wno-dev
|
||||||
@ -127,20 +127,20 @@ else() # Build from source
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Create mariadb connector library object
|
# Create mariadb connector library object
|
||||||
add_library(MariaDB::ConnCpp SHARED IMPORTED GLOBAL)
|
add_library(mariadb_cpp_connector SHARED IMPORTED GLOBAL)
|
||||||
add_dependencies(MariaDB::ConnCpp mariadb_connector_cpp)
|
add_dependencies(mariadb_cpp_connector mariadb_connector_cpp)
|
||||||
set_target_properties(MariaDB::ConnCpp PROPERTIES
|
set_target_properties(mariadb_cpp_connector PROPERTIES
|
||||||
IMPORTED_LOCATION "${MARIADBCPP_SHARED_LIBRARY_LOCATION}")
|
IMPORTED_LOCATION "${MARIADBCPP_SHARED_LIBRARY_LOCATION}")
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set_target_properties(MariaDB::ConnCpp PROPERTIES
|
set_target_properties(mariadb_cpp_connector PROPERTIES
|
||||||
IMPORTED_IMPLIB "${MARIADB_IMPLIB_LOCATION}")
|
IMPORTED_IMPLIB "${MARIADB_IMPLIB_LOCATION}")
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
set_target_properties(MariaDB::ConnCpp PROPERTIES
|
set_target_properties(mariadb_cpp_connector PROPERTIES
|
||||||
IMPORTED_SONAME "libmariadbcpp")
|
IMPORTED_SONAME "libmariadbcpp")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Add directories to include lists
|
# 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)
|
||||||
|
@ -1,7 +1,25 @@
|
|||||||
#include "ZCompression.h"
|
#include "ZCompression.h"
|
||||||
|
|
||||||
|
#ifdef DARKFLAME_PLATFORM_WIN32
|
||||||
#include "zlib-ng.h"
|
#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 {
|
namespace ZCompression {
|
||||||
int32_t GetMaxCompressedLength(int32_t nLenSrc) {
|
int32_t GetMaxCompressedLength(int32_t nLenSrc) {
|
||||||
int32_t n16kBlocks = (nLenSrc + 16383) / 16384; // round up any fraction of a block
|
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) {
|
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_in = zInfo.avail_in = nLenSrc;
|
||||||
zInfo.total_out = zInfo.avail_out = nLenDst;
|
zInfo.total_out = zInfo.avail_out = nLenDst;
|
||||||
zInfo.next_in = const_cast<Bytef*>(abSrc);
|
zInfo.next_in = const_cast<Bytef*>(abSrc);
|
||||||
zInfo.next_out = abDst;
|
zInfo.next_out = abDst;
|
||||||
|
|
||||||
int nErr, nRet = -1;
|
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) {
|
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) {
|
if (nErr == Z_STREAM_END) {
|
||||||
nRet = zInfo.total_out;
|
nRet = zInfo.total_out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zng_deflateEnd(&zInfo); // zlib function
|
z_deflateEnd(&zInfo); // zlib function
|
||||||
return(nRet);
|
return(nRet);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Decompress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst, int32_t& nErr) {
|
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
|
// Get the size of the decompressed data
|
||||||
zng_stream zInfo = { 0 };
|
z_stream zInfo = { 0 };
|
||||||
zInfo.total_in = zInfo.avail_in = nLenSrc;
|
zInfo.total_in = zInfo.avail_in = nLenSrc;
|
||||||
zInfo.total_out = zInfo.avail_out = nLenDst;
|
zInfo.total_out = zInfo.avail_out = nLenDst;
|
||||||
zInfo.next_in = const_cast<Bytef*>(abSrc);
|
zInfo.next_in = const_cast<Bytef*>(abSrc);
|
||||||
zInfo.next_out = abDst;
|
zInfo.next_out = abDst;
|
||||||
|
|
||||||
int nRet = -1;
|
int nRet = -1;
|
||||||
nErr = zng_inflateInit(&zInfo); // zlib function
|
nErr = z_inflateInit(&zInfo); // zlib function
|
||||||
if (nErr == Z_OK) {
|
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) {
|
if (nErr == Z_STREAM_END) {
|
||||||
nRet = zInfo.total_out;
|
nRet = zInfo.total_out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zng_inflateEnd(&zInfo); // zlib function
|
z_inflateEnd(&zInfo); // zlib function
|
||||||
return(nRet);
|
return(nRet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ add_subdirectory(GameDatabase)
|
|||||||
add_library(dDatabase STATIC "MigrationRunner.cpp")
|
add_library(dDatabase STATIC "MigrationRunner.cpp")
|
||||||
|
|
||||||
add_custom_target(conncpp_dylib
|
add_custom_target(conncpp_dylib
|
||||||
${CMAKE_COMMAND} -E copy $<TARGET_FILE:MariaDB::ConnCpp> ${PROJECT_BINARY_DIR})
|
${CMAKE_COMMAND} -E copy $<TARGET_FILE:mariadb_cpp_connector> ${CMAKE_BINARY_DIR})
|
||||||
|
|
||||||
add_dependencies(dDatabase conncpp_dylib)
|
add_dependencies(dDatabase conncpp_dylib)
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ target_include_directories(dDatabaseGame PUBLIC "."
|
|||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(dDatabaseGame
|
target_link_libraries(dDatabaseGame
|
||||||
INTERFACE dCommon
|
PUBLIC mariadb_cpp_connector
|
||||||
PRIVATE sqlite3 MariaDB::ConnCpp)
|
INTERFACE dCommon)
|
||||||
|
|
||||||
# Glob together all headers that need to be precompiled
|
# Glob together all headers that need to be precompiled
|
||||||
file(
|
file(
|
||||||
|
@ -21,7 +21,7 @@ add_executable(dCommonTests ${DCOMMONTEST_SOURCES})
|
|||||||
# Needs to be in binary dir for ctest
|
# Needs to be in binary dir for ctest
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
add_custom_target(dCommonTestsLink
|
add_custom_target(dCommonTestsLink
|
||||||
${CMAKE_COMMAND} -E copy $<TARGET_FILE:MariaDB::ConnCpp> ${CMAKE_CURRENT_BINARY_DIR})
|
${CMAKE_COMMAND} -E copy $<TARGET_FILE:mariadb_cpp_connector> ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
add_dependencies(dCommonTests dCommonTestsLink)
|
add_dependencies(dCommonTests dCommonTestsLink)
|
||||||
endif()
|
endif()
|
||||||
|
@ -16,7 +16,7 @@ add_executable(dGameTests ${DGAMETEST_SOURCES})
|
|||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
add_custom_target(dGameTestsLink
|
add_custom_target(dGameTestsLink
|
||||||
${CMAKE_COMMAND} -E copy $<TARGET_FILE:MariaDB::ConnCpp> ${CMAKE_CURRENT_BINARY_DIR})
|
${CMAKE_COMMAND} -E copy $<TARGET_FILE:mariadb_cpp_connector> ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
add_dependencies(dGameTests dGameTestsLink)
|
add_dependencies(dGameTests dGameTestsLink)
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user