Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyx14 committed Feb 14, 2024
1 parent 471ffd3 commit 2fc75e3
Show file tree
Hide file tree
Showing 122 changed files with 2,025 additions and 1,492 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ option(RUN_TESTS_AFTER_BUILD "Run tests when building" OFF) # By default, tests
# *****************************************************************************
# Add project
# *****************************************************************************
add_subdirectory(src/protobuf)
add_subdirectory(src)

if(BUILD_TESTS)
Expand Down
79 changes: 31 additions & 48 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,29 @@
},
"configurePresets": [
{
"name": "windows-release",
"displayName": "Windows - Release",
"description": "Sets Ninja generator, compilers, build and install directory and set build type as release",
"name": "base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"type": "FILEPATH"
},
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"BUILD_STATIC_LIBRARY": "ON",
"VCPKG_TARGET_TRIPLET": "x64-windows-static",
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"OPTIONS_ENABLE_SCCACHE": "ON"
},
"architecture": {
"value": "x64",
"strategy": "external"
},
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": ["Windows"]
}
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
"SPEED_UP_BUILD_UNITY": "ON",
"OPTIONS_ENABLE_SCCACHE": "ON",
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "linux-release",
"displayName": "Linux - Release",
"description": "Sets Ninja generator, compilers, build and install directory and set build type as release",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"name": "windows-release",
"inherits": "base",
"displayName": "Windows - Release",
"description": "Windows Release Build",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"type": "FILEPATH"
},
"BUILD_STATIC_LIBRARY": "ON",
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"OPTIONS_ENABLE_CCACHE": "ON",
"RUN_TESTS_AFTER_BUILD": "OFF"
"VCPKG_TARGET_TRIPLET": "x64-windows-static"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
"architecture": {
"value": "x64",
"strategy": "external"
}
},
{
Expand All @@ -69,10 +42,6 @@
"DEBUG_LOG": "ON",
"BUILD_STATIC_LIBRARY": "OFF",
"VCPKG_TARGET_TRIPLET": "x64-windows"
},
"architecture": {
"value": "x64",
"strategy": "external"
}
},
{
Expand All @@ -86,10 +55,24 @@
"ASAN_ENABLED": "OFF",
"BUILD_STATIC_LIBRARY": "OFF",
"VCPKG_TARGET_TRIPLET": "x64-windows"
}
},
{
"name": "linux-release",
"inherits": "base",
"displayName": "Linux - Release",
"description": "Sets Ninja generator, compilers, build and install directory and set build type as release",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"type": "FILEPATH"
},
"RUN_TESTS_AFTER_BUILD": "OFF"
},
"architecture": {
"value": "x64",
"strategy": "external"
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
}
},
{
Expand Down
3 changes: 3 additions & 0 deletions cmake/modules/BaseConfig.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cmake_minimum_required(VERSION 3.22 FATAL_ERROR)

# *****************************************************************************
# CMake Features
# *****************************************************************************
Expand Down Expand Up @@ -69,6 +71,7 @@ option(DEBUG_LOG "Enable Debug Log" OFF)
option(ASAN_ENABLED "Build this target with AddressSanitizer" OFF)
option(BUILD_STATIC_LIBRARY "Build using static libraries" OFF)
option(SPEED_UP_BUILD_UNITY "Compile using build unity for speed up build" ON)
option(USE_PRECOMPILED_HEADER "Compile using precompiled header" ON)

# === ASAN ===
if(ASAN_ENABLED)
Expand Down
54 changes: 30 additions & 24 deletions cmake/modules/CanaryLib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,22 @@ add_subdirectory(lib)
add_subdirectory(kv)
add_subdirectory(lua)
add_subdirectory(map)
add_subdirectory(protobuf)
add_subdirectory(security)
add_subdirectory(server)
add_subdirectory(utils)

# Add more global sources - please add preferably in the sub_directory CMakeLists.
set(ProtobufFiles
protobuf/appearances.pb.cc
protobuf/kv.pb.cc
)

# Add more global sources - please add preferably in the sub_directory CMakeLists.
target_sources(${PROJECT_NAME}_lib PRIVATE canary_server.cpp ${ProtobufFiles})

# Skip unity build inclusion for protobuf files
set_source_files_properties(
${ProtobufFiles} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON
)

target_sources(${PROJECT_NAME}_lib PRIVATE canary_server.cpp)

# Add public pre compiler header to lib, to pass down to related targets
target_precompile_headers(${PROJECT_NAME}_lib PUBLIC pch.hpp)
if (NOT SPEED_UP_BUILD_UNITY)
target_precompile_headers(${PROJECT_NAME}_lib PUBLIC pch.hpp)
endif()

if(NOT SPEED_UP_BUILD_UNITY AND USE_PRECOMPILED_HEADERS)
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC -DUSE_PRECOMPILED_HEADERS)
endif()

