Skip to content

Commit

Permalink
Merge branch 'main' into custom-pvp-system
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbesiren authored Sep 11, 2023
2 parents 33ae74d + be8f2e8 commit f64cb2f
Show file tree
Hide file tree
Showing 3,870 changed files with 67,573 additions and 67,322 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
16 changes: 11 additions & 5 deletions .github/workflows/lua-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
name: Lua-format
on:
pull_request:
paths:
- 'data*/**'
push:
paths:
- 'data*/**'
jobs:
lua-formatter:
runs-on: ubuntu-latest
Expand All @@ -20,16 +24,18 @@ jobs:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Run EmmyLuaCodeStyle
if: ${{ github.ref != 'refs/heads/main' }}
run: >
curl -L -o /tmp/linux-x64.tar.gz https://github.com/CppCXY/EmmyLuaCodeStyle/releases/download/1.3.1/linux-x64.tar.gz && tar -xzf /tmp/linux-x64.tar.gz -C /tmp && /tmp/linux-x64/bin/CodeFormat format -c .editorconfig -w .
- uses: JohnnyMorganz/stylua-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
args: .

- name: Run add and commit
if: ${{ github.ref != 'refs/heads/main' }}
uses: EndBug/add-and-commit@v9
with:
author_name: GitHub Actions
author_email: github-actions[bot]@users.noreply.github.com
message: "Lua code format - (EmmyLuaCodeStyle)"
message: "Lua code format - (Stylua)"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .luarc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"workspace.maxPreload": 10000
}
16 changes: 15 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
},
"BUILD_STATIC_LIBRARY": "ON",
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"OPTIONS_ENABLE_CCACHE": "ON"
"OPTIONS_ENABLE_CCACHE": "ON",
"RUN_TESTS_AFTER_BUILD": "OFF"
},
"condition": {
"type": "equals",
Expand Down Expand Up @@ -102,6 +103,15 @@
"SPEED_UP_BUILD_UNITY": "OFF",
"ASAN_ENABLED": "ON"
}
},
{
"name": "linux-test",
"inherits": "linux-release",
"displayName": "Linux - Test Build",
"description": "Build Tests",
"cacheVariables": {
"BUILD_TESTS": "ON"
}
}
],
"buildPresets": [
Expand All @@ -113,6 +123,10 @@
"name": "linux-debug",
"configurePreset": "linux-debug"
},
{
"name": "linux-test",
"configurePreset": "linux-test"
},
{
"name": "windows-release",
"configurePreset": "windows-release"
Expand Down
231 changes: 122 additions & 109 deletions cmake/modules/CanaryLib.cmake
Original file line number Diff line number Diff line change
@@ -1,109 +1,122 @@
# Define and setup CanaryLib main library target
add_library(${PROJECT_NAME}_lib)
setup_target(${PROJECT_NAME}_lib)

# Add subdirectories
add_subdirectory(account)
add_subdirectory(config)
add_subdirectory(creatures)
add_subdirectory(database)
add_subdirectory(game)
add_subdirectory(io)
add_subdirectory(items)
add_subdirectory(lib)
add_subdirectory(lua)
add_subdirectory(map)
add_subdirectory(security)
add_subdirectory(server)
add_subdirectory(utils)

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

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

# *****************************************************************************
# Build flags - need to be set before the links and sources
# *****************************************************************************
if (CMAKE_COMPILER_IS_GNUCXX)
target_compile_options(${PROJECT_NAME}_lib PRIVATE -Wno-deprecated-declarations)
endif()

# === IPO ===
check_ipo_supported(RESULT result OUTPUT output)
if(result)
set_property(TARGET ${PROJECT_NAME}_lib PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(WARNING "IPO is not supported: ${output}")
endif()

# === UNITY BUILD (compile time reducer) ===
if(SPEED_UP_BUILD_UNITY)
set_target_properties(${PROJECT_NAME}_lib PROPERTIES UNITY_BUILD ON)
log_option_enabled("Build unity for speed up compilation")
endif()

# *****************************************************************************
# Target include directories - to allow #include
# *****************************************************************************
target_include_directories(${PROJECT_NAME}_lib
PUBLIC
${BOOST_DI_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/src
${GMP_INCLUDE_DIRS}
${LUAJIT_INCLUDE_DIRS}
${PARALLEL_HASHMAP_INCLUDE_DIRS}
)

# *****************************************************************************
# Target links to external dependencies
# *****************************************************************************
target_link_libraries(${PROJECT_NAME}_lib
PUBLIC
${GMP_LIBRARIES}
${LUAJIT_LIBRARIES}
CURL::libcurl
ZLIB::ZLIB
absl::any absl::log absl::base absl::bits
asio::asio
eventpp::eventpp
fmt::fmt
magic_enum::magic_enum
mio::mio
protobuf::libprotobuf
pugixml::pugixml
spdlog::spdlog
unofficial::argon2::libargon2
unofficial::libmariadb
unofficial::mariadbclient
)

if(CMAKE_BUILD_TYPE MATCHES Debug)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC ${ZLIB_LIBRARY_DEBUG})
else()
target_link_libraries(${PROJECT_NAME}_lib PUBLIC ${ZLIB_LIBRARY_RELEASE})
endif()

if (MSVC)
if(BUILD_STATIC_LIBRARY)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC jsoncpp_static)
else()
target_link_libraries(${PROJECT_NAME}_lib PUBLIC jsoncpp_lib)
endif()

target_link_libraries(${PROJECT_NAME}_lib PUBLIC ${CMAKE_THREAD_LIBS_INIT} ${MYSQL_CLIENT_LIBS})
else()
target_link_libraries(${PROJECT_NAME}_lib PUBLIC jsoncpp_static Threads::Threads)
endif (MSVC)

# === OpenMP ===
if(OPTIONS_ENABLE_OPENMP)
log_option_enabled("openmp")
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC OpenMP::OpenMP_CXX)
endif()
else()
log_option_disabled("openmp")
endif()
# Define and setup CanaryLib main library target
add_library(${PROJECT_NAME}_lib)
setup_target(${PROJECT_NAME}_lib)

