mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-22 13:33:35 +00:00
Fix up ZLib a little more and remove more configuration into CMakeLists
This commit is contained in:
parent
6c8bb743af
commit
6eea3f3662
@ -19,6 +19,9 @@ 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")
|
||||
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)
|
||||
@ -89,10 +92,11 @@ elseif(WIN32)
|
||||
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
# Our output dir
|
||||
#set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) # unfortunately, forces all libraries to be built in series, which will slow down the build process
|
||||
# Set the output directories
|
||||
# ./build/<platform + architecture (x64, x86, aarch64)>/<compiler>/<build_mode>/
|
||||
|
||||
set(CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_CXX_COMPILER_ID}/${CMAKE_BUILD_TYPE})
|
||||
|
||||
# TODO make this not have to override the build type directories
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
|
||||
@ -107,6 +111,15 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
|
||||
# Get DLU config directory
|
||||
if(DEFINED ENV{DLU_CONFIG_DIR})
|
||||
set(DLU_CONFIG_DIR $ENV{DLU_CONFIG_DIR})
|
||||
else()
|
||||
set(DLU_CONFIG_DIR ${CMAKE_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
message(STATUS "Configuration Directory is ${DLU_CONFIG_DIR}, and the build directory is ${CMAKE_BINARY_DIR}")
|
||||
|
||||
find_package(MariaDB)
|
||||
|
||||
# Create a /resServer directory
|
||||
@ -115,18 +128,11 @@ make_directory(${CMAKE_BINARY_DIR}/resServer)
|
||||
# Create a /logs directory
|
||||
make_directory(${CMAKE_BINARY_DIR}/logs)
|
||||
|
||||
# Get DLU config directory
|
||||
if(DEFINED ENV{DLU_CONFIG_DIR})
|
||||
set(DLU_CONFIG_DIR $ENV{DLU_CONFIG_DIR})
|
||||
else()
|
||||
set(DLU_CONFIG_DIR ${PROJECT_BINARY_DIR})
|
||||
endif()
|
||||
message(STATUS "Variable: DLU_CONFIG_DIR = ${DLU_CONFIG_DIR}")
|
||||
|
||||
# Copy resource files on first build
|
||||
set(RESOURCE_FILES "sharedconfig.ini" "authconfig.ini" "chatconfig.ini" "worldconfig.ini" "masterconfig.ini" "blocklist.dcf")
|
||||
message(STATUS "Checking resource file integrity")
|
||||
|
||||
|
||||
include(Utils)
|
||||
UpdateConfigOption(${DLU_CONFIG_DIR}/authconfig.ini "port" "auth_server_port")
|
||||
UpdateConfigOption(${DLU_CONFIG_DIR}/chatconfig.ini "port" "chat_server_port")
|
||||
|
@ -11,9 +11,6 @@
|
||||
"displayName": "Default configure step",
|
||||
"description": "Use 'build' dir and Unix makefiles",
|
||||
"binaryDir": "${sourceDir}/build",
|
||||
"environment": {
|
||||
"DLU_CONFIG_DIR": "${sourceDir}/build"
|
||||
},
|
||||
"generator": "Unix Makefiles",
|
||||
|
||||
"hidden": true
|
||||
@ -36,15 +33,13 @@
|
||||
"name": "windows-msvc",
|
||||
"inherits": "windows-default",
|
||||
"displayName": "Windows (MSVC)",
|
||||
"description": "Create a build using MSVC",
|
||||
"binaryDir": "${sourceDir}/build/msvc"
|
||||
"description": "Create a build using MSVC"
|
||||
},
|
||||
{
|
||||
"name": "windows-clang",
|
||||
"inherits": "windows-default",
|
||||
"displayName": "EXPERIMENTAL - Windows (Clang)",
|
||||
"description": "Create a build using Clang",
|
||||
"binaryDir": "${sourceDir}/build/windows-clang",
|
||||
"toolset": "ClangCL"
|
||||
},
|
||||
|
||||
@ -65,8 +60,7 @@
|
||||
"toolchainFile": "${sourceDir}/cmake/toolchains/linux-clang.cmake",
|
||||
|
||||
"displayName": "Linux (Clang)",
|
||||
"description": "Create a build using the Clang toolchain for Linux",
|
||||
"binaryDir": "${sourceDir}/build/linux-clang"
|
||||
"description": "Create a build using the Clang toolchain for Linux"
|
||||
},
|
||||
{
|
||||
"name": "linux-gnu",
|
||||
@ -75,8 +69,7 @@
|
||||
"toolchainFile": "${sourceDir}/cmake/toolchains/linux-gnu.cmake",
|
||||
|
||||
"displayName": "Linux (GNU)",
|
||||
"description": "Create a build using the GNU toolchain for Linux",
|
||||
"binaryDir": "${sourceDir}/build/gnu"
|
||||
"description": "Create a build using the GNU toolchain for Linux"
|
||||
},
|
||||
{
|
||||
"name": "macos",
|
||||
@ -87,8 +80,7 @@
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Darwin"
|
||||
},
|
||||
"binaryDir": "${sourceDir}/build/macos"
|
||||
}
|
||||
}
|
||||
],
|
||||
"testPresets": [
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "ZCompression.h"
|
||||
|
||||
#include "zlib.h"
|
||||
#include "zlib-ng.h"
|
||||
|
||||
namespace ZCompression {
|
||||
int32_t GetMaxCompressedLength(int32_t nLenSrc) {
|
||||
@ -9,41 +9,41 @@ namespace ZCompression {
|
||||
}
|
||||
|
||||
int32_t Compress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst) {
|
||||
z_stream zInfo = { 0 };
|
||||
zng_stream zInfo = { 0 };
|
||||
zInfo.total_in = zInfo.avail_in = nLenSrc;
|
||||
zInfo.total_out = zInfo.avail_out = nLenDst;
|
||||
zInfo.next_in = const_cast<Bytef*>(abSrc);
|
||||
zInfo.next_out = abDst;
|
||||
|
||||
int nErr, nRet = -1;
|
||||
nErr = deflateInit(&zInfo, Z_DEFAULT_COMPRESSION); // zlib function
|
||||
nErr = zng_deflateInit(&zInfo, Z_DEFAULT_COMPRESSION); // zlib function
|
||||
if (nErr == Z_OK) {
|
||||
nErr = deflate(&zInfo, Z_FINISH); // zlib function
|
||||
nErr = zng_deflate(&zInfo, Z_FINISH); // zlib function
|
||||
if (nErr == Z_STREAM_END) {
|
||||
nRet = zInfo.total_out;
|
||||
}
|
||||
}
|
||||
deflateEnd(&zInfo); // zlib function
|
||||
zng_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
|
||||
z_stream zInfo = { 0 };
|
||||
zng_stream zInfo = { 0 };
|
||||
zInfo.total_in = zInfo.avail_in = nLenSrc;
|
||||
zInfo.total_out = zInfo.avail_out = nLenDst;
|
||||
zInfo.next_in = const_cast<Bytef*>(abSrc);
|
||||
zInfo.next_out = abDst;
|
||||
|
||||
int nRet = -1;
|
||||
nErr = inflateInit(&zInfo); // zlib function
|
||||
nErr = zng_inflateInit(&zInfo); // zlib function
|
||||
if (nErr == Z_OK) {
|
||||
nErr = inflate(&zInfo, Z_FINISH); // zlib function
|
||||
nErr = zng_inflate(&zInfo, Z_FINISH); // zlib function
|
||||
if (nErr == Z_STREAM_END) {
|
||||
nRet = zInfo.total_out;
|
||||
}
|
||||
}
|
||||
inflateEnd(&zInfo); // zlib function
|
||||
zng_inflateEnd(&zInfo); // zlib function
|
||||
return(nRet);
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,6 @@
|
||||
#include "Game.h"
|
||||
#include "Logger.h"
|
||||
|
||||
#include "zlib.h"
|
||||
|
||||
AssetManager::AssetManager(const std::filesystem::path& path) {
|
||||
if (!std::filesystem::is_directory(path)) {
|
||||
throw std::runtime_error("Attempted to load asset bundle (" + path.string() + ") however it is not a valid directory.");
|
||||
|
Loading…
Reference in New Issue
Block a user