# *****************************************************************************
# Build flags - need to be set before the links and sources
Expand All @@ -43,6 +38,14 @@ if (CMAKE_COMPILER_IS_GNUCXX)
target_compile_options(${PROJECT_NAME}_lib PRIVATE -Wno-deprecated-declarations)
endif()

# Sets the NDEBUG macro for RelWithDebInfo and Release configurations.
# This disables assertions in these configurations, optimizing the code for performance
# and reducing debugging overhead, while keeping debug information available for diagnostics.
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC
$<$<CONFIG:RelWithDebInfo>:NDEBUG>
$<$<CONFIG:Release>:NDEBUG>
)

# === IPO ===
if(MSVC)
target_compile_options(${PROJECT_NAME}_lib PRIVATE "/GL")
Expand All @@ -52,8 +55,8 @@ if(MSVC)
MODULE_LINKER_FLAGS "/LTCG"
EXE_LINKER_FLAGS "/LTCG")
else()
include(CheckIPOSupported)
check_ipo_supported(RESULT result)
include(CheckIPOSupported)
check_ipo_supported(RESULT result)
if(result)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=auto")
message(STATUS "IPO/LTO enabled with -flto=auto for non-MSVC compiler.")
Expand Down Expand Up @@ -102,14 +105,15 @@ target_link_libraries(${PROJECT_NAME}_lib
unofficial::argon2::libargon2
unofficial::libmariadb
unofficial::mariadbclient
opentelemetry-cpp::common
opentelemetry-cpp::metrics
opentelemetry-cpp::api
opentelemetry-cpp::ext
opentelemetry-cpp::sdk
opentelemetry-cpp::logs
opentelemetry-cpp::ostream_metrics_exporter
opentelemetry-cpp::prometheus_exporter
opentelemetry-cpp::common
opentelemetry-cpp::metrics
opentelemetry-cpp::api
opentelemetry-cpp::ext
opentelemetry-cpp::sdk
opentelemetry-cpp::logs
opentelemetry-cpp::ostream_metrics_exporter
opentelemetry-cpp::prometheus_exporter
protobuf
)

if(CMAKE_BUILD_TYPE MATCHES Debug)
Expand All @@ -121,8 +125,10 @@ endif()
if (MSVC)
if(BUILD_STATIC_LIBRARY)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC jsoncpp_static)
set(VCPKG_TARGET_TRIPLET "x64-windows-static" CACHE STRING "")
else()
target_link_libraries(${PROJECT_NAME}_lib PUBLIC jsoncpp_lib)
set(VCPKG_TARGET_TRIPLET "x64-windows" CACHE STRING "")
endif()

target_link_libraries(${PROJECT_NAME}_lib PUBLIC ${CMAKE_THREAD_LIBS_INIT} ${MYSQL_CLIENT_LIBS})
Expand Down
12 changes: 7 additions & 5 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ buyBlessCommandFee = 0
teleportPlayerToVocationRoom = true
toggleReceiveReward = false
randomMonsterSpawn = false
lootPouchMaxLimit = 2000
storeInboxMaxLimit = 2000

-- Teleport summon
-- Set to true will never remove the summon
Expand Down Expand Up @@ -339,12 +341,12 @@ pushDistanceDelay = 1500
pushWhenAttacking = false

-- Map
-- NOTE: set mapName WITHOUT .otbm at the end
-- NOTE: If toggleDownloadMap if false, then the mapDownloadUrl will not be used
-- NOTE: If a map with the name already exists in the world folder, the map will not be downloaded even if the toggleDownloadMap is true
toggleDownloadMap = false
mapName = "forgotten"
-- Note: Set mapName without .otbm at the end.
-- Note: If toggleDownloadMap is set to false, the mapDownloadUrl will not be used.
-- Note: If a map with the same name already exists in the world folder, the map will not be downloaded, even if toggleDownloadMap is set to true.
toggleDownloadMap = true
mapDownloadUrl = ""
mapName = "forgotten"
mapAuthor = "OTLand"

-- Party List limitations
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cmake_minimum_required(VERSION 3.22 FATAL_ERROR)

# Base configurations and settings for the project
include(BaseConfig)
include(GNUInstallDirs)
Expand Down
1 change: 1 addition & 0 deletions src/account/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
target_sources(${PROJECT_NAME}_lib PRIVATE
account.cpp
account_repository.cpp
account_repository_db.cpp
)
Loading

0 comments on commit 2fc75e3

Please sign in to comment.