# Add subdirectories
add_subdirectory(account)
add_subdirectory(config)
add_subdirectory(creatures)
add_subdirectory(database)
add_subdirectory(game)
add_subdirectory(io)
add_subdirectory(items)
add_subdirectory(lib)
add_subdirectory(kv)
add_subdirectory(lua)
add_subdirectory(map)
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
)


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

# *****************************************************************************
# Build flags - need to be set before the links and sources
# *****************************************************************************
if (CMAKE_COMPILER_IS_GNUCXX)
target_compile_options(${PROJECT_NAME}_lib PRIVATE -Wno-deprecated-declarations)
endif()

# === IPO ===
check_ipo_supported(RESULT result OUTPUT output)
if(result)
set_property(TARGET ${PROJECT_NAME}_lib PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(WARNING "IPO is not supported: ${output}")
endif()

# === UNITY BUILD (compile time reducer) ===
if(SPEED_UP_BUILD_UNITY)
set_target_properties(${PROJECT_NAME}_lib PROPERTIES UNITY_BUILD ON)
log_option_enabled("Build unity for speed up compilation")
endif()

# *****************************************************************************
# Target include directories - to allow #include
# *****************************************************************************
target_include_directories(${PROJECT_NAME}_lib
PUBLIC
${BOOST_DI_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/src
${GMP_INCLUDE_DIRS}
${LUAJIT_INCLUDE_DIRS}
${PARALLEL_HASHMAP_INCLUDE_DIRS}
)

# *****************************************************************************
# Target links to external dependencies
# *****************************************************************************
target_link_libraries(${PROJECT_NAME}_lib
PUBLIC
${GMP_LIBRARIES}
${LUAJIT_LIBRARIES}
CURL::libcurl
ZLIB::ZLIB
absl::any absl::log absl::base absl::bits
asio::asio
eventpp::eventpp
fmt::fmt
magic_enum::magic_enum
mio::mio
protobuf::libprotobuf
pugixml::pugixml
spdlog::spdlog
unofficial::argon2::libargon2
unofficial::libmariadb
unofficial::mariadbclient
)

if(CMAKE_BUILD_TYPE MATCHES Debug)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC ${ZLIB_LIBRARY_DEBUG})
else()
target_link_libraries(${PROJECT_NAME}_lib PUBLIC ${ZLIB_LIBRARY_RELEASE})
endif()

if (MSVC)
if(BUILD_STATIC_LIBRARY)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC jsoncpp_static)
else()
target_link_libraries(${PROJECT_NAME}_lib PUBLIC jsoncpp_lib)
endif()

