diff --git a/.clang-format b/.clang-format
index f1b2f74d0..b77507cbd 100644
--- a/.clang-format
+++ b/.clang-format
@@ -1,21 +1,23 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -4
-AlignAfterOpenBracket: Align
+AlignAfterOpenBracket: BlockIndent
AlignConsecutiveAssignments: None
AlignEscapedNewlines: Left
AlignOperands: Align
-AllowAllArgumentsOnNextLine: false
-AllowAllConstructorInitializersOnNextLine: false
-AllowAllParametersOfDeclarationOnNextLine: false
+AllowAllArgumentsOnNextLine: true
+AllowAllConstructorInitializersOnNextLine: true
+AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Always
-AllowShortCaseLabelsOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
-AllowShortIfStatementsOnASingleLine: Always
+AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
-AlwaysBreakTemplateDeclarations: Yes
+AlwaysBreakTemplateDeclarations: Leave
+BinPackArguments: true
+BinPackParameters: true
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
@@ -35,23 +37,24 @@ BraceWrapping:
SplitEmptyFunction: false
SplitEmptyRecord: true
SplitEmptyNamespace: true
+BracedInitializerIndentWidth: 4
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
-Cpp11BracedListStyle: false
+Cpp11BracedListStyle: true
ColumnLimit: 0
CompactNamespaces: false
-ContinuationIndentWidth: 4
+ContinuationIndentWidth: 0
IndentAccessModifiers: false
IndentCaseLabels: true
IndentPPDirectives: BeforeHash
IndentWidth: 4
InsertNewlineAtEOF: true
KeepEmptyLinesAtTheStartOfBlocks: true
-LambdaBodyIndentation: Signature
+LambdaBodyIndentation: OuterScope
MaxEmptyLinesToKeep: 1
-NamespaceIndentation: All
+NamespaceIndentation: None
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Left
@@ -64,7 +67,7 @@ SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
-SpaceBeforeRangeBasedForLoopColon: false
+SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
diff --git a/.dockerignore b/.dockerignore
index a99bb6a56..a520b11ab 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,5 +1,9 @@
dependencies/v8
.git
-build*/
-cmake-*/
+build
+cmake-build-*/
+vcpkg/
+docker/
+dependencies/fc/
*.tar
+*.diff
diff --git a/.editorconfig b/.editorconfig
index 3b464f4a6..4b329d914 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -448,7 +448,7 @@ ij_c_indent_implementation_members = 0
ij_c_indent_inside_code_block = 4
ij_c_indent_interface_members = 0
ij_c_indent_interface_members_except_ivars_block = false
-ij_c_indent_namespace_members = 4
+ij_c_indent_namespace_members = 0
ij_c_indent_preprocessor_directive = 0
ij_c_indent_visibility_keywords = 4
ij_c_insert_override = true
@@ -979,34 +979,37 @@ ij_toml_keep_indents_on_empty_lines = false
# Visual C++ Code Style settings
-cpp_generate_documentation_comments = xml
+cpp_generate_documentation_comments = doxygen_triple_slash
# Visual C++ Formatting settings
+indent_style = tab
+indent_size = 4
+tab_width= 4
cpp_indent_braces = false
-cpp_indent_multi_line_relative_to = innermost_parenthesis
+cpp_indent_multi_line_relative_to = outermost_parenthesis
cpp_indent_within_parentheses = indent
-cpp_indent_preserve_within_parentheses = true
+cpp_indent_preserve_within_parentheses = false
cpp_indent_case_contents = true
-cpp_indent_case_labels = false
+cpp_indent_case_labels = true
cpp_indent_case_contents_when_block = false
-cpp_indent_lambda_braces_when_parameter = true
+cpp_indent_lambda_braces_when_parameter = false
cpp_indent_goto_labels = one_left
cpp_indent_preprocessor = leftmost_column
cpp_indent_access_specifiers = false
-cpp_indent_namespace_contents = true
+cpp_indent_namespace_contents = false
cpp_indent_preserve_comments = false
-cpp_new_line_before_open_brace_namespace = ignore
-cpp_new_line_before_open_brace_type = ignore
-cpp_new_line_before_open_brace_function = ignore
-cpp_new_line_before_open_brace_block = ignore
-cpp_new_line_before_open_brace_lambda = ignore
-cpp_new_line_scope_braces_on_separate_lines = false
+cpp_new_line_before_open_brace_namespace = new_line
+cpp_new_line_before_open_brace_type = new_line
+cpp_new_line_before_open_brace_function = new_line
+cpp_new_line_before_open_brace_block = new_line
+cpp_new_line_before_open_brace_lambda = new_line
+cpp_new_line_scope_braces_on_separate_lines = true
cpp_new_line_close_brace_same_line_empty_type = false
cpp_new_line_close_brace_same_line_empty_function = false
cpp_new_line_before_catch = true
cpp_new_line_before_else = true
-cpp_new_line_before_while_in_do_while = false
+cpp_new_line_before_while_in_do_while = true
cpp_space_before_function_open_parenthesis = remove
cpp_space_within_parameter_list_parentheses = false
cpp_space_between_empty_parameter_list_parentheses = false
@@ -1043,10 +1046,13 @@ cpp_space_around_ternary_operator = insert
cpp_use_unreal_engine_macro_formatting = true
cpp_wrap_preserve_blocks = one_liners
-# Visual C++ Inlcude Cleanup settings
+# Visual C++ Include Cleanup settings
+cpp_include_cleanup_alternate_files = utilities/std/generator.h:generator,generator.h:generator
cpp_include_cleanup_add_missing_error_tag_type = suggestion
+cpp_include_cleanup_excluded_files = corecrt.h,Windows.h,tomcrypt.h
cpp_include_cleanup_remove_unused_error_tag_type = dimmed
+cpp_include_cleanup_replacement_files = generator:utilities/std/generator.h
cpp_include_cleanup_optimize_unused_error_tag_type = suggestion
cpp_include_cleanup_sort_after_edits = false
cpp_sort_includes_error_tag_type = none
diff --git a/.gitattributes b/.gitattributes
index f2d9aac3e..87c4091bc 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,2 +1,6 @@
-* test eol=lf
-bin/servers/* binary
+* text=auto
+*.cpp text
+*.h text
+*.exe binary
+bin/servers/** binary
+.gitignore text
diff --git a/.gitignore b/.gitignore
index 2d27dda9c..205d6aaea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,10 +10,12 @@ bin/*.bin
bin/*.dat
bin/*.dll
bin/*.exe
+bin/*.idb
+bin/*.ilk
+bin/*.obj
bin/*.pdb
-bin/*.zip
bin/*.txt
-bin/*.ilk
+bin/*.zip
bin/GS2Emu.*
bin/gs2emu*
bin/servers/*
@@ -24,7 +26,7 @@ build*/*
cmake-build-*/
dependencies/.cipd/
dependencies/.gclient*
-dependencies/v8*
+dependencies/fc/
lib/
out/
packages/
diff --git a/.gitmodules b/.gitmodules
index 923c7324b..e69de29bb 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,18 +0,0 @@
-[submodule "dependencies/miniupnp"]
- path = dependencies/miniupnp
- url = https://github.com/miniupnp/miniupnp.git
-[submodule "dependencies/depot_tools"]
- path = dependencies/depot_tools
- url = https://chromium.googlesource.com/chromium/tools/depot_tools.git
-[submodule "dependencies/gs2lib"]
- path = dependencies/gs2lib
- url = https://xtjoeytx@bitbucket.org/xtjoeytx/gs2lib.git
-[submodule "dependencies/gs2compiler"]
- path = dependencies/gs2compiler
- url = https://github.com/xtjoeytx/gs2-parser.git
-[submodule "cmake/nuget"]
- path = cmake/nuget
- url = https://github.com/katusk/CMakeNuGetTools
-[submodule "vcpkg"]
- path = vcpkg
- url = https://github.com/microsoft/vcpkg.git
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 12c57031e..99927daff 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,89 +19,122 @@
# along with GS2Emu. If not, see .
#
-cmake_minimum_required(VERSION 3.0.0)
-
-# Make it easier for Windows users to get the required packages.
-# This needs to go before the project() call.
-if(WIN32)
- set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file")
- set(VCPKG_TARGET_TRIPLET "x64-windows-static")
- if(V8NPCSERVER)
- set(VCPKG_MANIFEST_FEATURES "npcserver")
- endif()
+cmake_minimum_required(VERSION 3.28)
+
+# Add custom CMake modules path for external dependencies.
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/dependencies")
+
+# Includes.
+include(FetchContent)
+include(utility)
+
+# Set build type.
+set(default_build_type "RelWithDebInfo")
+if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
+ message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
+ set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
+ STRING "Choose the type of build." FORCE)
+
+ # Set the possible values of build type for cmake-gui
+ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
+ "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
-project(GS2Emu VERSION 3.0.9 DESCRIPTION "Graal Online v1.411 to v6.037 compatible server" LANGUAGES C CXX)
-
-set(CMAKE_DEBUG_POSTFIX _d)
-
-set(BIN_DIR "bin" CACHE STRING "Binary output directory")
-
-# specify the C++ standard
-set(CMAKE_CXX_STANDARD 20)
-set(CMAKE_CXX_STANDARD_REQUIRED True)
-
-set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/${BIN_DIR})
-set(CPACK_PACKAGE_DIRECTORY ${PROJECT_SOURCE_DIR}/dist)
+# Enable Hot Reload for MSVC compilers if supported.
+if(POLICY CMP0141)
+ cmake_policy(SET CMP0141 NEW) # CMP0141: MSVC debug information format.
+ set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$,$>,$<$:EditAndContinue>$<$:ProgramDatabase>,$<$:ProgramDatabase>>"
+ CACHE STRING "MSVC debug format." FORCE)
+endif()
+# Policies.
+cmake_policy(SET CMP0054 NEW) # CMP0054: Only interpret if() arguments as variables or keywords when unquoted.
+cmake_policy(SET CMP0074 NEW) # CMP0074: find_package uses PackageName_ROOT variables.
+cmake_policy(SET CMP0077 NEW) # CMP0077: option() honors normal variables.
+cmake_policy(SET CMP0091 NEW) # CMP0091: MSVC runtime library flags are selected by an abstraction.
+cmake_policy(SET CMP0095 NEW) # CMP0095: RPATH entries are properly escaped in the intermediary CMake install script.
+cmake_policy(SET CMP0144 NEW) # CMP0144: Also search _ROOT as well as _ROOT.
+if(POLICY CMP0177)
+ cmake_policy(SET CMP0177 NEW) # CMP0177: install() DESTINATION paths are normalized.
+endif()
+if(POLICY CMP0156)
+ cmake_policy(SET CMP0156 NEW) # CMP0156: De-duplicate libraries on link lines based on linker capabilities
+endif()
+if(POLICY CMP0179)
+ cmake_policy(SET CMP0179 NEW) # CMP0179: De-duplication of static libraries on link lines keeps first occurrence
+endif()
-# Second, for multi-config builds (e.g. msvc)
-foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
- string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
- set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/lib )
- set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/lib )
- set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/${BIN_DIR} )
-endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
+# Get submodules.
+find_package(Git QUIET)
+if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
+ # Update submodules as needed
+ option(GIT_SUBMODULE "Check submodules during build" ON)
+ if (GIT_SUBMODULE)
+ message(STATUS "Submodule update")
+ execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ RESULT_VARIABLE GIT_SUBMOD_RESULT)
+ if (NOT GIT_SUBMOD_RESULT EQUAL "0")
+ message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
+ endif()
+ endif()
+endif()
-link_directories(${PROJECT_SOURCE_DIR}/lib)
+# vcpkg configuration.
+set(VCPKG_TARGET_TRIPLET "x64-windows-static" CACHE STRING "vcpkg triplet")
+set(VCPKG_INSTALLED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/build/vcpkg_installed")
+set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>")
+if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ set(CMAKE_EXECUTABLE_SUFFIX ".exe")
+endif()
-# Adhere to GNU filesystem layout conventions
-include(GNUInstallDirs)
+# GS2 project.
+project(GS2Emu VERSION 4.0.0 DESCRIPTION "Graal Online v1.380 to v6.037 compatible server" LANGUAGES C CXX)
-# Lowercase project name for binaries and packaging
+# Lowercase project name for binaries and packaging.
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
-# Additional CMake modules
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
+# Adhere to GNU filesystem layout conventions.
+include(GNUInstallDirs)
-# Version number in format X.YY.ZZ
-string(REPLACE "." ";" VERSION_LIST ${PROJECT_VERSION})
-list(GET VERSION_LIST 0 VER_X)
-list(GET VERSION_LIST 1 VER_Y)
-list(GET VERSION_LIST 2 VER_Z)
-set(VER_EXTRA "-beta" CACHE STRING "Extra version")
+# Debug build postfix.
+set(CMAKE_DEBUG_POSTFIX _d)
-# Build date Information
-string(TIMESTAMP VER_YEAR "%Y")
-string(TIMESTAMP VER_MONTH "%m")
-string(TIMESTAMP VER_DAY "%d")
-string(TIMESTAMP VER_HOUR "%H")
-string(TIMESTAMP VER_MINUTE "%M")
+# Directories.
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build/lib")
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build/lib")
+set(CPACK_PACKAGE_DIRECTORY ${PROJECT_SOURCE_DIR}/dist)
-set(VER_EXTRA "${VER_EXTRA} (${VER_YEAR}-${VER_MONTH}-${VER_DAY} ${VER_HOUR}:${VER_MINUTE})")
+# Dependency and FetchContent setup.
+set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
+set(DEPENDENCY_DIRECTORY "${PROJECT_SOURCE_DIR}/dependencies")
+set(FETCHCONTENT_BASE_DIR "${DEPENDENCY_DIRECTORY}/fc")
+set(FETCHCONTENT_TRY_FIND_PACKAGE_MODE ALWAYS)
+# System defines.
+if(MINGW)
+ message(STATUS "Compiling with MinGW")
+ add_compile_definitions(__GXX_TYPEINFO_EQUALITY_INLINE=1)
+endif()
-set(VER_FULL "${VER_X}.${VER_Y}.${VER_Z}${VER_EXTRA}")
+# Set up version data
+setup_versioning_data()
-set(APP_CREDITS "Joey, Nalin, Codr, and Cadavre")
-set(APP_VENDOR "OpenGraal")
+# Print version data
+message(STATUS "[${PROJECT_NAME}] Configuring version ${VER_FULL}")
-STRING(REGEX REPLACE " " "-" VER_CPACK ${VER_FULL})
-STRING(REGEX REPLACE "[\(]" "" VER_CPACK ${VER_CPACK})
-STRING(REGEX REPLACE "[\)]" "" VER_CPACK ${VER_CPACK})
-STRING(REGEX REPLACE "(-[0-9]+:[0-9]+)" "" VER_CPACK ${VER_CPACK})
+# Generate the IConfig.h file.
+generate_iconfig()
-# Generate version header from the above
-configure_file(
- ${PROJECT_SOURCE_DIR}/server/include/IConfig.h.in
- ${PROJECT_BINARY_DIR}/server/include/IConfig.h
-)
+# Unit testing
+option(TESTS "Compile tests" OFF)
+# Static runtime.
option(STATIC "Compile as a static runtime." ON)
if(STATIC)
- message("Compile as static runtime")
+ message(STATUS "[${PROJECT_NAME}] Compile as static runtime")
add_definitions(-DSTATICLIB)
set(BUILD_SHARED_LIBS FALSE CACHE BOOL "-" FORCE)
else()
@@ -109,53 +142,44 @@ else()
set(BUILD_SHARED_LIBS TRUE CACHE BOOL "-" FORCE)
endif()
-option(GRALATNPC "Compile with Gralat NPC support, only works when V8NPCSERVER is enabled." ON)
-if(GRALATNPC)
- message("Compile with Gralat NPC support")
- add_definitions(-DGRALATNPC)
-else()
- message("Don't compile with Gralat NPC support")
-endif()
+# Dependency: Threads.
+if(NOT MSVC)
+ # Prefer static linkage.
+ if(STATIC)
+ set(SUFFIXES_ORIG ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ endif()
-option(V8NPCSERVER "Compile built-in V8 NPC-Server" OFF)
-if(V8NPCSERVER)
- message("Enabling built-in V8 NPC-Server")
- add_definitions(-DV8NPCSERVER)
-else()
- message("Disabling built-in V8 NPC-Server")
+ find_package(Threads REQUIRED)
+
+ # Restore library suffixes.
+ if(STATIC)
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ${SUFFIXES_ORIG})
+ endif()
endif()
-option(TESTS "Compile tests" ON)
+# Server.
+add_subdirectory(${PROJECT_SOURCE_DIR}/bin)
+add_subdirectory(${PROJECT_SOURCE_DIR}/server)
-option(UPNP "Compile with UPNP support" OFF)
-if(UPNP)
- message("Enabling UPNP support")
- add_definitions(-DUPNP)
-else()
- message("Disabling UPNP support")
-endif()
+###-----------------------###
-# Packaging
-if(APPLE)
- set(CPACK_GENERATOR DragNDrop)
+# Packaging.
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ set(CPACK_GENERATOR "DragNDrop")
set(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME} ${VER_FULL}")
- set(
- CPACK_DMG_DS_STORE_SETUP_SCRIPT
- ${PROJECT_SOURCE_DIR}/resources/packaging/osx/DMGSetup.scpt
- )
- set(
- CPACK_DMG_BACKGROUND_IMAGE
- ${PROJECT_SOURCE_DIR}/resources/packaging/osx/DMGBackground.tif
- )
-elseif(WIN32)
+ set(CPACK_DMG_DS_STORE_SETUP_SCRIPT ${PROJECT_SOURCE_DIR}/resources/packaging/osx/DMGSetup.scpt)
+ set(CPACK_DMG_BACKGROUND_IMAGE ${PROJECT_SOURCE_DIR}/resources/packaging/osx/DMGBackground.tif)
+elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(CPACK_GENERATOR "ZIP")
else()
- set(CPACK_GENERATOR TGZ)
+ set(CPACK_GENERATOR "TGZ")
endif()
-set(CPACK_PACKAGE_NAME ${PROJECT_NAME_LOWER})
-set(CPACK_PACKAGE_VENDOR "OpenGraal Team")
-set(CPACK_PACKAGE_CONTACT "opengraal")
+# More packaging.
+set(CPACK_PACKAGE_NAME "${PROJECT_NAME_LOWER}")
+set(CPACK_PACKAGE_VENDOR "${APP_VENDOR} Team")
+set(CPACK_PACKAGE_CONTACT "preagonal.net")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${VER_CPACK}")
set(CPACK_PACKAGE_VERSION_MAJOR ${VER_X})
set(CPACK_PACKAGE_VERSION_MINOR ${VER_Y})
@@ -167,166 +191,11 @@ set(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE.md)
set(CPACK_SOURCE_GENERATOR TGZ)
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${VER_CPACK}-src")
set(CPACK_SOURCE_IGNORE_FILES "/build/;/.bzr/;~$;${CPACK_SOURCE_IGNORE_FILES}")
-include(CPack)
-
-# Generate version header from the above
-configure_file(
- ${PROJECT_SOURCE_DIR}/server/include/IConfig.h.in
- ${PROJECT_BINARY_DIR}/server/include/IConfig.h
-)
-
-if(APPLE)
- set(MAKE_TESTS OFF)
- # Set variables for generating the Info.plist file
- set(MACOSX_BUNDLE_BUNDLE_VERSION "${VER_FULL}")
- set(MACOSX_BUNDLE_EXECUTABLE ${PROJECT_NAME})
- set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.OpenGraal.GS2Emu")
- set(MACOSX_BUNDLE_NSMAIN_NIB_FILE "Application")
- set(MACOSX_BUNDLE_ICON_FILE "carton")
- set(MACOSX_BUNDLE_NAME ${PROJECT_NAME})
- set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${VER_FULL}")
-elseif(WIN32)
- set(MAKE_TESTS OFF)
- # Visual C++ Compiler options
- if(MSVC)
- set(MAKE_TESTS ON)
-
- # Suppress secure string function warnings
- add_definitions(-D_CRT_SECURE_NO_WARNINGS)
-
- # Supress fmtlib warnings
- add_definitions(-D_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING)
-
- include(CheckCXXCompilerFlag)
- CHECK_CXX_COMPILER_FLAG("/std:c++latest" _cpp_latest_flag_supported)
- if (_cpp_latest_flag_supported)
- set(CMAKE_CXX_STANDARD 23)
- #add_compile_options("/std:c++latest")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE")
- endif()
+set(CPACK_INSTALL_EXECUTABLES "${PROJECT_NAME_LOWER}${CMAKE_EXECUTABLE_SUFFIX}")
- # Enable parallel compilation
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
-
- # Enable preprocessor conformance mode.
- string(APPEND CMAKE_CXX_FLAGS " /Zc:preprocessor")
-
- # Enable static linkage of the Microsoft Visual C/C++ Runtime
- set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
- set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MTd")
- set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT")
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
- set(
- CMAKE_CXX_FLAGS_RELWITHDEBINFO
- "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MTd"
- )
- set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT")
- cmake_policy(SET CMP0043 NEW)
-
- # hack to fix clion + msvc together
- #if (CLIONHAX)
- set(CompilerFlags
- CMAKE_CXX_FLAGS
- CMAKE_CXX_FLAGS_DEBUG
- CMAKE_CXX_FLAGS_RELEASE
- CMAKE_C_FLAGS
- CMAKE_C_FLAGS_DEBUG
- CMAKE_C_FLAGS_RELEASE
- )
- foreach(CompilerFlag ${CompilerFlags})
- string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
- endforeach()
- #endif()
- endif()
-
- if( MINGW )
- add_definitions(-D__STDC_FORMAT_MACROS)
- add_definitions(-D__USE_MINGW_ANSI_STDIO=1 -D_BSD_SOURCE=1)
- add_compile_options(-Wno-deprecated-declarations)
- endif()
-
- # Prevent Windows.h from clashing with the Standard Template Library so we
- # can use std::min/std::max (see https://support.microsoft.com/kb/143208)
- add_definitions(-DNOMINMAX)
-else()
- set(MAKE_TESTS ON)
- if(STATIC)
- # SET(CMAKE_EXE_LINKER_FLAGS "-static")
- endif()
-
- add_definitions(-D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=1 -DNDEBUG=1 -DENABLE_SCRIPTENV_DEBUG=1)
- add_compile_options(-Wno-error -Wno-dev)
-endif()
-
-# Prefer static linkage
-if(STATIC)
- set(SUFFIXES_ORIG ${CMAKE_FIND_LIBRARY_SUFFIXES})
- set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
-endif()
-
-if(V8NPCSERVER)
- if(NOT WIN32 AND NOT APPLE)
- find_package(zstd)
- endif()
- find_package(V8 REQUIRED)
- include(FetchContent)
- set(HTTPLIB_USE_BROTLI_IF_AVAILABLE FALSE CACHE BOOL "-" FORCE)
- FetchContent_Declare(httplib GIT_REPOSITORY https://github.com/yhirose/cpp-httplib.git
- GIT_TAG a609330e4c6374f741d3b369269f7848255e1954)
- FetchContent_MakeAvailable(httplib)
- find_package(OpenSSL REQUIRED)
-
-
- if(NOT V8_FOUND)
- message("v8 not found in system")
- endif()
-endif()
-
-if(UPNP)
- find_package(Miniupnpc)
-
- if(NOT MINIUPNPC_FOUND)
- message("MiniUPNPC not found in system. Compiling it ourselves.")
-
- if(STATIC)
- add_definitions(-DMINIUPNP_STATICLIB)
- set(UPNPC_BUILD_STATIC TRUE CACHE BOOL "-" FORCE)
- set(UPNPC_BUILD_SHARED FALSE CACHE BOOL "-" FORCE)
- else()
- set(UPNPC_BUILD_STATIC FALSE CACHE BOOL "-" FORCE)
- set(UPNPC_BUILD_SHARED TRUE CACHE BOOL "-" FORCE)
- endif()
-
- set(UPNPC_BUILD_TESTS FALSE CACHE BOOL "-" FORCE)
- set(UPNPC_BUILD_SAMPLE FALSE CACHE BOOL "-" FORCE)
- set(NO_GETADDRINFO FALSE CACHE BOOL "-" FORCE)
- set(UPNPC_NO_INSTALL TRUE CACHE BOOL "-" FORCE)
-
- add_subdirectory(${PROJECT_SOURCE_DIR}/dependencies/miniupnp/miniupnpc EXCLUDE_FROM_ALL)
- endif()
-endif()
-
-if(NOT WIN32)
- find_package(Threads REQUIRED)
-endif()
-
-# Restore library suffixes
-if(STATIC)
- set(CMAKE_FIND_LIBRARY_SUFFIXES ${SUFFIXES_ORIG})
-endif()
-
-add_subdirectory(${PROJECT_SOURCE_DIR}/dependencies/gs2lib EXCLUDE_FROM_ALL)
-add_subdirectory(${PROJECT_SOURCE_DIR}/dependencies/gs2compiler EXCLUDE_FROM_ALL)
-
-add_subdirectory(${PROJECT_SOURCE_DIR}/bin)
-add_subdirectory(${PROJECT_SOURCE_DIR}/server)
+include(CPack)
if (TESTS)
enable_testing()
add_subdirectory(${PROJECT_SOURCE_DIR}/Catch_tests)
endif()
-
-set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})
diff --git a/CMakePresets.json b/CMakePresets.json
new file mode 100644
index 000000000..e4413203f
--- /dev/null
+++ b/CMakePresets.json
@@ -0,0 +1,167 @@
+{
+ "version": 5,
+ "configurePresets": [
+ {
+ "name": "Release",
+ "hidden": true,
+ "binaryDir": "${sourceDir}/build",
+ "architecture": {
+ "value": "x64",
+ "strategy": "external"
+ },
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "MinSizeRel",
+ "CMAKE_TOOLCHAIN_FILE": {
+ "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
+ "type": "FILEPATH"
+ },
+ "CMAKE_SUPPRESS_DEVELOPER_WARNINGS": true,
+ "CMAKE_BUILD_WITH_INSTALL_RPATH": false,
+ "PACKET_LOGGING": false
+ }
+ },
+ {
+ "name": "Debug",
+ "hidden": true,
+ "binaryDir": "${sourceDir}/build",
+ "architecture": {
+ "value": "x64",
+ "strategy": "external"
+ },
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "Debug",
+ "CMAKE_TOOLCHAIN_FILE": {
+ "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
+ "type": "FILEPATH"
+ },
+ "CMAKE_SUPPRESS_DEVELOPER_WARNINGS": true,
+ "CMAKE_BUILD_WITH_INSTALL_RPATH": false,
+ "CMAKE_VERBOSE_MAKEFILE": true,
+ "PACKET_LOGGING": false
+ }
+ },
+ {
+ "name": "Release Debug Info",
+ "inherits": "Release",
+ "hidden": true,
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "RelWithDebInfo"
+ }
+ },
+ {
+ "name": "MSVC SegmentHeap",
+ "hidden": true,
+ "condition": {
+ "type": "allOf",
+ "conditions": [
+ {
+ "type": "equals",
+ "lhs": "${hostSystemName}",
+ "rhs": "Windows"
+ },
+ {
+ "type": "notEquals",
+ "lhs": "$env{VSINSTALLDIR}",
+ "rhs": ""
+ }
+ ]
+ },
+ "cacheVariables": {
+ "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "$env{VSINSTALLDIR}Common7/IDE/CommonExtensions/Microsoft/CMake/cmake/Microsoft/SegmentHeap.cmake"
+ }
+ },
+ {
+ "name": "Target Windows",
+ "hidden": true,
+ "cacheVariables": {
+ "VCPKG_TARGET_TRIPLET": "x64-windows-static"
+ }
+ },
+ {
+ "name": "Target Linux",
+ "hidden": true,
+ "cacheVariables": {
+ "VCPKG_TARGET_TRIPLET": "x64-linux"
+ }
+ },
+ {
+ "name": "Windows Release",
+ "inherits": [ "Release", "Target Windows", "MSVC SegmentHeap" ]
+ },
+ {
+ "name": "Windows Debug",
+ "inherits": [ "Debug", "Target Windows", "MSVC SegmentHeap" ]
+ },
+ {
+ "name": "Windows Debug (Packet Logging)",
+ "inherits": "Windows Debug",
+ "cacheVariables": {
+ "PACKET_LOGGING": true
+ }
+ },
+ {
+ "name": "Linux Release",
+ "inherits": [ "Release", "Target Linux" ]
+ },
+ {
+ "name": "Linux Debug",
+ "inherits": [ "Debug", "Target Linux" ]
+ },
+ {
+ "name": "Release MINGW",
+ "inherits": "Release",
+ "cacheVariables": {
+ "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": {
+ "value": "${sourceDir}/cmake/crosscompile/x86_64-mingw64.cmake",
+ "type": "FILEPATH"
+ },
+ "CMAKE_BUILD_WITH_INSTALL_RPATH": true
+ }
+ },
+ {
+ "name": "Linux Remote Release Debug Info",
+ "inherits": "Linux Release",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "RelWithDebInfo"
+ },
+ "vendor": {
+ "microsoft.com/VisualStudioSettings/CMake/1.0": {
+ "intelliSenseMode": "linux-gcc-x64"
+ },
+ "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
+ "rsyncCommandArgs": [ "-t", "--delete", "--delete-excluded" ],
+ "copySourcesOptions": {
+ "exclusionList": [
+ ".vs",
+ ".git",
+ "out",
+ "build",
+ "dependencies/fc"
+ ]
+ }
+ }
+ }
+ },
+ {
+ "name": "Linux Remote Debug",
+ "inherits": "Linux Debug",
+ "vendor": {
+ "microsoft.com/VisualStudioSettings/CMake/1.0": {
+ "intelliSenseMode": "linux-gcc-x64"
+ },
+ "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
+ "rsyncCommandArgs": [ "-t", "--delete", "--delete-excluded" ],
+ "copySourcesOptions": {
+ "exclusionList": [
+ ".vs",
+ ".git",
+ "out",
+ "build",
+ "dependencies/fc"
+ ]
+ }
+ }
+ }
+ }
+ ]
+}
diff --git a/Catch_tests/CMakeLists.txt b/Catch_tests/CMakeLists.txt
index e8d95c94b..076a2a617 100644
--- a/Catch_tests/CMakeLists.txt
+++ b/Catch_tests/CMakeLists.txt
@@ -1,17 +1,9 @@
cmake_minimum_required(VERSION 3.22)
-if(MAKE_TESTS)
- include(FetchContent)
- include(AddTest)
- include(SubdirList)
+if(TESTS)
+ include(utility)
- FetchContent_Declare(
- Catch2
- GIT_REPOSITORY https://github.com/catchorg/Catch2.git
- GIT_TAG v3.4.0 # or a later release
- )
-
- FetchContent_MakeAvailable(Catch2)
+ find_package(Catch2 CONFIG REQUIRED)
subdir_list(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR})
diff --git a/Catch_tests/CString/CString_tests.cpp b/Catch_tests/CString/CString_tests.cpp
index 98f3d81c3..429f63d93 100644
--- a/Catch_tests/CString/CString_tests.cpp
+++ b/Catch_tests/CString/CString_tests.cpp
@@ -59,7 +59,7 @@ SCENARIO( "CString", "[string]" ) {
}
WHEN("escape string") {
- CString originalStr = CString("Test string's, hope it works out \\\\, \\, \", \', \"\" - / lol");
+ auto originalStr = CString("Test string's, hope it works out \\\\, \\, \", \', \"\" - / lol");
CString stringEscaped = originalStr.escape();
THEN("check escaped result") {
@@ -225,7 +225,7 @@ SCENARIO( "CString", "[string]" ) {
test << "hello world";
CString test2 = "HeLlO wOrLd";
- int retVal = test.comparei(test2);
+ bool retVal = test.comparei(test2);
THEN( "return should be true") {
REQUIRE( retVal == true );
@@ -236,11 +236,11 @@ SCENARIO( "CString", "[string]" ) {
test << "hello world";
CString test2 = "HeLlO wOrZd";
- int retVal = test.comparei(test2);
+ bool retVal = test.comparei(test2);
THEN( "return should not be true") {
REQUIRE( retVal != true );
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Catch_tests/Player/Player_tests.cpp b/Catch_tests/Player/Player_tests.cpp
index 1ba2e549a..34e3878e0 100644
--- a/Catch_tests/Player/Player_tests.cpp
+++ b/Catch_tests/Player/Player_tests.cpp
@@ -1,8 +1,13 @@
#define CATCH_CONFIG_MAIN
#include "catch2/catch_all.hpp"
+#include "player/PlayerClient.h"
+
#include
-#include
#include
+#include