Add Aarch64 support (#231)

* added mariadb-connector-cpp submodule

* raknet aarch64 support

* fix compile errors

* mariadb connector swap (in progress)

* update CMakeLists, add preprocessor definition to switch between mysql and mariadb connectors

* update types with missing aarch64 check

* corrected adding extra flag to properly compile mariadbconn in CMakeLists

* updated readme with arm builds section

* fix build failure if test folder does not exist

* Remove mysql connector from all builds, add mariadbconnector to windows build

* readd Linux check for backtrace lib to CMakeLists.txt

* Separate system specific mariadbconncpp extra compile flags

* Copy dlls to exes directory once built

* fetch prebuilt binaries on windows so that ClangCL can be used

* Delay load dll so that plugin directory is set correctly

* Fixed typo in glibcxx compile flag

* whitespacing, spaces -> tabs

* Updated README.md, included instructions to update

* Updated README.md

added libssl-dev requirement and removed mysql connector references from macOS builds section

* apple compile fixes for zlib and shared library name

* add windows arm64 checks to raknet

* remove extra . in shared library location

* Setup plugins directory for the connector to search in, pass openssl_root_dir on for apple

* Fix copy paths for single config generators and non windows

* change plugin folder location, another single config generator fix

* GENERATOR_IS_MULTI_CONFIG is a property not a variable

* Fixed a few errors after merge

* Fix plugin directory path, force windows to look at the right folder

* fixed directory name for make_directory command

* Update README.md

Updated MacOS, Windows build instructions.

* set INSTALL_PLUGINDIR so that the right directory is used

* Support for relative rpath for docker build

* added mariadb-connector-cpp submodule

* raknet aarch64 support

* fix compile errors

* mariadb connector swap (in progress)

* update CMakeLists, add preprocessor definition to switch between mysql and mariadb connectors

* update types with missing aarch64 check

* corrected adding extra flag to properly compile mariadbconn in CMakeLists

* updated readme with arm builds section

* fix build failure if test folder does not exist

* Remove mysql connector from all builds, add mariadbconnector to windows build

* readd Linux check for backtrace lib to CMakeLists.txt

* Separate system specific mariadbconncpp extra compile flags

* Copy dlls to exes directory once built

* fetch prebuilt binaries on windows so that ClangCL can be used

* Delay load dll so that plugin directory is set correctly

* Fixed typo in glibcxx compile flag

* whitespacing, spaces -> tabs

* Updated README.md, included instructions to update

* Updated README.md

added libssl-dev requirement and removed mysql connector references from macOS builds section

* apple compile fixes for zlib and shared library name

* add windows arm64 checks to raknet

* Setup plugins directory for the connector to search in, pass openssl_root_dir on for apple

* Fix copy paths for single config generators and non windows

* change plugin folder location, another single config generator fix

* GENERATOR_IS_MULTI_CONFIG is a property not a variable

* Fixed a few errors after merge

* Fix plugin directory path, force windows to look at the right folder

* fixed directory name for make_directory command

* Update README.md

Updated MacOS, Windows build instructions.

* set INSTALL_PLUGINDIR so that the right directory is used

* Support for relative rpath for docker build

* Rebase on main

* Remove extra git submodule

* Update CMakeLists.txt

* Remove CMakeLists.txt file from mariadb

Remove the CMakeLists.txt file from the mariaDBConnector so we dont build the tests.  Also add a config option to the CMakeVariables.txt so you can build the connector with multiple jobs

* Compile on windows

Specify the mariadbcpp.dll file location with a defined absolute path so windows knows it actually exists.

* default to 1 job

Default mariadb jobs running in parallel to 1 instead of 4

* Move mariadbcpp.dll file to the expected directory on windows

* Changed plugin

Updated the plugin location from the project binary directory to the expected location, the mariadb binary directory.

* Addressed windows dll issues by moving files to the expected directory instead of a directory that wouldnt get created

* Update README

Co-authored-by: Aaron Kimbrell <aronwk.aaron@gmail.com>
Co-authored-by: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com>
This commit is contained in:
jumpy-badger 2022-07-04 05:33:05 +01:00 committed by GitHub
parent 1497d9b35a
commit eaa962f265
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 271 additions and 129 deletions

4
.gitmodules vendored
View File

@ -10,6 +10,10 @@
[submodule "thirdparty/libbcrypt"]
path = thirdparty/libbcrypt
url = https://github.com/trusch/libbcrypt.git
[submodule "thirdparty/mariadb-connector-cpp"]
path = thirdparty/mariadb-connector-cpp
url = https://github.com/mariadb-corporation/mariadb-connector-cpp.git
ignore = dirty
[submodule "thirdparty/docker-utils"]
path = thirdparty/docker-utils
url = https://github.com/lcdr/utils.git

View File

@ -45,12 +45,6 @@ endif()
if(WIN32)
include(FetchContent)
FetchContent_Declare(
mysql
URL https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-8.0.27-winx64.zip
URL_HASH MD5=e3c53f6e4d0a72fde2713f7597bf9468
)
FetchContent_Declare(
zlib
URL https://github.com/madler/zlib/archive/refs/tags/v1.2.11.zip
@ -58,48 +52,35 @@ FetchContent_Declare(
)
FetchContent_MakeAvailable(zlib)
FetchContent_MakeAvailable(mysql)
set(ZLIB_INCLUDE_DIRS ${zlib_SOURCE_DIR} ${zlib_BINARY_DIR})
set_target_properties(zlib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIRS}") # Why?
add_library(ZLIB::ZLIB ALIAS zlib) # You're welcome
endif(WIN32)
if(UNIX)
if(APPLE)
else()
include(FetchContent)
FetchContent_Declare(
mysql
URL https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-8.0.27-linux-glibc2.12-x86-64bit.tar.gz
URL_HASH MD5=12f086b76c11022cc7139b41a36cdf9e
)
if(UNIX AND NOT APPLE)
include(FetchContent)
if (__include_backtrace__ AND __compile_backtrace__)
FetchContent_Declare(
backtrace
GIT_REPOSITORY https://github.com/ianlancetaylor/libbacktrace.git
)
FetchContent_MakeAvailable(mysql)
FetchContent_MakeAvailable(backtrace)
if (__include_backtrace__ AND __compile_backtrace__)
FetchContent_Declare(
backtrace
GIT_REPOSITORY https://github.com/ianlancetaylor/libbacktrace.git
)
if (NOT EXISTS ${backtrace_SOURCE_DIR}/.libs)
set(backtrace_make_cmd "${backtrace_SOURCE_DIR}/configure --prefix=\"/usr\" --enable-shared --with-system-libunwind")
FetchContent_MakeAvailable(backtrace)
if (NOT EXISTS ${backtrace_SOURCE_DIR}/.libs)
set(backtrace_make_cmd "${backtrace_SOURCE_DIR}/configure --prefix=\"/usr\" --enable-shared --with-system-libunwind")
execute_process(
COMMAND bash -c "cd ${backtrace_SOURCE_DIR} && ${backtrace_make_cmd} && make && cd ${CMAKE_SOURCE_DIR}"
)
endif()
link_directories(${backtrace_SOURCE_DIR}/.libs/)
include_directories(${backtrace_SOURCE_DIR})
endif(__include_backtrace__)
execute_process(
COMMAND bash -c "cd ${backtrace_SOURCE_DIR} && ${backtrace_make_cmd} && make && cd ${CMAKE_SOURCE_DIR}"
)
endif()
link_directories(${backtrace_SOURCE_DIR}/.libs/)
include_directories(${backtrace_SOURCE_DIR})
endif(__include_backtrace__)
endif()
endif(UNIX)
# Set the version
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
@ -161,20 +142,9 @@ configure_file("${CMAKE_SOURCE_DIR}/vanity/NPC.xml" "${CMAKE_BINARY_DIR}/vanity/
# 3rdparty includes
include_directories(${PROJECT_SOURCE_DIR}/thirdparty/raknet/Source/)
if(UNIX)
if(APPLE)
include_directories(/usr/local/include/)
include_directories(/usr/local/mysql-connector-c++/include/jdbc/)
include_directories(/usr/local/mysql-connector-c++/include/jdbc/cppconn/)
else()
include_directories(${mysql_SOURCE_DIR}/include/jdbc/)
include_directories(${mysql_SOURCE_DIR}/include/jdbc/cppconn/)
endif(APPLE)
endif(UNIX)
if(WIN32)
include_directories(${mysql_SOURCE_DIR}/include/jdbc)
include_directories(${mysql_SOURCE_DIR}/include/jdbc/cppconn)
endif(WIN32)
if(APPLE)
include_directories(/usr/local/include/)
endif(APPLE)
include_directories(${PROJECT_SOURCE_DIR}/thirdparty/tinyxml2/)
include_directories(${PROJECT_SOURCE_DIR}/thirdparty/recastnavigation/Recast/Include)
include_directories(${PROJECT_SOURCE_DIR}/thirdparty/recastnavigation/Detour/Include)
@ -209,27 +179,8 @@ include_directories(${PROJECT_SOURCE_DIR}/thirdparty/cpplinq/)
include_directories(${PROJECT_SOURCE_DIR}/dNet/)
include_directories(${PROJECT_SOURCE_DIR}/dScripts/)
# Default to linking to libmysql
set(MYSQL_LIB mysql)
if(WIN32)
set(MYSQL_LIB mysqlcppconn)
endif(WIN32)
# Lib folders:
link_directories(${PROJECT_BINARY_DIR})
if(UNIX)
if(APPLE)
link_directories(/usr/local/mysql-connector-c++/lib64/)
else()
link_directories(${mysql_SOURCE_DIR}/lib64/)
# Link to libmysqlcppconn on Linux
set(MYSQL_LIB mysqlcppconn)
endif(APPLE)
endif(UNIX)
if(WIN32)
link_directories(${mysql_SOURCE_DIR}/lib64/vs14)
endif(WIN32)
# Source Code
file(
@ -376,6 +327,145 @@ if(MSVC)
add_compile_options("/wd4267")
endif(MSVC)
# 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_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}/$<CONFIG>")
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()
add_library (mariadbConnCpp SHARED IMPORTED)
set_property(TARGET mariadbConnCpp PROPERTY IMPORTED_LOCATION ${MARIADB_SHARED_LIBRARY_LOCATION})
if(WIN32)
set_property(TARGET mariadbConnCpp PROPERTY IMPORTED_IMPLIB ${MARIADB_IMPLIB_LOCATION})
endif()
target_include_directories(mariadbConnCpp INTERFACE ${MARIADB_INCLUDE_DIR})
add_dependencies(mariadbConnCpp mariadb_connector_cpp)
# 3rdparty static libraries:
#add_library(zlib ${SOURCES_ZLIB})
add_library(raknet ${SOURCES_RAKNET})
@ -395,6 +485,10 @@ add_library(dPhysics ${SOURCES_DPHYSICS})
target_link_libraries(dNet dCommon) #Needed because otherwise linker errors occur.
target_link_libraries(dCommon ZLIB::ZLIB)
target_link_libraries(dCommon libbcrypt)
target_link_libraries(dDatabase mariadbConnCpp)
target_link_libraries(dNet dDatabase)
target_link_libraries(dGame dDatabase)
target_link_libraries(dChatFilter dDatabase)
if(WIN32)
target_link_libraries(raknet ws2_32)
@ -417,7 +511,7 @@ target_link_libraries(WorldServer dPhysics)
target_link_libraries(WorldServer detour)
target_link_libraries(WorldServer recast)
target_link_libraries(WorldServer raknet)
target_link_libraries(WorldServer ${MYSQL_LIB})
target_link_libraries(WorldServer mariadbConnCpp)
if(UNIX)
target_link_libraries(WorldServer pthread)
target_link_libraries(WorldServer dl)
@ -437,7 +531,7 @@ target_link_libraries(AuthServer dCommon)
target_link_libraries(AuthServer dDatabase)
target_link_libraries(AuthServer dNet)
target_link_libraries(AuthServer raknet)
target_link_libraries(AuthServer ${MYSQL_LIB})
target_link_libraries(AuthServer mariadbConnCpp)
if(UNIX)
target_link_libraries(AuthServer pthread)
target_link_libraries(AuthServer dl)
@ -448,7 +542,7 @@ target_link_libraries(MasterServer dCommon)
target_link_libraries(MasterServer dDatabase)
target_link_libraries(MasterServer dNet)
target_link_libraries(MasterServer raknet)
target_link_libraries(MasterServer ${MYSQL_LIB})
target_link_libraries(MasterServer mariadbConnCpp)
if(UNIX)
target_link_libraries(MasterServer pthread)
target_link_libraries(MasterServer dl)
@ -460,7 +554,7 @@ target_link_libraries(ChatServer dChatFilter)
target_link_libraries(ChatServer dDatabase)
target_link_libraries(ChatServer dNet)
target_link_libraries(ChatServer raknet)
target_link_libraries(ChatServer ${MYSQL_LIB})
target_link_libraries(ChatServer mariadbConnCpp)
if(UNIX)
target_link_libraries(ChatServer pthread)
target_link_libraries(ChatServer dl)

View File

@ -16,3 +16,5 @@ NET_VERSION=171022
# Set __include_backtrace__ to 1 to includes the backtrace library for better crashlogs.
# __compile_backtrace__=1
# Set __compile_backtrace__ to 1 to compile the backtrace library instead of using system libraries.
__maria_db_connector_compile_jobs__=1
# Set to the number of jobs (make -j equivalent) to compile the mariadbconn files with.

View File

@ -31,7 +31,6 @@ Development of the latest iteration of Darkflame Universe has been done primaril
```bash
git clone --recursive https://github.com/DarkflameUniverse/DarkflameServer
```
**Python**
Some tools utilized to streamline the setup process require Python 3, make sure you have it installed.
@ -44,7 +43,7 @@ This was done make sure that older and incomplete clients wouldn't produce false
If you're using a DLU client you'll have to go into the "CMakeVariables.txt" file and change the NET_VERSION variable to 171023 to match the modified client's version number.
### Linux builds
Make sure packages like `gcc`, `cmake`, and `zlib` are installed. Depending on the distribution, these packages might already be installed. Note that on systems like Ubuntu, you will need the `zlib1g-dev` package so that the header files are available.
Make sure packages like `gcc`, `cmake`, and `zlib` are installed. Depending on the distribution, these packages might already be installed. Note that on systems like Ubuntu, you will need the `zlib1g-dev` package so that the header files are available. `libssl-dev` will also be required.
CMake must be version 3.14 or higher!
@ -71,22 +70,19 @@ make
```
### MacOS builds
Ensure `cmake`, `zlib` and `open ssl` are installed as well as a compiler (e.g `clang` or `gcc`).
**Download precompiled MySQL connector**
In the repository root folder run the following. Ensure -DOPENSSL_ROOT_DIR=/path/to/openssl points to your openssl install location
```bash
# Install required tools
brew install boost mysql-connector-c++
# Create the build directory, preserving it if it already exists
mkdir -p build
cd build
# Symlinks for finding the required modules
sudo ln -s /usr/local/mysql-connector-c++/lib64/libmysqlcppconn.dylib /usr/local/mysql-connector-c++/lib64/libmysql.dylib
sudo ln -s /usr/local/mysql-connector-c++/lib64/libcrypto.1.1.dylib /usr/local/mysql/lib/libcrypto.1.1.dylib
```
# Run CMake to generate build files
cmake .. -DOPENSSL_ROOT_DIR=/path/to/openssl
Then follow the Linux build steps (gcc is not required), but before running `make`, run the following to make sure all the libs are available in the build folder:
```bash
sudo ln -s /usr/local/mysql-connector-c++/lib64/libssl.1.1.dylib /path/to/build/folder/libssl.1.1.dylib
sudo ln -s /usr/local/mysql-connector-c++/lib64/libcrypto.1.1.dylib /path/to/build/folder/libcrypto.1.1.dylib
# Get cmake to build the project. If make files are being used then using make and appending `-j` and the amount of cores to utilize may be preferable, for example `make -j8`
cmake --build . --config Release
```
### Windows builds (native)
@ -102,10 +98,20 @@ cd build
cmake ..
:: Run CMake with build flag to build
cmake --build .
cmake --build . --config Release
```
**Windows for ARM** has not been tested but should build by doing the following
```batch
:: Create the build directory
mkdir build
cd build
Once built you must also move all DLLs from `build/_deps/mysql-src/lib64` or else you encounter missing DLL errors
:: Run CMake to generate make files
cmake .. -DMARIADB_BUILD_SOURCE=ON
:: Run CMake with build flag to build
cmake --build . --config Release
```
### Windows builds (WSL)
This section will go through how to install [WSL](https://docs.microsoft.com/en-us/windows/wsl/install) and building in a Linux environment under Windows. WSL requires Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11.
@ -129,6 +135,21 @@ sudo apt install build-essential
[**Follow the Linux instructions**](#linux-builds)
### ARM builds
AArch64 builds should work on linux and MacOS using their respective build steps. Windows ARM should build but it has not been tested
### Updating your build
To update your server to the latest version navigate to your cloned directory
```bash
cd /path/to/DarkflameServer
```
run the following commands to update to the latest changes
```bash
git pull
git submodule update --init --recursive
```
now follow the build section for your system
## Setting up the environment
### Database

View File

@ -10,7 +10,6 @@ sql::Driver * Database::driver;
sql::Connection * Database::con;
void Database::Connect(const string& host, const string& database, const string& username, const string& password) {
driver = get_driver_instance();
//To bypass debug issues:
std::string newHost = "tcp://" + host;
@ -19,11 +18,15 @@ void Database::Connect(const string& host, const string& database, const string&
const char* szUsername = username.c_str();
const char* szPassword = password.c_str();
con = driver->connect(szHost, szUsername, szPassword);
con->setSchema(szDatabase);
driver = sql::mariadb::get_driver_instance();
bool myTrue = true;
con->setClientOption("MYSQL_OPT_RECONNECT", &myTrue);
sql::Properties properties;
properties["hostName"] = szHost;
properties["user"] = szUsername;
properties["password"] = szPassword;
properties["autoReconnect"] = "true";
con = driver->connect(properties);
con->setSchema(szDatabase);
} //Connect
void Database::Destroy(std::string source) {
@ -74,4 +77,5 @@ sql::PreparedStatement* Database::CreatePreppedStmt(const std::string& query) {
auto* stmt = con->prepareStatement(str);
return stmt;
} //CreatePreppedStmt
} //CreatePreppedStmt

View File

@ -1,13 +1,7 @@
#pragma once
#include <string>
#include <mysql_connection.h>
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>
#include <cppconn/sqlstring.h>
#include <conncpp.hpp>
class MySqlException : public std::runtime_error {
public:

View File

@ -247,14 +247,15 @@ Leaderboard *LeaderboardManager::GetLeaderboard(uint32_t gameID, InfoType infoTy
uint32_t index = 0;
while (res->next()) {
entries.push_back({
res->getUInt64(4),
res->getString(5),
res->getUInt(1),
res->getUInt(2),
res->getUInt(3),
res->getUInt(6)
});
LeaderboardEntry entry;
entry.playerID = res->getUInt64(4);
entry.playerName = res->getString(5);
entry.time = res->getUInt(1);
entry.score = res->getUInt(2);
entry.placement = res->getUInt(3);
entry.lastPlayed = res->getUInt(6);
entries.push_back(entry);
index++;
}

View File

@ -172,8 +172,8 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
// If the player has a property this query will have a single result.
if (playerPropertyLookupResults->next()) {
const auto cloneId = playerPropertyLookupResults->getUInt64(4);
const auto propertyName = playerPropertyLookupResults->getString(5).asStdString();
const auto propertyDescription = playerPropertyLookupResults->getString(6).asStdString();
const auto propertyName = std::string(playerPropertyLookupResults->getString(5).c_str());
const auto propertyDescription = std::string(playerPropertyLookupResults->getString(6).c_str());
const auto privacyOption = playerPropertyLookupResults->getInt(9);
const auto modApproved = playerPropertyLookupResults->getBoolean(10);
const auto dateLastUpdated = playerPropertyLookupResults->getInt64(11);
@ -212,8 +212,8 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
const auto propertyId = propertyEntry->getUInt64(1);
const auto owner = propertyEntry->getInt(2);
const auto cloneId = propertyEntry->getUInt64(4);
const auto propertyNameFromDb = propertyEntry->getString(5).asStdString();
const auto propertyDescriptionFromDb = propertyEntry->getString(6).asStdString();
const auto propertyNameFromDb = std::string(propertyEntry->getString(5).c_str());
const auto propertyDescriptionFromDb = std::string(propertyEntry->getString(6).c_str());
const auto privacyOption = propertyEntry->getInt(9);
const auto modApproved = propertyEntry->getBoolean(10);
const auto dateLastUpdated = propertyEntry->getInt(11);
@ -239,7 +239,7 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
continue;
} else {
isOwned = cloneId == character->GetPropertyCloneID();
ownerName = nameResult->getString(1).asStdString();
ownerName = std::string(nameResult->getString(1).c_str());
}
delete nameResult;
@ -346,4 +346,4 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
propertiesLeft = nullptr;
GameMessages::SendPropertySelectQuery(m_Parent->GetObjectID(), startIndex, numberOfProperties - (startIndex + numResults) > 0, character->GetPropertyCloneID(), false, true, entries, sysAddr);
}
}

View File

@ -75,7 +75,7 @@ PropertyManagementComponent::PropertyManagementComponent(Entity* parent) : Compo
this->moderatorRequested = propertyEntry->getInt(10) == 0 && rejectionReason == "" && privacyOption == PropertyPrivacyOption::Public;
this->LastUpdatedTime = propertyEntry->getUInt64(11);
this->claimedTime = propertyEntry->getUInt64(12);
this->rejectionReason = propertyEntry->getString(13).asStdString();
this->rejectionReason = std::string(propertyEntry->getString(13).c_str());
this->reputation = propertyEntry->getUInt(14);
Load();
@ -865,7 +865,7 @@ void PropertyManagementComponent::OnQueryPropertyData(Entity* originator, const
result->next();
const auto reason = result->getString(1).asStdString();;
const auto reason = std::string(result->getString(1).c_str());
const auto modApproved = result->getInt(2);
if (reason != "") {
moderatorRequested = false;

View File

@ -306,9 +306,9 @@ void Mail::HandleDataRequest(RakNet::BitStream* packet, const SystemAddress& sys
WriteToPacket(&bitStream, body, 400);
WriteToPacket(&bitStream, sender, 32);*/
WriteStringAsWString(&bitStream, res->getString(7), 50); //subject
WriteStringAsWString(&bitStream, res->getString(8), 400); //body
WriteStringAsWString(&bitStream, res->getString(3), 32); //sender
WriteStringAsWString(&bitStream, res->getString(7).c_str(), 50); //subject
WriteStringAsWString(&bitStream, res->getString(8).c_str(), 400); //body
WriteStringAsWString(&bitStream, res->getString(3).c_str(), 32); //sender
bitStream.Write(uint32_t(0));
bitStream.Write(uint64_t(0));

View File

@ -61,6 +61,10 @@ int main(int argc, char** argv) {
Diagnostics::SetProcessFileName(argv[0]);
Diagnostics::Initialize();
#if defined(_WIN32) && defined(MARIADB_PLUGIN_DIR_OVERRIDE)
_putenv_s("MARIADB_PLUGIN_DIR", MARIADB_PLUGIN_DIR_OVERRIDE);
#endif
//Triggers the shutdown sequence at application exit
std::atexit(ShutdownSequence);
signal(SIGINT, [](int) { ShutdownSequence(); });

View File

@ -35,7 +35,7 @@ RUN echo "Build server" && \
mkdir -p cmake_build && \
cd cmake_build && \
sed -i -e "s/171022/${BUILD_VERSION}/g" ../CMakeVariables.txt && \
cmake .. && \
cmake .. -DCMAKE_BUILD_RPATH_USE_ORIGIN=TRUE && \
make -j $BUILD_THREADS
RUN unzip /build/resources/navmeshes.zip -d /build/cmake_build/res/maps
@ -56,4 +56,4 @@ RUN mkdir -p /build/cmake_build && ln -s /app/_deps /build/cmake_build/_deps
COPY docker/start_server.sh /start_server.sh
CMD [ "/start_server.sh" ]
CMD [ "/start_server.sh" ]

View File

@ -8,7 +8,11 @@ create_test_sourcelist (Tests
# add the executable
add_executable (CommonCxxTests ${Tests})
target_link_libraries(CommonCxxTests dCommon raknet)
if(WIN32)
target_link_libraries(CommonCxxTests ws2_32)
endif(WIN32)
# remove the test driver source file
set (TestsToRun ${Tests})
remove (TestsToRun CommonCxxTests.cpp)

1
thirdparty/mariadb-connector-cpp vendored Submodule

@ -0,0 +1 @@
Subproject commit 3fbdf8fa337d532861f6a61494a72dbce6402f8b

View File

@ -3,7 +3,7 @@
#include <assert.h>
#if defined(_WIN32) || defined(__CYGWIN__)
#include <io.h>
#elif !defined ( __APPLE__ ) && !defined ( __APPLE_CC__ ) && !defined ( __PPC__ ) && !defined ( __FreeBSD__ )
#elif !defined ( __APPLE__ ) && !defined ( __APPLE_CC__ ) && !defined ( __PPC__ ) && !defined ( __FreeBSD__ ) && !defined ( __aarch64__ )
#include <sys/io.h>
#endif
#include "DS_Queue.h"

View File

@ -133,6 +133,7 @@ namespace GenRPC
#define AUTO_RPC_ABI_PPC 4 // first 6 args (even if float) in int reg; first 13 floats in reg.
// parameter passing area with shadow area.
#define AUTO_RPC_ABI_AARCH64 5
// Configure the parameters for the system.
#if defined(__i386__) || defined( _M_IX86 ) || defined( __INTEL__ )
@ -176,6 +177,18 @@ typedef double HardwareReal;
typedef unsigned long long NaturalWord;
typedef double HardwareReal; // could be changed to __float128 on AMD64/nonwin
#elif defined( __aarch64__ ) || defined (_M_ARM64)
#define AUTO_RPC_ABI AUTO_RPC_ABI_AARCH64
#define AUTO_RPC_AUTORPC_WORD 64
#define AUTO_RPC_INT_REG_PARAMS 8
#define AUTO_RPC_FLOAT_REG_PARAMS 8
#define AUTO_RPC_PARAMETER_REFERENCE_THRESHOLD 0
#define AUTO_RPC_INT_SHADOW_OF_FLOATS 0
#define AUTO_RPC_ALLOC_SEPARATE_FLOATS 1
#define AUTO_RPC_CREATE_FLOAT_MAP 0
typedef unsigned long long NaturalWord;
typedef double HardwareReal;
#elif defined ( _PS3 )
typedef double HardwareReal;
typedef unsigned long long NaturalWord;

View File

@ -92,8 +92,8 @@
defined(__amd64) || defined(__amd64__) || \
defined(__alpha__) || defined(__alpha) || defined(__ia64) || defined(__ia64__) || \
defined(_M_ALPHA) || defined(ns32000) || defined(__ns32000__) || defined(sequent) || \
defined(MIPSEL) || defined(_MIPSEL) || defined(sun386) || defined(__sun386__)
defined(MIPSEL) || defined(_MIPSEL) || defined(sun386) || defined(__sun386__) || \
defined(__aarch64__) || defined (_M_ARM64)
# define HOST_ENDIAN_IS_LITTLE
#else
@ -128,8 +128,8 @@ namespace cat
defined(__amd64) || defined(__amd64__) || defined(_M_X64) || \
defined(__alpha__) || defined(__alpha) || defined(__ia64) || defined(__ia64__) || \
defined(_M_ALPHA) || defined(ns32000) || defined(__ns32000__) || defined(sequent) || \
defined(MIPSEL) || defined(_MIPSEL) || defined(sun386) || defined(__sun386__)
defined(MIPSEL) || defined(_MIPSEL) || defined(sun386) || defined(__sun386__) || \
defined(__aarch64__) || defined (_M_ARM64)
# define LITTLE_ENDIAN
#else