target_link_libraries(${PROJECT_NAME}_lib PUBLIC ${CMAKE_THREAD_LIBS_INIT} ${MYSQL_CLIENT_LIBS})
else()
target_link_libraries(${PROJECT_NAME}_lib PUBLIC jsoncpp_static Threads::Threads)
endif (MSVC)

# === OpenMP ===
if(OPTIONS_ENABLE_OPENMP)
log_option_enabled("openmp")
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC OpenMP::OpenMP_CXX)
endif()
else()
log_option_disabled("openmp")
endif()
3 changes: 2 additions & 1 deletion config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ redSkullDuration = 1
blackSkullDuration = 3
orangeSkullDuration = 7

onlyInvitedCanMoveHouseItems = true
cleanProtectionZones = false

-- Connection Config
Expand Down Expand Up @@ -270,6 +269,8 @@ houseRentPeriod = "never"
houseRentRate = 1.0
houseOwnedByAccount = false
houseBuyLevel = 100
housePurchasedShowPrice = false
onlyInvitedCanMoveHouseItems = true

-- Item Usage
timeBetweenActions = 200
Expand Down
6 changes: 3 additions & 3 deletions data-canary/lib/core/load.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dofile(DATA_DIRECTORY .. '/lib/core/storages.lua')
dofile(DATA_DIRECTORY .. '/lib/core/constants.lua')
dofile(DATA_DIRECTORY .. '/lib/core/quests.lua')
dofile(DATA_DIRECTORY .. "/lib/core/storages.lua")
dofile(DATA_DIRECTORY .. "/lib/core/constants.lua")
dofile(DATA_DIRECTORY .. "/lib/core/quests.lua")
8 changes: 4 additions & 4 deletions data-canary/lib/core/quests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ if not Quests then
missionId = 1,
startValue = 1,
endValue = 1,
description = "You broke the first seal."
}
}
}
description = "You broke the first seal.",
},
},
},
}
end
15 changes: 7 additions & 8 deletions data-canary/lib/core/storages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ Reserved player action storage key ranges (const.hpp)
Storage = {
Quest = {
Key = {
ID1000 = 103
ID1000 = 103,
},
ExampleQuest = {
Example = 9000,
Door = 9001
}
Door = 9001,
},
},

DelayLargeSeaShell = 30002,
Promotion = 30003,
Imbuement = 30004
Imbuement = 30004,
}

GlobalStorage = {
ExampleQuest = {
Example = 60000
}
Example = 60000,
},
}

-- Values extraction function
Expand All @@ -64,8 +64,7 @@ table.sort(extraction) -- Sort the table
if #extraction > 1 then
for i = 1, #extraction - 1 do
if extraction[i] == extraction[i + 1] then
logger.warn("Duplicate storage value found: {}",
extraction[i])
logger.warn("Duplicate storage value found: {}", extraction[i])
end
end
end
2 changes: 1 addition & 1 deletion data-canary/lib/lib.lua
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
-- Core API functions implemented in Lua
dofile(DATA_DIRECTORY .. '/lib/core/load.lua')
dofile(DATA_DIRECTORY .. "/lib/core/load.lua")
Loading

0 comments on commit f64cb2f

Please sign in to comment.