From e938b75c9e37c0d0b45f83738f86abc7f56dd33a Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Sun, 29 Sep 2024 14:57:41 -0300 Subject: [PATCH] fix: circular inclusion related to network/protocol/connection (#2924) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug Fixes and Improvements • Fixed a minor bug in the unit test. • Improved the tests build and run scripts. • Removed all redundant pch.hpp includes from the .cpp files as the directive ```target_precompile_headers(${PROJECT_NAME}_lib PUBLIC pch.hpp)``` now handles that automatically. • Added the precompiled file correctly in the visual studio solution • Resolved several circular dependencies involving the following components: - Connection - KV - Protocol --- CMakeLists.txt | 2 +- cmake/modules/CanaryLib.cmake | 4 +- src/account/account.cpp | 2 - src/account/account_repository.cpp | 2 - src/account/account_repository_db.cpp | 2 - src/canary_server.cpp | 2 - src/config/configmanager.cpp | 2 - src/creatures/appearance/mounts/mounts.cpp | 2 - src/creatures/appearance/outfit/outfit.cpp | 2 - src/creatures/combat/combat.cpp | 2 - src/creatures/combat/condition.cpp | 2 - src/creatures/combat/spells.cpp | 2 - src/creatures/creature.cpp | 2 - src/creatures/interactions/chat.cpp | 2 - src/creatures/monsters/monster.cpp | 2 - src/creatures/monsters/monsters.cpp | 2 - .../monsters/spawns/spawn_monster.cpp | 2 - src/creatures/npcs/npc.cpp | 2 - src/creatures/npcs/npcs.cpp | 2 - src/creatures/npcs/spawns/spawn_npc.cpp | 2 - .../achievement/player_achievement.cpp | 2 - .../players/cyclopedia/player_badge.cpp | 2 - .../players/cyclopedia/player_cyclopedia.cpp | 2 - .../players/cyclopedia/player_title.cpp | 2 - src/creatures/players/grouping/familiars.cpp | 2 - src/creatures/players/grouping/groups.cpp | 2 - src/creatures/players/grouping/guild.cpp | 2 - src/creatures/players/grouping/party.cpp | 2 - .../players/imbuements/imbuements.cpp | 1 - src/creatures/players/management/ban.cpp | 2 - src/creatures/players/management/waitlist.cpp | 2 - src/creatures/players/player.cpp | 6 +- src/creatures/players/storages/storages.cpp | 2 - src/creatures/players/vip/player_vip.cpp | 2 - src/creatures/players/vocations/vocation.cpp | 2 - src/creatures/players/wheel/player_wheel.cpp | 52 +++++- src/creatures/players/wheel/player_wheel.hpp | 53 +----- src/creatures/players/wheel/wheel_gems.cpp | 3 +- src/creatures/players/wheel/wheel_gems.hpp | 159 +--------------- src/database/database.cpp | 2 - src/database/databasemanager.cpp | 2 - src/database/databasetasks.cpp | 2 - src/enums/player_wheel.hpp | 171 ++++++++++++++++++ src/game/bank/bank.cpp | 2 - src/game/functions/game_reload.cpp | 2 - src/game/game.cpp | 2 - src/game/movement/position.cpp | 2 - src/game/movement/teleport.cpp | 2 - src/game/scheduling/dispatcher.cpp | 2 - src/game/scheduling/events_scheduler.cpp | 2 - src/game/scheduling/save_manager.cpp | 13 +- src/game/scheduling/save_manager.hpp | 7 +- src/game/scheduling/task.cpp | 2 - src/game/zones/zone.cpp | 2 - src/io/fileloader.cpp | 2 - src/io/filestream.cpp | 2 - src/io/functions/iologindata_load_player.cpp | 6 +- src/io/functions/iologindata_save_player.cpp | 2 - src/io/io_bosstiary.cpp | 2 - src/io/io_wheel.cpp | 4 +- src/io/iobestiary.cpp | 2 - src/io/ioguild.cpp | 2 - src/io/iologindata.cpp | 2 - src/io/iomap.cpp | 1 - src/io/iomapserialize.cpp | 2 - src/io/iomarket.cpp | 2 - src/io/ioprey.cpp | 16 +- src/io/ioprey.hpp | 16 +- src/items/bed.cpp | 2 - src/items/containers/container.cpp | 2 - src/items/containers/depot/depotchest.cpp | 2 - src/items/containers/depot/depotlocker.cpp | 2 - src/items/containers/inbox/inbox.cpp | 2 - src/items/containers/mailbox/mailbox.cpp | 2 - src/items/containers/rewards/reward.cpp | 2 - src/items/containers/rewards/rewardchest.cpp | 2 - src/items/cylinder.cpp | 2 - src/items/decay/decay.cpp | 2 - src/items/functions/item/attribute.cpp | 2 - src/items/functions/item/custom_attribute.cpp | 2 - src/items/functions/item/item_parse.cpp | 2 - src/items/item.cpp | 2 - src/items/items.cpp | 2 - src/items/thing.cpp | 2 - src/items/tile.cpp | 2 - src/items/tile.hpp | 2 +- src/items/trashholder.cpp | 2 - src/items/weapons/weapons.cpp | 2 - src/kv/kv.cpp | 4 +- src/kv/kv_definitions.hpp | 29 +++ src/kv/kv_sql.cpp | 14 +- src/kv/kv_sql.hpp | 16 +- src/kv/value_wrapper.cpp | 2 - src/kv/value_wrapper.hpp | 11 +- src/kv/value_wrapper_proto.cpp | 2 - src/lib/di/soft_singleton.cpp | 1 - src/lib/logging/log_with_spd_log.cpp | 1 - src/lib/thread/thread_pool.cpp | 2 - src/lua/callbacks/event_callback.cpp | 2 - src/lua/callbacks/events_callbacks.cpp | 2 - src/lua/creature/actions.cpp | 2 - src/lua/creature/creatureevent.cpp | 2 - src/lua/creature/events.cpp | 2 - src/lua/creature/movement.cpp | 2 - src/lua/creature/raids.cpp | 2 - src/lua/creature/talkaction.cpp | 2 - .../functions/core/game/bank_functions.cpp | 10 +- .../functions/core/game/config_functions.cpp | 2 - .../functions/core/game/game_functions.cpp | 2 - .../functions/core/game/global_functions.cpp | 2 - src/lua/functions/core/game/lua_enums.cpp | 2 - .../core/game/modal_window_functions.cpp | 2 - .../functions/core/game/zone_functions.cpp | 10 +- src/lua/functions/core/libs/bit_functions.cpp | 2 - src/lua/functions/core/libs/db_functions.cpp | 2 - src/lua/functions/core/libs/kv_functions.cpp | 2 - .../functions/core/libs/logger_functions.cpp | 2 - .../functions/core/libs/metrics_functions.cpp | 2 - .../functions/core/libs/result_functions.cpp | 2 - .../network/network_message_functions.cpp | 2 - .../core/network/webhook_functions.cpp | 2 - .../creatures/combat/combat_functions.cpp | 2 - .../creatures/combat/condition_functions.cpp | 2 - .../creatures/combat/spell_functions.cpp | 2 - .../creatures/combat/variant_functions.cpp | 2 - .../creatures/creature_functions.cpp | 2 - .../creatures/monster/charm_functions.cpp | 2 - .../creatures/monster/loot_functions.cpp | 2 - .../creatures/monster/monster_functions.cpp | 2 - .../monster/monster_spell_functions.cpp | 2 - .../monster/monster_type_functions.cpp | 2 - .../functions/creatures/npc/npc_functions.cpp | 2 - .../creatures/npc/npc_type_functions.cpp | 2 - .../creatures/npc/shop_functions.cpp | 2 - .../creatures/player/group_functions.cpp | 2 - .../creatures/player/guild_functions.cpp | 2 - .../creatures/player/mount_functions.cpp | 2 - .../creatures/player/party_functions.cpp | 2 - .../creatures/player/player_functions.cpp | 2 - .../creatures/player/vocation_functions.cpp | 2 - src/lua/functions/events/action_functions.cpp | 2 - .../events/creature_event_functions.cpp | 2 - .../events/event_callback_functions.cpp | 2 - .../events/events_scheduler_functions.cpp | 2 - .../events/global_event_functions.cpp | 2 - .../functions/events/move_event_functions.cpp | 2 - .../events/talk_action_functions.cpp | 2 - .../functions/items/container_functions.cpp | 2 - .../functions/items/imbuement_functions.cpp | 2 - .../items/item_classification_functions.cpp | 2 - src/lua/functions/items/item_functions.cpp | 2 - .../functions/items/item_type_functions.cpp | 2 - src/lua/functions/items/weapon_functions.cpp | 2 - src/lua/functions/lua_functions_loader.cpp | 2 - src/lua/functions/map/house_functions.cpp | 2 - src/lua/functions/map/position_functions.cpp | 2 - src/lua/functions/map/teleport_functions.cpp | 2 - src/lua/functions/map/tile_functions.cpp | 2 - src/lua/functions/map/town_functions.cpp | 2 - src/lua/global/baseevents.cpp | 2 - src/lua/global/globalevent.cpp | 2 - src/lua/modules/modules.cpp | 2 - src/lua/scripts/lua_environment.cpp | 2 - src/lua/scripts/luascript.cpp | 2 - src/lua/scripts/script_environment.cpp | 2 - src/lua/scripts/scripts.cpp | 2 - src/main.cpp | 1 - src/map/house/house.cpp | 2 - src/map/house/housetile.cpp | 2 - src/map/map.cpp | 2 - src/map/mapcache.cpp | 2 - src/map/spectators.cpp | 2 - src/map/utils/astarnodes.cpp | 2 - src/map/utils/mapsector.cpp | 2 - src/pch.cpp | 11 ++ src/security/argon.cpp | 2 - src/security/rsa.cpp | 2 - src/server/network/connection/connection.cpp | 46 +++-- src/server/network/connection/connection.hpp | 11 +- src/server/network/message/networkmessage.cpp | 2 - src/server/network/message/outputmessage.cpp | 8 +- src/server/network/message/outputmessage.hpp | 4 +- src/server/network/protocol/protocol.cpp | 65 +++++-- src/server/network/protocol/protocol.hpp | 52 ++---- src/server/network/protocol/protocolgame.cpp | 4 +- src/server/network/protocol/protocolgame.hpp | 2 +- src/server/network/protocol/protocollogin.cpp | 2 - .../network/protocol/protocolstatus.cpp | 2 - src/server/network/webhook/webhook.cpp | 2 - src/server/server.cpp | 2 - src/server/server_definitions.hpp | 2 + src/server/signals.cpp | 2 - src/utils/pugicast.cpp | 2 +- src/utils/tools.cpp | 2 - src/utils/wildcardtree.cpp | 2 - tests/build_and_run.sh | 14 +- tests/integration/main.cpp | 1 + vcproj/canary.vcxproj | 11 +- 198 files changed, 486 insertions(+), 674 deletions(-) create mode 100644 src/enums/player_wheel.hpp create mode 100644 src/kv/kv_definitions.hpp create mode 100644 src/pch.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d5853366d80..5bee518ecd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,6 +125,6 @@ option(RUN_TESTS_AFTER_BUILD "Run tests when building" OFF) # By default, tests # ***************************************************************************** add_subdirectory(src) -if(BUILD_TESTS) +if(BUILD_TESTS OR PACKAGE_TESTS) add_subdirectory(tests) endif() diff --git a/cmake/modules/CanaryLib.cmake b/cmake/modules/CanaryLib.cmake index a3f5410b9d8..84d1c96c214 100644 --- a/cmake/modules/CanaryLib.cmake +++ b/cmake/modules/CanaryLib.cmake @@ -23,9 +23,7 @@ add_subdirectory(utils) target_sources(${PROJECT_NAME}_lib PRIVATE canary_server.cpp) # Add public pre compiler header to lib, to pass down to related targets -if (NOT SPEED_UP_BUILD_UNITY) - target_precompile_headers(${PROJECT_NAME}_lib PUBLIC pch.hpp) -endif() +target_precompile_headers(${PROJECT_NAME}_lib PUBLIC pch.hpp) if(NOT SPEED_UP_BUILD_UNITY AND USE_PRECOMPILED_HEADERS) target_compile_definitions(${PROJECT_NAME}_lib PUBLIC -DUSE_PRECOMPILED_HEADERS) diff --git a/src/account/account.cpp b/src/account/account.cpp index 2e5f58dd864..8b67c09ebca 100644 --- a/src/account/account.cpp +++ b/src/account/account.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "account/account.hpp" #include "account/account_repository_db.hpp" diff --git a/src/account/account_repository.cpp b/src/account/account_repository.cpp index babca847043..f329825645d 100644 --- a/src/account/account_repository.cpp +++ b/src/account/account_repository.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "account/account_repository.hpp" #include "lib/di/container.hpp" diff --git a/src/account/account_repository_db.cpp b/src/account/account_repository_db.cpp index 81da30c08c5..a6d169ef4af 100644 --- a/src/account/account_repository_db.cpp +++ b/src/account/account_repository_db.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "account/account_repository_db.hpp" #include "database/database.hpp" diff --git a/src/canary_server.cpp b/src/canary_server.cpp index f71fc71ba9a..f46d34f7104 100644 --- a/src/canary_server.cpp +++ b/src/canary_server.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "canary_server.hpp" #include "declarations.hpp" diff --git a/src/config/configmanager.cpp b/src/config/configmanager.cpp index 9ce861665de..1d0138483a9 100644 --- a/src/config/configmanager.cpp +++ b/src/config/configmanager.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "config/configmanager.hpp" #include "lib/di/container.hpp" #include "game/game.hpp" diff --git a/src/creatures/appearance/mounts/mounts.cpp b/src/creatures/appearance/mounts/mounts.cpp index 7014d0b026b..ada9fb1c4ff 100644 --- a/src/creatures/appearance/mounts/mounts.cpp +++ b/src/creatures/appearance/mounts/mounts.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/appearance/mounts/mounts.hpp" #include "game/game.hpp" #include "utils/pugicast.hpp" diff --git a/src/creatures/appearance/outfit/outfit.cpp b/src/creatures/appearance/outfit/outfit.cpp index 251bf7bde35..40c28a1d7bb 100644 --- a/src/creatures/appearance/outfit/outfit.cpp +++ b/src/creatures/appearance/outfit/outfit.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/appearance/outfit/outfit.hpp" #include "utils/pugicast.hpp" #include "utils/tools.hpp" diff --git a/src/creatures/combat/combat.cpp b/src/creatures/combat/combat.cpp index d65d10e4e6f..4920e8cdc4e 100644 --- a/src/creatures/combat/combat.cpp +++ b/src/creatures/combat/combat.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "declarations.hpp" #include "creatures/combat/combat.hpp" #include "lua/creature/events.hpp" diff --git a/src/creatures/combat/condition.cpp b/src/creatures/combat/condition.cpp index b308c05a5bc..f07126ed868 100644 --- a/src/creatures/combat/condition.cpp +++ b/src/creatures/combat/condition.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/combat/condition.hpp" #include "game/game.hpp" #include "game/scheduling/dispatcher.hpp" diff --git a/src/creatures/combat/spells.cpp b/src/creatures/combat/spells.cpp index 105bf734c23..263d7041887 100644 --- a/src/creatures/combat/spells.cpp +++ b/src/creatures/combat/spells.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/combat/combat.hpp" #include "creatures/combat/spells.hpp" #include "creatures/monsters/monster.hpp" diff --git a/src/creatures/creature.cpp b/src/creatures/creature.cpp index 56ed1770039..438355cbf07 100644 --- a/src/creatures/creature.cpp +++ b/src/creatures/creature.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/creature.hpp" #include "declarations.hpp" #include "game/scheduling/dispatcher.hpp" diff --git a/src/creatures/interactions/chat.cpp b/src/creatures/interactions/chat.cpp index 900247e457a..84f4dd67e23 100644 --- a/src/creatures/interactions/chat.cpp +++ b/src/creatures/interactions/chat.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/interactions/chat.hpp" #include "game/game.hpp" #include "utils/pugicast.hpp" diff --git a/src/creatures/monsters/monster.cpp b/src/creatures/monsters/monster.cpp index 4a6d07fe8d7..1db78747947 100644 --- a/src/creatures/monsters/monster.cpp +++ b/src/creatures/monsters/monster.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/monsters/monster.hpp" #include "creatures/combat/spells.hpp" #include "creatures/players/wheel/player_wheel.hpp" diff --git a/src/creatures/monsters/monsters.cpp b/src/creatures/monsters/monsters.cpp index 7e192a79575..9a1c2b70634 100644 --- a/src/creatures/monsters/monsters.cpp +++ b/src/creatures/monsters/monsters.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/monsters/monsters.hpp" #include "creatures/combat/spells.hpp" diff --git a/src/creatures/monsters/spawns/spawn_monster.cpp b/src/creatures/monsters/spawns/spawn_monster.cpp index 93b381da061..828549e7153 100644 --- a/src/creatures/monsters/spawns/spawn_monster.cpp +++ b/src/creatures/monsters/spawns/spawn_monster.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/monsters/spawns/spawn_monster.hpp" #include "game/game.hpp" #include "creatures/monsters/monster.hpp" diff --git a/src/creatures/npcs/npc.cpp b/src/creatures/npcs/npc.cpp index 05f22780ada..4a767dee320 100644 --- a/src/creatures/npcs/npc.cpp +++ b/src/creatures/npcs/npc.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/npcs/npc.hpp" #include "creatures/npcs/npcs.hpp" #include "declarations.hpp" diff --git a/src/creatures/npcs/npcs.cpp b/src/creatures/npcs/npcs.cpp index 6fe7f0b8320..05fc48a63d8 100644 --- a/src/creatures/npcs/npcs.cpp +++ b/src/creatures/npcs/npcs.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "declarations.hpp" #include "creatures/combat/combat.hpp" #include "lua/scripts/lua_environment.hpp" diff --git a/src/creatures/npcs/spawns/spawn_npc.cpp b/src/creatures/npcs/spawns/spawn_npc.cpp index 694822c2386..0976e96b68f 100644 --- a/src/creatures/npcs/spawns/spawn_npc.cpp +++ b/src/creatures/npcs/spawns/spawn_npc.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/npcs/spawns/spawn_npc.hpp" #include "creatures/npcs/npc.hpp" #include "game/game.hpp" diff --git a/src/creatures/players/achievement/player_achievement.cpp b/src/creatures/players/achievement/player_achievement.cpp index cd0735ab54c..5a9c1f55858 100644 --- a/src/creatures/players/achievement/player_achievement.cpp +++ b/src/creatures/players/achievement/player_achievement.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "player_achievement.hpp" #include "creatures/players/player.hpp" diff --git a/src/creatures/players/cyclopedia/player_badge.cpp b/src/creatures/players/cyclopedia/player_badge.cpp index 5f78c1a2e3c..c19e2443db1 100644 --- a/src/creatures/players/cyclopedia/player_badge.cpp +++ b/src/creatures/players/cyclopedia/player_badge.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "player_badge.hpp" #include "creatures/players/player.hpp" diff --git a/src/creatures/players/cyclopedia/player_cyclopedia.cpp b/src/creatures/players/cyclopedia/player_cyclopedia.cpp index eb7e05d2338..de34e1d8250 100644 --- a/src/creatures/players/cyclopedia/player_cyclopedia.cpp +++ b/src/creatures/players/cyclopedia/player_cyclopedia.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "player_cyclopedia.hpp" #include "database/databasetasks.hpp" diff --git a/src/creatures/players/cyclopedia/player_title.cpp b/src/creatures/players/cyclopedia/player_title.cpp index 7c348cbf79d..38e4e6428d0 100644 --- a/src/creatures/players/cyclopedia/player_title.cpp +++ b/src/creatures/players/cyclopedia/player_title.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "player_title.hpp" #include "creatures/players/player.hpp" diff --git a/src/creatures/players/grouping/familiars.cpp b/src/creatures/players/grouping/familiars.cpp index 6312aaa285d..1e09fd5cd7f 100644 --- a/src/creatures/players/grouping/familiars.cpp +++ b/src/creatures/players/grouping/familiars.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/players/grouping/familiars.hpp" #include "lib/di/container.hpp" #include "config/configmanager.hpp" diff --git a/src/creatures/players/grouping/groups.cpp b/src/creatures/players/grouping/groups.cpp index c4dab4a9039..189d2ecc165 100644 --- a/src/creatures/players/grouping/groups.cpp +++ b/src/creatures/players/grouping/groups.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "config/configmanager.hpp" #include "game/game.hpp" #include "creatures/players/grouping/groups.hpp" diff --git a/src/creatures/players/grouping/guild.cpp b/src/creatures/players/grouping/guild.cpp index bbd662d1a1d..240593c1047 100644 --- a/src/creatures/players/grouping/guild.cpp +++ b/src/creatures/players/grouping/guild.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/players/grouping/guild.hpp" #include "game/game.hpp" diff --git a/src/creatures/players/grouping/party.cpp b/src/creatures/players/grouping/party.cpp index b56e0c68605..067a1acd399 100644 --- a/src/creatures/players/grouping/party.cpp +++ b/src/creatures/players/grouping/party.cpp @@ -9,8 +9,6 @@ #include -#include "pch.hpp" - #include "creatures/players/grouping/party.hpp" #include "game/game.hpp" #include "lua/creature/events.hpp" diff --git a/src/creatures/players/imbuements/imbuements.cpp b/src/creatures/players/imbuements/imbuements.cpp index 4bfb0de836b..069a77475e2 100644 --- a/src/creatures/players/imbuements/imbuements.cpp +++ b/src/creatures/players/imbuements/imbuements.cpp @@ -7,7 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" #include "creatures/players/imbuements/imbuements.hpp" #include "lua/creature/events.hpp" #include "utils/pugicast.hpp" diff --git a/src/creatures/players/management/ban.cpp b/src/creatures/players/management/ban.cpp index d81045c5344..748b784a77a 100644 --- a/src/creatures/players/management/ban.cpp +++ b/src/creatures/players/management/ban.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/players/management/ban.hpp" #include "database/database.hpp" #include "database/databasetasks.hpp" diff --git a/src/creatures/players/management/waitlist.cpp b/src/creatures/players/management/waitlist.cpp index 345c20f2650..f20843ea248 100644 --- a/src/creatures/players/management/waitlist.cpp +++ b/src/creatures/players/management/waitlist.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/players/management/waitlist.hpp" #include "game/game.hpp" diff --git a/src/creatures/players/player.cpp b/src/creatures/players/player.cpp index e3790583eff..6f5ed27d079 100644 --- a/src/creatures/players/player.cpp +++ b/src/creatures/players/player.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/combat/combat.hpp" #include "creatures/interactions/chat.hpp" #include "creatures/monsters/monster.hpp" @@ -6206,7 +6204,9 @@ void Player::sendIcons() { // Remove the last icon so that Bakragore's is added auto iconSet = getClientIcons(); if (iconSet.size() >= 9 && iconBakragore != IconBakragore::None) { - iconSet.erase(std::prev(iconSet.end())); + std::vector tempVector(iconSet.begin(), iconSet.end()); + tempVector.pop_back(); + iconSet = std::unordered_set(tempVector.begin(), tempVector.end()); } client->sendIcons(iconSet, iconBakragore); diff --git a/src/creatures/players/storages/storages.cpp b/src/creatures/players/storages/storages.cpp index 7fe925ce9e3..8f53bff0cec 100644 --- a/src/creatures/players/storages/storages.cpp +++ b/src/creatures/players/storages/storages.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/players/storages/storages.hpp" #include "config/configmanager.hpp" diff --git a/src/creatures/players/vip/player_vip.cpp b/src/creatures/players/vip/player_vip.cpp index 95ebe91ad5f..9d7bb7c27c7 100644 --- a/src/creatures/players/vip/player_vip.cpp +++ b/src/creatures/players/vip/player_vip.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/players/vip/player_vip.hpp" #include "io/iologindata.hpp" diff --git a/src/creatures/players/vocations/vocation.cpp b/src/creatures/players/vocations/vocation.cpp index 6fec2725164..3da025f7b4a 100644 --- a/src/creatures/players/vocations/vocation.cpp +++ b/src/creatures/players/vocations/vocation.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/players/vocations/vocation.hpp" #include "utils/pugicast.hpp" diff --git a/src/creatures/players/wheel/player_wheel.cpp b/src/creatures/players/wheel/player_wheel.cpp index b78f136312b..6500420adfc 100644 --- a/src/creatures/players/wheel/player_wheel.cpp +++ b/src/creatures/players/wheel/player_wheel.cpp @@ -7,17 +7,16 @@ * Website: https://docs.opentibiabr.org/ */ -#include "pch.hpp" - #include "creatures/players/wheel/player_wheel.hpp" +#include "config/configmanager.hpp" #include "io/io_wheel.hpp" - #include "game/game.hpp" +#include "server/network/message/networkmessage.hpp" #include "creatures/players/player.hpp" #include "creatures/combat/spells.hpp" - -#include "config/configmanager.hpp" +#include "kv/kv.hpp" +#include "creatures/players/wheel/wheel_gems.hpp" const static std::vector wheelGemBasicSlot1Allowed = { WheelGemBasicModifier_t::General_FireResistance, @@ -3151,3 +3150,46 @@ WheelGemBasicModifier_t PlayerWheel::selectBasicModifier2(WheelGemBasicModifier_ } return modifier; } + +void PlayerWheelGem::save(const std::shared_ptr &kv) const { + kv->scoped("revealed")->set(uuid, serialize()); +} +void PlayerWheelGem::remove(const std::shared_ptr &kv) const { + kv->scoped("revealed")->remove(uuid); +} + +PlayerWheelGem PlayerWheelGem::load(const std::shared_ptr &kv, const std::string &uuid) { + auto val = kv->scoped("revealed")->get(uuid); + if (!val || !val.has_value()) { + return {}; + } + return deserialize(uuid, val.value()); +} + +ValueWrapper PlayerWheelGem::serialize() const { + return { + { "uuid", uuid }, + { "locked", locked }, + { "affinity", static_cast(affinity) }, + { "quality", static_cast(quality) }, + { "basicModifier1", static_cast(basicModifier1) }, + { "basicModifier2", static_cast(basicModifier2) }, + { "supremeModifier", static_cast(supremeModifier) } + }; +} + +PlayerWheelGem PlayerWheelGem::deserialize(const std::string &uuid, const ValueWrapper &val) { + auto map = val.get(); + if (map.empty()) { + return {}; + } + return { + uuid, + map["locked"]->get(), + static_cast(map["affinity"]->get()), + static_cast(map["quality"]->get()), + static_cast(map["basicModifier1"]->get()), + static_cast(map["basicModifier2"]->get()), + static_cast(map["supremeModifier"]->get()) + }; +} diff --git a/src/creatures/players/wheel/player_wheel.hpp b/src/creatures/players/wheel/player_wheel.hpp index e94f605930c..b01b1c5a1b3 100644 --- a/src/creatures/players/wheel/player_wheel.hpp +++ b/src/creatures/players/wheel/player_wheel.hpp @@ -9,16 +9,17 @@ #pragma once -#include "io/io_wheel.hpp" #include "utils/utils_definitions.hpp" -#include "kv/kv.hpp" -#include "wheel_gems.hpp" +#include "enums/player_wheel.hpp" +#include "creatures/players/wheel/wheel_definitions.hpp" +#include "kv/kv_definitions.hpp" class Spell; class Player; class Creature; class NetworkMessage; -class IOWheel; +class KV; +class WheelModifierContext; struct PlayerWheelGem { std::string uuid; @@ -33,50 +34,16 @@ struct PlayerWheelGem { return fmt::format("[PlayerWheelGem] uuid: {}, locked: {}, affinity: {}, quality: {}, basicModifier1: {}, basicModifier2: {}, supremeModifier: {}", uuid, locked, static_cast(affinity), static_cast(quality), static_cast(basicModifier1), static_cast(basicModifier2), static_cast(supremeModifier)); } - void save(const std::shared_ptr &kv) const { - kv->scoped("revealed")->set(uuid, serialize()); - } + void save(const std::shared_ptr &kv) const; - void remove(const std::shared_ptr &kv) const { - kv->scoped("revealed")->remove(uuid); - } + void remove(const std::shared_ptr &kv) const; - static PlayerWheelGem load(const std::shared_ptr &kv, const std::string &uuid) { - auto val = kv->scoped("revealed")->get(uuid); - if (!val || !val.has_value()) { - return {}; - } - return deserialize(uuid, val.value()); - } + static PlayerWheelGem load(const std::shared_ptr &kv, const std::string &uuid); private: - ValueWrapper serialize() const { - return { - { "uuid", uuid }, - { "locked", locked }, - { "affinity", static_cast(affinity) }, - { "quality", static_cast(quality) }, - { "basicModifier1", static_cast(basicModifier1) }, - { "basicModifier2", static_cast(basicModifier2) }, - { "supremeModifier", static_cast(supremeModifier) } - }; - } + ValueWrapper serialize() const; - static PlayerWheelGem deserialize(const std::string &uuid, const ValueWrapper &val) { - auto map = val.get(); - if (map.empty()) { - return {}; - } - return { - uuid, - map["locked"]->get(), - static_cast(map["affinity"]->get()), - static_cast(map["quality"]->get()), - static_cast(map["basicModifier1"]->get()), - static_cast(map["basicModifier2"]->get()), - static_cast(map["supremeModifier"]->get()) - }; - } + static PlayerWheelGem deserialize(const std::string &uuid, const ValueWrapper &val); }; class PlayerWheel { diff --git a/src/creatures/players/wheel/wheel_gems.cpp b/src/creatures/players/wheel/wheel_gems.cpp index c3653298c12..186a6939186 100644 --- a/src/creatures/players/wheel/wheel_gems.cpp +++ b/src/creatures/players/wheel/wheel_gems.cpp @@ -7,9 +7,10 @@ * Website: https://docs.opentibiabr.org/ */ -#include "pch.hpp" +#include "creatures/players/wheel/wheel_gems.hpp" #include "creatures/players/wheel/player_wheel.hpp" +#include "enums/player_wheel.hpp" void GemModifierResistanceStrategy::execute() { m_wheel.addResistance(m_combatType, m_resistance); diff --git a/src/creatures/players/wheel/wheel_gems.hpp b/src/creatures/players/wheel/wheel_gems.hpp index 668d8fe05db..dc691fa2b26 100644 --- a/src/creatures/players/wheel/wheel_gems.hpp +++ b/src/creatures/players/wheel/wheel_gems.hpp @@ -9,167 +9,12 @@ #pragma once +#include "creatures/creatures_definitions.hpp" #include "wheel_definitions.hpp" +#include "enums/player_wheel.hpp" class PlayerWheel; -enum class WheelGemAction_t : uint8_t { - Destroy, - Reveal, - SwitchDomain, - ToggleLock, -}; - -enum class WheelGemAffinity_t : uint8_t { - Green, - Red, - Blue, - Purple, -}; - -enum class WheelGemQuality_t : uint8_t { - Lesser, - Regular, - Greater, -}; - -enum class WheelGemBasicModifier_t : uint8_t { - General_PhysicalResistance, - General_HolyResistance, - General_DeathResistance, - General_FireResistance, - General_EarthResistance, - General_IceResistance, - General_EnergyResistance, - - General_HolyResistance_DeathWeakness, - General_DeathResistance_HolyWeakness, - General_FireResistance_EarthResistance, - General_FireResistance_IceResistance, - General_FireResistance_EnergyResistance, - General_EarthResistance_IceResistance, - General_EarthResistance_EnergyResistance, - General_IceResistance_EnergyResistance, - - General_FireResistance_EarthWeakness, - General_FireResistance_IceWeakness, - General_FireResistance_EnergyWeakness, - General_EarthResistance_FireWeakness, - General_EarthResistance_IceWeakness, - General_EarthResistance_EnergyWeakness, - General_IceResistance_EarthWeakness, - General_IceResistance_FireWeakness, - General_IceResistance_EnergyWeakness, - General_EnergyResistance_EarthWeakness, - General_EnergyResistance_IceWeakness, - General_EnergyResistance_FireWeakness, - General_ManaDrainResistance, - General_LifeDrainResistance, - General_ManaDrainResistance_LifeDrainResistance, - General_MitigationMultiplier, - - Vocation_Health, - Vocation_Capacity, - Vocation_Mana_FireResistance, - Vocation_Mana_EnergyResistance, - Vocation_Mana_Earth_Resistance, - Vocation_Mana_Ice_Resistance, - Vocation_Mana, - Vocation_Health_FireResistance, - Vocation_Health_EnergyResistance, - Vocation_Health_EarthResistance, - Vocation_Health_IceResistance, - Vocation_Mixed, - Vocation_Mixed2, - Vocation_Capacity_FireResistance, - Vocation_Capacity_EnergyResistance, - Vocation_Capacity_EarthResistance, - Vocation_Capacity_IceResistance, -}; - -enum class WheelGemSupremeModifier_t : uint8_t { - General_Dodge, - General_CriticalDamage, - General_LifeLeech, - General_ManaLeech, - SorcererDruid_UltimateHealing, - General_RevelationMastery_GiftOfLife, - - Knight_AvatarOfSteel_Cooldown, - Knight_ExecutionersThrow_Cooldown, - Knight_ExecutionersThrow_DamageIncrease, - Knight_ExecutionersThrow_CriticalExtraDamage, - Knight_Fierce_Berserk_DamageIncrease, - Knight_Fierce_Berserk_CriticalExtraDamage, - Knight_Berserk_DamageIncrease, - Knight_Berserk_CriticalExtraDamage, - Knight_Front_Sweep_CriticalExtraDamage, - Knight_Front_Sweep_DamageIncrease, - Knight_Groundshaker_DamageIncrease, - Knight_Groundshaker_CriticalExtraDamage, - Knight_Annihilation_CriticalExtraDamage, - Knight_Annihilation_DamageIncrease, - Knight_FairWoundCleansing_HealingIncrease, - Knight_RevelationMastery_AvatarOfSteel, - Knight_RevelationMastery_ExecutionersThrow, - Knight_RevelationMastery_CombatMastery, - - Paladin_AvatarOfLight_Cooldown, - Paladin_DivineDazzle_Cooldown, - Paladin_DivineGrenade_DamageIncrease, - Paladin_DivineGrenade_CriticalExtraDamage, - Paladin_DivineCaldera_DamageIncrease, - Paladin_DivineCaldera_CriticalExtraDamage, - Paladin_DivineMissile_DamageIncrease, - Paladin_DivineMissile_CriticalExtraDamage, - Paladin_EtherealSpear_DamageIncrease, - Paladin_EtherealSpear_CriticalExtraDamage, - Paladin_StrongEtherealSpear_DamageIncrease, - Paladin_StrongEtherealSpear_CriticalExtraDamage, - Paladin_DivineEmpowerment_Cooldown, - Paladin_DivineGrenade_Cooldown, - Paladin_Salvation_HealingIncrease, - Paladin_RevelationMastery_AvatarOfLight, - Paladin_RevelationMastery_DivineGrenade, - Paladin_RevelationMastery_DivineEmpowerment, - - Sorcerer_AvatarOfStorm_Cooldown, - Sorcerer_EnergyWave_Cooldown, - Sorcerer_GreatDeathBeam_DamageIncrease, - Sorcerer_GreatDeathBeam_CriticalExtraDamage, - Sorcerer_HellsCore_DamageIncrease, - Sorcerer_HellsCore_CriticalExtraDamage, - Sorcerer_EnergyWave_DamageIncrease, - Sorcerer_EnergyWave_CriticalExtraDamage, - Sorcerer_GreatFireWave_DamageIncrease, - Sorcerer_GreatFireWave_CriticalExtraDamage, - Sorcerer_RageOfTheSkies_DamageIncrease, - Sorcerer_RageOfTheSkies_CriticalExtraDamage, - Sorcerer_GreatEnergyBeam_DamageIncrease, - Sorcerer_GreatEnergyBeam_CriticalExtraDamage, - Sorcerer_RevelationMastery_AvatarOfStorm, - Sorcerer_RevelationMastery_BeamMastery, - Sorcerer_RevelationMastery_DrainBody, - - Druid_AvatarOfNature_Cooldown, - Druid_NaturesEmbrace_Cooldown, - Druid_TerraBurst_DamageIncrease, - Druid_TerraBurst_CriticalExtraDamage, - Druid_IceBurst_DamageIncrease, - Druid_IceBurst_CriticalExtraDamage, - Druid_EternalWinter_CriticalExtraDamage, - Druid_EternalWinter_DamageIncrease, - Druid_TerraWave_DamageIncrease, - Druid_TerraWave_CriticalExtraDamage, - Druid_StrongIceWave_DamageIncrease, - Druid_StrongIceWave_CriticalExtraDamage, - Druid_HealFriend_HealingIncrease, - Druid_MassHealing_HealingIncrease, - Druid_RevelationMastery_AvatarOfNature, - Druid_RevelationMastery_BlessingOfTheGrove, - Druid_RevelationMastery_TwinBursts, -}; - class GemModifierStrategy { public: explicit GemModifierStrategy(PlayerWheel &wheel) : diff --git a/src/database/database.cpp b/src/database/database.cpp index f226587c511..50b795455d3 100644 --- a/src/database/database.cpp +++ b/src/database/database.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "config/configmanager.hpp" #include "database/database.hpp" #include "lib/di/container.hpp" diff --git a/src/database/databasemanager.cpp b/src/database/databasemanager.cpp index dfbb7d9a64a..3e55799e45a 100644 --- a/src/database/databasemanager.cpp +++ b/src/database/databasemanager.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "config/configmanager.hpp" #include "database/databasemanager.hpp" #include "lua/functions/core/libs/core_libs_functions.hpp" diff --git a/src/database/databasetasks.cpp b/src/database/databasetasks.cpp index 8a660f1c031..010b3f16320 100644 --- a/src/database/databasetasks.cpp +++ b/src/database/databasetasks.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "database/databasetasks.hpp" #include "game/scheduling/dispatcher.hpp" #include "lib/thread/thread_pool.hpp" diff --git a/src/enums/player_wheel.hpp b/src/enums/player_wheel.hpp new file mode 100644 index 00000000000..81cde57f651 --- /dev/null +++ b/src/enums/player_wheel.hpp @@ -0,0 +1,171 @@ +/** + * Canary - A free and open-source MMORPG server emulator + * Copyright (©) 2019-2024 OpenTibiaBR + * Repository: https://github.com/opentibiabr/canary + * License: https://github.com/opentibiabr/canary/blob/main/LICENSE + * Contributors: https://github.com/opentibiabr/canary/graphs/contributors + * Website: https://docs.opentibiabr.com/ + */ + +#pragma once + +#ifndef USE_PRECOMPILED_HEADERS + #include +#endif + +enum class WheelGemAction_t : uint8_t { + Destroy, + Reveal, + SwitchDomain, + ToggleLock, +}; + +enum class WheelGemAffinity_t : uint8_t { + Green, + Red, + Blue, + Purple, +}; + +enum class WheelGemQuality_t : uint8_t { + Lesser, + Regular, + Greater, +}; + +enum class WheelGemBasicModifier_t : uint8_t { + General_PhysicalResistance, + General_HolyResistance, + General_DeathResistance, + General_FireResistance, + General_EarthResistance, + General_IceResistance, + General_EnergyResistance, + + General_HolyResistance_DeathWeakness, + General_DeathResistance_HolyWeakness, + General_FireResistance_EarthResistance, + General_FireResistance_IceResistance, + General_FireResistance_EnergyResistance, + General_EarthResistance_IceResistance, + General_EarthResistance_EnergyResistance, + General_IceResistance_EnergyResistance, + + General_FireResistance_EarthWeakness, + General_FireResistance_IceWeakness, + General_FireResistance_EnergyWeakness, + General_EarthResistance_FireWeakness, + General_EarthResistance_IceWeakness, + General_EarthResistance_EnergyWeakness, + General_IceResistance_EarthWeakness, + General_IceResistance_FireWeakness, + General_IceResistance_EnergyWeakness, + General_EnergyResistance_EarthWeakness, + General_EnergyResistance_IceWeakness, + General_EnergyResistance_FireWeakness, + General_ManaDrainResistance, + General_LifeDrainResistance, + General_ManaDrainResistance_LifeDrainResistance, + General_MitigationMultiplier, + + Vocation_Health, + Vocation_Capacity, + Vocation_Mana_FireResistance, + Vocation_Mana_EnergyResistance, + Vocation_Mana_Earth_Resistance, + Vocation_Mana_Ice_Resistance, + Vocation_Mana, + Vocation_Health_FireResistance, + Vocation_Health_EnergyResistance, + Vocation_Health_EarthResistance, + Vocation_Health_IceResistance, + Vocation_Mixed, + Vocation_Mixed2, + Vocation_Capacity_FireResistance, + Vocation_Capacity_EnergyResistance, + Vocation_Capacity_EarthResistance, + Vocation_Capacity_IceResistance, +}; + +enum class WheelGemSupremeModifier_t : uint8_t { + General_Dodge, + General_CriticalDamage, + General_LifeLeech, + General_ManaLeech, + SorcererDruid_UltimateHealing, + General_RevelationMastery_GiftOfLife, + + Knight_AvatarOfSteel_Cooldown, + Knight_ExecutionersThrow_Cooldown, + Knight_ExecutionersThrow_DamageIncrease, + Knight_ExecutionersThrow_CriticalExtraDamage, + Knight_Fierce_Berserk_DamageIncrease, + Knight_Fierce_Berserk_CriticalExtraDamage, + Knight_Berserk_DamageIncrease, + Knight_Berserk_CriticalExtraDamage, + Knight_Front_Sweep_CriticalExtraDamage, + Knight_Front_Sweep_DamageIncrease, + Knight_Groundshaker_DamageIncrease, + Knight_Groundshaker_CriticalExtraDamage, + Knight_Annihilation_CriticalExtraDamage, + Knight_Annihilation_DamageIncrease, + Knight_FairWoundCleansing_HealingIncrease, + Knight_RevelationMastery_AvatarOfSteel, + Knight_RevelationMastery_ExecutionersThrow, + Knight_RevelationMastery_CombatMastery, + + Paladin_AvatarOfLight_Cooldown, + Paladin_DivineDazzle_Cooldown, + Paladin_DivineGrenade_DamageIncrease, + Paladin_DivineGrenade_CriticalExtraDamage, + Paladin_DivineCaldera_DamageIncrease, + Paladin_DivineCaldera_CriticalExtraDamage, + Paladin_DivineMissile_DamageIncrease, + Paladin_DivineMissile_CriticalExtraDamage, + Paladin_EtherealSpear_DamageIncrease, + Paladin_EtherealSpear_CriticalExtraDamage, + Paladin_StrongEtherealSpear_DamageIncrease, + Paladin_StrongEtherealSpear_CriticalExtraDamage, + Paladin_DivineEmpowerment_Cooldown, + Paladin_DivineGrenade_Cooldown, + Paladin_Salvation_HealingIncrease, + Paladin_RevelationMastery_AvatarOfLight, + Paladin_RevelationMastery_DivineGrenade, + Paladin_RevelationMastery_DivineEmpowerment, + + Sorcerer_AvatarOfStorm_Cooldown, + Sorcerer_EnergyWave_Cooldown, + Sorcerer_GreatDeathBeam_DamageIncrease, + Sorcerer_GreatDeathBeam_CriticalExtraDamage, + Sorcerer_HellsCore_DamageIncrease, + Sorcerer_HellsCore_CriticalExtraDamage, + Sorcerer_EnergyWave_DamageIncrease, + Sorcerer_EnergyWave_CriticalExtraDamage, + Sorcerer_GreatFireWave_DamageIncrease, + Sorcerer_GreatFireWave_CriticalExtraDamage, + Sorcerer_RageOfTheSkies_DamageIncrease, + Sorcerer_RageOfTheSkies_CriticalExtraDamage, + Sorcerer_GreatEnergyBeam_DamageIncrease, + Sorcerer_GreatEnergyBeam_CriticalExtraDamage, + Sorcerer_RevelationMastery_AvatarOfStorm, + Sorcerer_RevelationMastery_BeamMastery, + Sorcerer_RevelationMastery_DrainBody, + + Druid_AvatarOfNature_Cooldown, + Druid_NaturesEmbrace_Cooldown, + Druid_TerraBurst_DamageIncrease, + Druid_TerraBurst_CriticalExtraDamage, + Druid_IceBurst_DamageIncrease, + Druid_IceBurst_CriticalExtraDamage, + Druid_EternalWinter_CriticalExtraDamage, + Druid_EternalWinter_DamageIncrease, + Druid_TerraWave_DamageIncrease, + Druid_TerraWave_CriticalExtraDamage, + Druid_StrongIceWave_DamageIncrease, + Druid_StrongIceWave_CriticalExtraDamage, + Druid_HealFriend_HealingIncrease, + Druid_MassHealing_HealingIncrease, + Druid_RevelationMastery_AvatarOfNature, + Druid_RevelationMastery_BlessingOfTheGrove, + Druid_RevelationMastery_TwinBursts, +}; diff --git a/src/game/bank/bank.cpp b/src/game/bank/bank.cpp index 33d97c92ee5..0a876e62210 100644 --- a/src/game/bank/bank.cpp +++ b/src/game/bank/bank.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "bank.hpp" #include "game/game.hpp" #include "creatures/players/player.hpp" diff --git a/src/game/functions/game_reload.cpp b/src/game/functions/game_reload.cpp index d9d9eb1f449..d42f7ec3c78 100644 --- a/src/game/functions/game_reload.cpp +++ b/src/game/functions/game_reload.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/functions/game_reload.hpp" #include "config/configmanager.hpp" diff --git a/src/game/game.cpp b/src/game/game.cpp index 77dffe532f0..381792c3092 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/game.hpp" #include "lua/creature/actions.hpp" diff --git a/src/game/movement/position.cpp b/src/game/movement/position.cpp index 807a65ad458..46ea6ea573d 100644 --- a/src/game/movement/position.cpp +++ b/src/game/movement/position.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/movement/position.hpp" #include "utils/tools.hpp" diff --git a/src/game/movement/teleport.cpp b/src/game/movement/teleport.cpp index 44050100eb6..595fe5f33ca 100644 --- a/src/game/movement/teleport.cpp +++ b/src/game/movement/teleport.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/game.hpp" #include "game/movement/teleport.hpp" diff --git a/src/game/scheduling/dispatcher.cpp b/src/game/scheduling/dispatcher.cpp index eaedaa86ac5..db0aae845a6 100644 --- a/src/game/scheduling/dispatcher.cpp +++ b/src/game/scheduling/dispatcher.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/scheduling/dispatcher.hpp" #include "lib/thread/thread_pool.hpp" #include "lib/di/container.hpp" diff --git a/src/game/scheduling/events_scheduler.cpp b/src/game/scheduling/events_scheduler.cpp index a86254fa35c..3089d9cdcd6 100644 --- a/src/game/scheduling/events_scheduler.cpp +++ b/src/game/scheduling/events_scheduler.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "config/configmanager.hpp" #include "game/scheduling/events_scheduler.hpp" #include "lua/scripts/scripts.hpp" diff --git a/src/game/scheduling/save_manager.cpp b/src/game/scheduling/save_manager.cpp index fbad528598b..4d98da9900f 100644 --- a/src/game/scheduling/save_manager.cpp +++ b/src/game/scheduling/save_manager.cpp @@ -1,8 +1,17 @@ -#include "pch.hpp" +/** + * Canary - A free and open-source MMORPG server emulator + * Copyright (©) 2019-2024 OpenTibiaBR + * Repository: https://github.com/opentibiabr/canary + * License: https://github.com/opentibiabr/canary/blob/main/LICENSE + * Contributors: https://github.com/opentibiabr/canary/graphs/contributors + * Website: https://docs.opentibiabr.com/ + */ -#include "game/game.hpp" #include "game/scheduling/save_manager.hpp" + +#include "game/game.hpp" #include "io/iologindata.hpp" +#include "kv/kv.hpp" SaveManager::SaveManager(ThreadPool &threadPool, KVStore &kvStore, Logger &logger, Game &game) : threadPool(threadPool), kv(kvStore), logger(logger), game(game) { } diff --git a/src/game/scheduling/save_manager.hpp b/src/game/scheduling/save_manager.hpp index 745231c0075..4bd66a7966f 100644 --- a/src/game/scheduling/save_manager.hpp +++ b/src/game/scheduling/save_manager.hpp @@ -10,7 +10,12 @@ #pragma once #include "lib/thread/thread_pool.hpp" -#include "kv/kv.hpp" + +class KVStore; +class Logger; +class Game; +class Player; +class Guild; class SaveManager { public: diff --git a/src/game/scheduling/task.cpp b/src/game/scheduling/task.cpp index 96355968bd1..0e1f6489516 100644 --- a/src/game/scheduling/task.cpp +++ b/src/game/scheduling/task.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "task.hpp" #include "lib/logging/log_with_spd_log.hpp" diff --git a/src/game/zones/zone.cpp b/src/game/zones/zone.cpp index 7ffa4b594f4..9215ef2570f 100644 --- a/src/game/zones/zone.cpp +++ b/src/game/zones/zone.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "zone.hpp" #include "game/game.hpp" #include "creatures/monsters/monster.hpp" diff --git a/src/io/fileloader.cpp b/src/io/fileloader.cpp index 38bf2be19e3..a4269ffdd30 100644 --- a/src/io/fileloader.cpp +++ b/src/io/fileloader.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "io/fileloader.hpp" namespace OTB { diff --git a/src/io/filestream.cpp b/src/io/filestream.cpp index fc8ae6116fc..71b2dd4aa2f 100644 --- a/src/io/filestream.cpp +++ b/src/io/filestream.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "io/filestream.hpp" #include "io/fileloader.hpp" diff --git a/src/io/functions/iologindata_load_player.cpp b/src/io/functions/iologindata_load_player.cpp index 66be7927692..3042f4ce03b 100644 --- a/src/io/functions/iologindata_load_player.cpp +++ b/src/io/functions/iologindata_load_player.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/players/wheel/player_wheel.hpp" #include "creatures/players/achievement/player_achievement.hpp" #include "io/functions/iologindata_load_player.hpp" @@ -723,7 +721,7 @@ void IOLoginDataLoad::loadPlayerPreyClass(std::shared_ptr player, DBResu Database &db = Database::getInstance(); std::ostringstream query; query << "SELECT * FROM `player_prey` WHERE `player_id` = " << player->getGUID(); - if (result = db.storeQuery(query.str())) { + if ((result = db.storeQuery(query.str()))) { do { auto slot = std::make_unique(static_cast(result->getNumber("slot"))); auto state = static_cast(result->getNumber("state")); @@ -770,7 +768,7 @@ void IOLoginDataLoad::loadPlayerTaskHuntingClass(std::shared_ptr player, Database &db = Database::getInstance(); std::ostringstream query; query << "SELECT * FROM `player_taskhunt` WHERE `player_id` = " << player->getGUID(); - if (result = db.storeQuery(query.str())) { + if ((result = db.storeQuery(query.str()))) { do { auto slot = std::make_unique(static_cast(result->getNumber("slot"))); auto state = static_cast(result->getNumber("state")); diff --git a/src/io/functions/iologindata_save_player.cpp b/src/io/functions/iologindata_save_player.cpp index eccb88c8229..9ff8fe94f64 100644 --- a/src/io/functions/iologindata_save_player.cpp +++ b/src/io/functions/iologindata_save_player.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "io/functions/iologindata_save_player.hpp" #include "game/game.hpp" diff --git a/src/io/io_bosstiary.cpp b/src/io/io_bosstiary.cpp index 7c7c8108ce7..0bb0ff15699 100644 --- a/src/io/io_bosstiary.cpp +++ b/src/io/io_bosstiary.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "io/io_bosstiary.hpp" #include "creatures/monsters/monsters.hpp" diff --git a/src/io/io_wheel.cpp b/src/io/io_wheel.cpp index e8ad30a5d80..1d2a7884e82 100644 --- a/src/io/io_wheel.cpp +++ b/src/io/io_wheel.cpp @@ -7,14 +7,12 @@ * Website: https://docs.opentibiabr.org/ */ -#include "pch.hpp" - #include "io/io_wheel.hpp" +#include "kv/kv.hpp" #include "creatures/players/wheel/player_wheel.hpp" #include "creatures/players/player.hpp" #include "creatures/combat/spells.hpp" - #include "utils/tools.hpp" #define MITIGATION_INCREASE 0.03 diff --git a/src/io/iobestiary.cpp b/src/io/iobestiary.cpp index 9cd964e7c7c..83dd2ed806e 100644 --- a/src/io/iobestiary.cpp +++ b/src/io/iobestiary.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "declarations.hpp" #include "game/game.hpp" #include "io/iobestiary.hpp" diff --git a/src/io/ioguild.cpp b/src/io/ioguild.cpp index 99e1e750676..9d3d628a42d 100644 --- a/src/io/ioguild.cpp +++ b/src/io/ioguild.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "database/database.hpp" #include "creatures/players/grouping/guild.hpp" #include "io/ioguild.hpp" diff --git a/src/io/iologindata.cpp b/src/io/iologindata.cpp index de445bb70f8..d6873243919 100644 --- a/src/io/iologindata.cpp +++ b/src/io/iologindata.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "io/iologindata.hpp" #include "io/functions/iologindata_load_player.hpp" #include "io/functions/iologindata_save_player.hpp" diff --git a/src/io/iomap.cpp b/src/io/iomap.cpp index 1f5c5205113..d39988caa71 100644 --- a/src/io/iomap.cpp +++ b/src/io/iomap.cpp @@ -7,7 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" #include "io/iomap.hpp" #include "game/movement/teleport.hpp" #include "game/game.hpp" diff --git a/src/io/iomapserialize.cpp b/src/io/iomapserialize.cpp index e2a367c4ec4..7351cde1cb9 100644 --- a/src/io/iomapserialize.cpp +++ b/src/io/iomapserialize.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "io/iomapserialize.hpp" #include "io/iologindata.hpp" #include "game/game.hpp" diff --git a/src/io/iomarket.cpp b/src/io/iomarket.cpp index a0253e2ea01..71e707e0bd9 100644 --- a/src/io/iomarket.cpp +++ b/src/io/iomarket.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "io/iomarket.hpp" #include "database/databasetasks.hpp" #include "io/iologindata.hpp" diff --git a/src/io/ioprey.cpp b/src/io/ioprey.cpp index 93a91abade1..abea75aa6c9 100644 --- a/src/io/ioprey.cpp +++ b/src/io/ioprey.cpp @@ -7,14 +7,16 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" +#include "io/ioprey.hpp" +#include "lib/di/container.hpp" #include "creatures/monsters/monster.hpp" #include "creatures/players/player.hpp" #include "config/configmanager.hpp" #include "game/game.hpp" -#include "io/ioprey.hpp" #include "lib/metrics/metrics.hpp" +#include "server/network/message/networkmessage.hpp" +#include "server/network/protocol/protocolgame.hpp" // Prey class PreySlot::PreySlot(PreySlot_t id) : @@ -245,6 +247,10 @@ void TaskHuntingSlot::reloadReward() { } } +IOPrey &IOPrey::getInstance() { + return inject(); +} + // Prey/Task hunting global class void IOPrey::checkPlayerPreys(std::shared_ptr player, uint8_t amount) const { if (!player) { @@ -595,7 +601,11 @@ void IOPrey::initializeTaskHuntOptions() { msg.add(option->secondKills); msg.add(option->secondReward); }); - baseDataMessage = msg; + m_baseDataMessage = msg; +} + +NetworkMessage IOPrey::getTaskHuntingBaseDate() const { + return m_baseDataMessage; } const std::unique_ptr &IOPrey::getTaskRewardOption(const std::unique_ptr &slot) const { diff --git a/src/io/ioprey.hpp b/src/io/ioprey.hpp index 221f2ce5562..df7243df6d6 100644 --- a/src/io/ioprey.hpp +++ b/src/io/ioprey.hpp @@ -9,12 +9,14 @@ #pragma once -#include "lib/di/container.hpp" -#include "server/network/protocol/protocolgame.hpp" +// TODO: Remove circular includes (maybe shared_ptr?) +#include "server/network/message/networkmessage.hpp" class PreySlot; class TaskHuntingSlot; class TaskHuntingOption; +class NetworkMessage; +class Player; static const std::unique_ptr &PreySlotNull {}; static const std::unique_ptr &TaskHuntingSlotNull {}; @@ -221,9 +223,7 @@ class IOPrey { IOPrey(const IOPrey &) = delete; void operator=(const IOPrey &) = delete; - static IOPrey &getInstance() { - return inject(); - } + static IOPrey &getInstance(); void checkPlayerPreys(std::shared_ptr player, uint8_t amount) const; void parsePreyAction(std::shared_ptr player, PreySlot_t slotId, PreyAction_t action, PreyOption_t option, int8_t index, uint16_t raceId) const; @@ -233,11 +233,9 @@ class IOPrey { void initializeTaskHuntOptions(); const std::unique_ptr &getTaskRewardOption(const std::unique_ptr &slot) const; - NetworkMessage getTaskHuntingBaseDate() const { - return baseDataMessage; - } + NetworkMessage getTaskHuntingBaseDate() const; - NetworkMessage baseDataMessage; + NetworkMessage m_baseDataMessage; std::vector> taskOption; }; diff --git a/src/items/bed.cpp b/src/items/bed.cpp index 4b38be3b474..8bfd6d119a5 100644 --- a/src/items/bed.cpp +++ b/src/items/bed.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/bed.hpp" #include "game/game.hpp" #include "io/iologindata.hpp" diff --git a/src/items/containers/container.cpp b/src/items/containers/container.cpp index 6c526a8500a..be2e63ae95b 100644 --- a/src/items/containers/container.cpp +++ b/src/items/containers/container.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/containers/container.hpp" #include "items/decay/decay.hpp" #include "io/iomap.hpp" diff --git a/src/items/containers/depot/depotchest.cpp b/src/items/containers/depot/depotchest.cpp index 15488267f04..2c7d21ed199 100644 --- a/src/items/containers/depot/depotchest.cpp +++ b/src/items/containers/depot/depotchest.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/containers/depot/depotchest.hpp" #include "utils/tools.hpp" diff --git a/src/items/containers/depot/depotlocker.cpp b/src/items/containers/depot/depotlocker.cpp index 0be000794ef..c7320293efd 100644 --- a/src/items/containers/depot/depotlocker.cpp +++ b/src/items/containers/depot/depotlocker.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/containers/depot/depotlocker.hpp" DepotLocker::DepotLocker(uint16_t type, uint16_t size) : diff --git a/src/items/containers/inbox/inbox.cpp b/src/items/containers/inbox/inbox.cpp index 9b22c53748a..220f119645f 100644 --- a/src/items/containers/inbox/inbox.cpp +++ b/src/items/containers/inbox/inbox.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/containers/inbox/inbox.hpp" #include "utils/tools.hpp" diff --git a/src/items/containers/mailbox/mailbox.cpp b/src/items/containers/mailbox/mailbox.cpp index c2c9b2f61e1..c558b85e30d 100644 --- a/src/items/containers/mailbox/mailbox.cpp +++ b/src/items/containers/mailbox/mailbox.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/containers/mailbox/mailbox.hpp" #include "game/game.hpp" #include "io/iologindata.hpp" diff --git a/src/items/containers/rewards/reward.cpp b/src/items/containers/rewards/reward.cpp index 4b1757bd6c8..6a8374e8060 100644 --- a/src/items/containers/rewards/reward.cpp +++ b/src/items/containers/rewards/reward.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/containers/rewards/reward.hpp" Reward::Reward() : diff --git a/src/items/containers/rewards/rewardchest.cpp b/src/items/containers/rewards/rewardchest.cpp index c9bb8112f90..96cf9c2edcc 100644 --- a/src/items/containers/rewards/rewardchest.cpp +++ b/src/items/containers/rewards/rewardchest.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/containers/rewards/rewardchest.hpp" RewardChest::RewardChest(uint16_t type) : diff --git a/src/items/cylinder.cpp b/src/items/cylinder.cpp index 0636e5ff34c..fa61eab2fcb 100644 --- a/src/items/cylinder.cpp +++ b/src/items/cylinder.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/cylinder.hpp" std::shared_ptr VirtualCylinder::virtualCylinder = std::make_shared(); diff --git a/src/items/decay/decay.cpp b/src/items/decay/decay.cpp index 5eaff61a7a9..bdf9ed36040 100644 --- a/src/items/decay/decay.cpp +++ b/src/items/decay/decay.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/decay/decay.hpp" #include "lib/di/container.hpp" diff --git a/src/items/functions/item/attribute.cpp b/src/items/functions/item/attribute.cpp index c67c6ce38f7..747b8c90c39 100644 --- a/src/items/functions/item/attribute.cpp +++ b/src/items/functions/item/attribute.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/functions/item/attribute.hpp" /* diff --git a/src/items/functions/item/custom_attribute.cpp b/src/items/functions/item/custom_attribute.cpp index 202c57c0960..462ba4b520a 100644 --- a/src/items/functions/item/custom_attribute.cpp +++ b/src/items/functions/item/custom_attribute.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/functions/item/custom_attribute.hpp" #include "lua/scripts/luascript.hpp" diff --git a/src/items/functions/item/item_parse.cpp b/src/items/functions/item/item_parse.cpp index 9b63b9aee0e..96fa33c2a7b 100644 --- a/src/items/functions/item/item_parse.cpp +++ b/src/items/functions/item/item_parse.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/functions/item/item_parse.hpp" #include "items/weapons/weapons.hpp" #include "lua/creature/movement.hpp" diff --git a/src/items/item.cpp b/src/items/item.cpp index 2ad0cfa4abd..43c172b8e7d 100644 --- a/src/items/item.cpp +++ b/src/items/item.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/item.hpp" #include "items/containers/container.hpp" #include "items/decay/decay.hpp" diff --git a/src/items/items.cpp b/src/items/items.cpp index 2d4020c5416..bcd055a8db5 100644 --- a/src/items/items.cpp +++ b/src/items/items.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/functions/item/item_parse.hpp" #include "items/items.hpp" #include "items/weapons/weapons.hpp" diff --git a/src/items/thing.cpp b/src/items/thing.cpp index 6eec7994df8..647f312b227 100644 --- a/src/items/thing.cpp +++ b/src/items/thing.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/thing.hpp" #include "items/tile.hpp" diff --git a/src/items/tile.cpp b/src/items/tile.cpp index fc16dd5799c..e9b0b9e8115 100644 --- a/src/items/tile.cpp +++ b/src/items/tile.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/tile.hpp" #include "creatures/creature.hpp" #include "creatures/combat/combat.hpp" diff --git a/src/items/tile.hpp b/src/items/tile.hpp index 71f9d4ae09c..1790cd2972a 100644 --- a/src/items/tile.hpp +++ b/src/items/tile.hpp @@ -256,7 +256,7 @@ class Tile : public Cylinder, public SharedObject { resetTileFlags(ground); } - if (ground = item) { + if ((ground = item)) { setTileFlags(item); } } diff --git a/src/items/trashholder.cpp b/src/items/trashholder.cpp index 65676a75a37..fe95557ce50 100644 --- a/src/items/trashholder.cpp +++ b/src/items/trashholder.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/trashholder.hpp" #include "game/game.hpp" diff --git a/src/items/weapons/weapons.cpp b/src/items/weapons/weapons.cpp index 69d20d43e06..109f0d27218 100644 --- a/src/items/weapons/weapons.cpp +++ b/src/items/weapons/weapons.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/combat/combat.hpp" #include "game/game.hpp" #include "lua/creature/events.hpp" diff --git a/src/kv/kv.cpp b/src/kv/kv.cpp index 29a9787f72f..0a7cfe6827d 100644 --- a/src/kv/kv.cpp +++ b/src/kv/kv.cpp @@ -7,10 +7,10 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "kv/kv.hpp" + #include "lib/di/container.hpp" +#include "database/database.hpp" int64_t KV::lastTimestamp_ = 0; uint64_t KV::counter_ = 0; diff --git a/src/kv/kv_definitions.hpp b/src/kv/kv_definitions.hpp new file mode 100644 index 00000000000..e53c8b0f24a --- /dev/null +++ b/src/kv/kv_definitions.hpp @@ -0,0 +1,29 @@ +/** + * Canary - A free and open-source MMORPG server emulator + * Copyright (©) 2019-2024 OpenTibiaBR + * Repository: https://github.com/opentibiabr/canary + * License: https://github.com/opentibiabr/canary/blob/main/LICENSE + * Contributors: https://github.com/opentibiabr/canary/graphs/contributors + * Website: https://docs.opentibiabr.com/ + */ + +#pragma once + +class ValueWrapper; + +#ifndef USE_PRECOMPILED_HEADERS + #include + #include + #include + #include + #include +#endif + +using StringType = std::string; +using BooleanType = bool; +using IntType = int; +using DoubleType = double; +using ArrayType = std::vector; +using MapType = phmap::flat_hash_map>; + +using ValueVariant = std::variant; diff --git a/src/kv/kv_sql.cpp b/src/kv/kv_sql.cpp index 57d2cc57a10..0391425884c 100644 --- a/src/kv/kv_sql.cpp +++ b/src/kv/kv_sql.cpp @@ -7,14 +7,18 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "kv/kv_sql.hpp" + +#include "database/database.hpp" +#include "lib/logging/logger.hpp" #include "kv/value_wrapper_proto.hpp" #include "utils/tools.hpp" #include +KVSQL::KVSQL(Database &db, Logger &logger) : + KVStore(logger), db(db) { } + std::optional KVSQL::load(const std::string &key) { auto query = fmt::format("SELECT `key_name`, `timestamp`, `value` FROM `kv_store` WHERE `key_name` = {}", db.escapeString(key)); auto result = db.storeQuery(query); @@ -97,3 +101,9 @@ bool KVSQL::saveAll() { return success; } + +DBInsert KVSQL::dbUpdate() { + auto insert = DBInsert("INSERT INTO `kv_store` (`key_name`, `timestamp`, `value`) VALUES"); + insert.upsert({ "key_name", "timestamp", "value" }); + return insert; +} diff --git a/src/kv/kv_sql.hpp b/src/kv/kv_sql.hpp index 1d7a6387d68..43bedada82f 100644 --- a/src/kv/kv_sql.hpp +++ b/src/kv/kv_sql.hpp @@ -11,16 +11,14 @@ #include "kv/kv.hpp" -#include "database/database.hpp" -#include "lib/logging/logger.hpp" - class Database; +class Logger; +class DBInsert; +class ValueWrapper; class KVSQL final : public KVStore { public: - explicit KVSQL(Database &db, Logger &logger) : - KVStore(logger), - db(db) { } + explicit KVSQL(Database &db, Logger &logger); bool saveAll() override; @@ -30,11 +28,7 @@ class KVSQL final : public KVStore { bool save(const std::string &key, const ValueWrapper &value) override; bool prepareSave(const std::string &key, const ValueWrapper &value, DBInsert &update); - DBInsert dbUpdate() { - auto insert = DBInsert("INSERT INTO `kv_store` (`key_name`, `timestamp`, `value`) VALUES"); - insert.upsert({ "key_name", "timestamp", "value" }); - return insert; - } + DBInsert dbUpdate(); Database &db; }; diff --git a/src/kv/value_wrapper.cpp b/src/kv/value_wrapper.cpp index 78f828248a1..72920b6972a 100644 --- a/src/kv/value_wrapper.cpp +++ b/src/kv/value_wrapper.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "kv/value_wrapper.hpp" #include "utils/tools.hpp" diff --git a/src/kv/value_wrapper.hpp b/src/kv/value_wrapper.hpp index 0b388187dc3..889b1776de2 100644 --- a/src/kv/value_wrapper.hpp +++ b/src/kv/value_wrapper.hpp @@ -19,16 +19,7 @@ #include #include -class ValueWrapper; - -using StringType = std::string; -using BooleanType = bool; -using IntType = int; -using DoubleType = double; -using ArrayType = std::vector; -using MapType = phmap::flat_hash_map>; - -using ValueVariant = std::variant; +#include "kv/kv_definitions.hpp" class ValueWrapper { public: diff --git a/src/kv/value_wrapper_proto.cpp b/src/kv/value_wrapper_proto.cpp index 4362101957e..e4d60bed354 100644 --- a/src/kv/value_wrapper_proto.cpp +++ b/src/kv/value_wrapper_proto.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "kv/value_wrapper_proto.hpp" #include "kv/value_wrapper.hpp" diff --git a/src/lib/di/soft_singleton.cpp b/src/lib/di/soft_singleton.cpp index 64ea514d140..8fb90288cee 100644 --- a/src/lib/di/soft_singleton.cpp +++ b/src/lib/di/soft_singleton.cpp @@ -6,7 +6,6 @@ * Contributors: https://github.com/opentibiabr/canary/graphs/contributors * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" #include "lib/di/soft_singleton.hpp" #include "utils/tools.hpp" diff --git a/src/lib/logging/log_with_spd_log.cpp b/src/lib/logging/log_with_spd_log.cpp index f8cfe16946d..a1893e3d501 100644 --- a/src/lib/logging/log_with_spd_log.cpp +++ b/src/lib/logging/log_with_spd_log.cpp @@ -8,7 +8,6 @@ */ #include -#include "pch.hpp" #include "lib/di/container.hpp" LogWithSpdLog::LogWithSpdLog() { diff --git a/src/lib/thread/thread_pool.cpp b/src/lib/thread/thread_pool.cpp index b2f51ef8f9d..9a44c0d6dbe 100644 --- a/src/lib/thread/thread_pool.cpp +++ b/src/lib/thread/thread_pool.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lib/thread/thread_pool.hpp" #include "game/game.hpp" diff --git a/src/lua/callbacks/event_callback.cpp b/src/lua/callbacks/event_callback.cpp index 8280bad6d2b..6591755d18f 100644 --- a/src/lua/callbacks/event_callback.cpp +++ b/src/lua/callbacks/event_callback.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/callbacks/event_callback.hpp" #include "utils/tools.hpp" diff --git a/src/lua/callbacks/events_callbacks.cpp b/src/lua/callbacks/events_callbacks.cpp index 13a42baa15a..ac14fd17c5a 100644 --- a/src/lua/callbacks/events_callbacks.cpp +++ b/src/lua/callbacks/events_callbacks.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/callbacks/events_callbacks.hpp" #include "lua/callbacks/event_callback.hpp" diff --git a/src/lua/creature/actions.cpp b/src/lua/creature/actions.cpp index 9e16ee7b33e..3d9028ce406 100644 --- a/src/lua/creature/actions.cpp +++ b/src/lua/creature/actions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/creature/actions.hpp" #include "items/bed.hpp" #include "items/containers/container.hpp" diff --git a/src/lua/creature/creatureevent.cpp b/src/lua/creature/creatureevent.cpp index 90d09d2b7f9..3b7dfdceb4c 100644 --- a/src/lua/creature/creatureevent.cpp +++ b/src/lua/creature/creatureevent.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/creature/creatureevent.hpp" #include "utils/tools.hpp" #include "creatures/players/player.hpp" diff --git a/src/lua/creature/events.cpp b/src/lua/creature/events.cpp index 144c188e900..354a8ac78e8 100644 --- a/src/lua/creature/events.cpp +++ b/src/lua/creature/events.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/creature/events.hpp" #include "utils/tools.hpp" #include "items/item.hpp" diff --git a/src/lua/creature/movement.cpp b/src/lua/creature/movement.cpp index b75ff31c661..64e290d8990 100644 --- a/src/lua/creature/movement.cpp +++ b/src/lua/creature/movement.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/game.hpp" #include "lua/creature/events.hpp" #include "lua/callbacks/event_callback.hpp" diff --git a/src/lua/creature/raids.cpp b/src/lua/creature/raids.cpp index 8064bf52b81..c801c4cdee4 100644 --- a/src/lua/creature/raids.cpp +++ b/src/lua/creature/raids.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/creature/raids.hpp" #include "utils/pugicast.hpp" #include "game/game.hpp" diff --git a/src/lua/creature/talkaction.cpp b/src/lua/creature/talkaction.cpp index c1b8c028ddc..ae07bfe6765 100644 --- a/src/lua/creature/talkaction.cpp +++ b/src/lua/creature/talkaction.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/players/player.hpp" #include "lua/scripts/scripts.hpp" #include "lua/creature/talkaction.hpp" diff --git a/src/lua/functions/core/game/bank_functions.cpp b/src/lua/functions/core/game/bank_functions.cpp index eb0bbf00280..26005db41e3 100644 --- a/src/lua/functions/core/game/bank_functions.cpp +++ b/src/lua/functions/core/game/bank_functions.cpp @@ -1,4 +1,12 @@ -#include "pch.hpp" +/** + * Canary - A free and open-source MMORPG server emulator + * Copyright (©) 2019-2024 OpenTibiaBR + * Repository: https://github.com/opentibiabr/canary + * License: https://github.com/opentibiabr/canary/blob/main/LICENSE + * Contributors: https://github.com/opentibiabr/canary/graphs/contributors + * Website: https://docs.opentibiabr.com/ + */ + #include "lua/functions/core/game/bank_functions.hpp" #include "game/bank/bank.hpp" #include "game/game.hpp" diff --git a/src/lua/functions/core/game/config_functions.cpp b/src/lua/functions/core/game/config_functions.cpp index b839f720057..acd4e8c0c1c 100644 --- a/src/lua/functions/core/game/config_functions.cpp +++ b/src/lua/functions/core/game/config_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/functions/core/game/config_functions.hpp" #include "config/configmanager.hpp" diff --git a/src/lua/functions/core/game/game_functions.cpp b/src/lua/functions/core/game/game_functions.cpp index 83544ded535..73516ce53de 100644 --- a/src/lua/functions/core/game/game_functions.cpp +++ b/src/lua/functions/core/game/game_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "core.hpp" #include "creatures/monsters/monster.hpp" #include "game/functions/game_reload.hpp" diff --git a/src/lua/functions/core/game/global_functions.cpp b/src/lua/functions/core/game/global_functions.cpp index 6b5175b06cf..79cb3d398fa 100644 --- a/src/lua/functions/core/game/global_functions.cpp +++ b/src/lua/functions/core/game/global_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/interactions/chat.hpp" #include "game/game.hpp" #include "game/scheduling/dispatcher.hpp" diff --git a/src/lua/functions/core/game/lua_enums.cpp b/src/lua/functions/core/game/lua_enums.cpp index e4dc252be0d..22b93351911 100644 --- a/src/lua/functions/core/game/lua_enums.cpp +++ b/src/lua/functions/core/game/lua_enums.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/functions/core/game/lua_enums.hpp" #include "creatures/players/wheel/wheel_gems.hpp" diff --git a/src/lua/functions/core/game/modal_window_functions.cpp b/src/lua/functions/core/game/modal_window_functions.cpp index 0221a9e9a59..a4851cfc85a 100644 --- a/src/lua/functions/core/game/modal_window_functions.cpp +++ b/src/lua/functions/core/game/modal_window_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/players/player.hpp" #include "lua/functions/core/game/modal_window_functions.hpp" #include "game/modal_window/modal_window.hpp" diff --git a/src/lua/functions/core/game/zone_functions.cpp b/src/lua/functions/core/game/zone_functions.cpp index 0f19c94f789..d973f1b003c 100644 --- a/src/lua/functions/core/game/zone_functions.cpp +++ b/src/lua/functions/core/game/zone_functions.cpp @@ -1,4 +1,12 @@ -#include "pch.hpp" +/** + * Canary - A free and open-source MMORPG server emulator + * Copyright (©) 2019-2024 OpenTibiaBR + * Repository: https://github.com/opentibiabr/canary + * License: https://github.com/opentibiabr/canary/blob/main/LICENSE + * Contributors: https://github.com/opentibiabr/canary/graphs/contributors + * Website: https://docs.opentibiabr.com/ + */ + #include "lua/functions/core/game/zone_functions.hpp" #include "game/zones/zone.hpp" #include "game/game.hpp" diff --git a/src/lua/functions/core/libs/bit_functions.cpp b/src/lua/functions/core/libs/bit_functions.cpp index 86f76a77a26..94e5f709b5d 100644 --- a/src/lua/functions/core/libs/bit_functions.cpp +++ b/src/lua/functions/core/libs/bit_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/functions/core/libs/bit_functions.hpp" #ifndef LUAJIT_VERSION diff --git a/src/lua/functions/core/libs/db_functions.cpp b/src/lua/functions/core/libs/db_functions.cpp index d5f5a62e0f8..bdfbac8f501 100644 --- a/src/lua/functions/core/libs/db_functions.cpp +++ b/src/lua/functions/core/libs/db_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "database/databasemanager.hpp" #include "database/databasetasks.hpp" #include "lua/functions/core/libs/db_functions.hpp" diff --git a/src/lua/functions/core/libs/kv_functions.cpp b/src/lua/functions/core/libs/kv_functions.cpp index 5ed9c9cfe5d..7ef21f861f7 100644 --- a/src/lua/functions/core/libs/kv_functions.cpp +++ b/src/lua/functions/core/libs/kv_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include #include "kv/kv.hpp" diff --git a/src/lua/functions/core/libs/logger_functions.cpp b/src/lua/functions/core/libs/logger_functions.cpp index 1b2605f6421..741d35fec9d 100644 --- a/src/lua/functions/core/libs/logger_functions.cpp +++ b/src/lua/functions/core/libs/logger_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/functions/core/libs/logger_functions.hpp" void LoggerFunctions::init(lua_State* L) { diff --git a/src/lua/functions/core/libs/metrics_functions.cpp b/src/lua/functions/core/libs/metrics_functions.cpp index 9dc9fa528cb..bcb233bb5aa 100644 --- a/src/lua/functions/core/libs/metrics_functions.cpp +++ b/src/lua/functions/core/libs/metrics_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/functions/core/libs/metrics_functions.hpp" #include "lib/metrics/metrics.hpp" diff --git a/src/lua/functions/core/libs/result_functions.cpp b/src/lua/functions/core/libs/result_functions.cpp index 512f90f7da5..46acc07af9f 100644 --- a/src/lua/functions/core/libs/result_functions.cpp +++ b/src/lua/functions/core/libs/result_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/functions/core/libs/result_functions.hpp" int ResultFunctions::luaResultGetNumber(lua_State* L) { diff --git a/src/lua/functions/core/network/network_message_functions.cpp b/src/lua/functions/core/network/network_message_functions.cpp index e2f4013448d..c7572b4488b 100644 --- a/src/lua/functions/core/network/network_message_functions.cpp +++ b/src/lua/functions/core/network/network_message_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/functions/core/network/network_message_functions.hpp" #include "creatures/players/player.hpp" #include "server/network/protocol/protocolstatus.hpp" diff --git a/src/lua/functions/core/network/webhook_functions.cpp b/src/lua/functions/core/network/webhook_functions.cpp index 37372f8b23a..b24e6184ce3 100644 --- a/src/lua/functions/core/network/webhook_functions.cpp +++ b/src/lua/functions/core/network/webhook_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/functions/core/network/webhook_functions.hpp" #include "server/network/webhook/webhook.hpp" diff --git a/src/lua/functions/creatures/combat/combat_functions.cpp b/src/lua/functions/creatures/combat/combat_functions.cpp index 3bba21d179c..f073cde6aba 100644 --- a/src/lua/functions/creatures/combat/combat_functions.cpp +++ b/src/lua/functions/creatures/combat/combat_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/combat/combat.hpp" #include "game/game.hpp" #include "lua/functions/creatures/combat/combat_functions.hpp" diff --git a/src/lua/functions/creatures/combat/condition_functions.cpp b/src/lua/functions/creatures/combat/condition_functions.cpp index 27f21867f76..e7b1dd331ea 100644 --- a/src/lua/functions/creatures/combat/condition_functions.cpp +++ b/src/lua/functions/creatures/combat/condition_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/combat/condition.hpp" #include "game/game.hpp" #include "lua/functions/creatures/combat/condition_functions.hpp" diff --git a/src/lua/functions/creatures/combat/spell_functions.cpp b/src/lua/functions/creatures/combat/spell_functions.cpp index a24407c1682..79ecb29b957 100644 --- a/src/lua/functions/creatures/combat/spell_functions.cpp +++ b/src/lua/functions/creatures/combat/spell_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/combat/spells.hpp" #include "creatures/players/vocations/vocation.hpp" #include "lua/functions/creatures/combat/spell_functions.hpp" diff --git a/src/lua/functions/creatures/combat/variant_functions.cpp b/src/lua/functions/creatures/combat/variant_functions.cpp index 3b0299983fd..4723e9e8543 100644 --- a/src/lua/functions/creatures/combat/variant_functions.cpp +++ b/src/lua/functions/creatures/combat/variant_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/cylinder.hpp" #include "lua/functions/creatures/combat/variant_functions.hpp" #include "lua/global/lua_variant.hpp" diff --git a/src/lua/functions/creatures/creature_functions.cpp b/src/lua/functions/creatures/creature_functions.cpp index 81a4a0b5304..4d4a4202903 100644 --- a/src/lua/functions/creatures/creature_functions.cpp +++ b/src/lua/functions/creatures/creature_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/game.hpp" #include "creatures/creature.hpp" #include "lua/functions/creatures/creature_functions.hpp" diff --git a/src/lua/functions/creatures/monster/charm_functions.cpp b/src/lua/functions/creatures/monster/charm_functions.cpp index d456f1c96a8..492820b76fa 100644 --- a/src/lua/functions/creatures/monster/charm_functions.cpp +++ b/src/lua/functions/creatures/monster/charm_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/game.hpp" #include "io/iobestiary.hpp" #include "lua/functions/creatures/monster/charm_functions.hpp" diff --git a/src/lua/functions/creatures/monster/loot_functions.cpp b/src/lua/functions/creatures/monster/loot_functions.cpp index 47e0d8778e3..e05d86b6340 100644 --- a/src/lua/functions/creatures/monster/loot_functions.cpp +++ b/src/lua/functions/creatures/monster/loot_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/monsters/monsters.hpp" #include "lua/functions/creatures/monster/loot_functions.hpp" diff --git a/src/lua/functions/creatures/monster/monster_functions.cpp b/src/lua/functions/creatures/monster/monster_functions.cpp index 917e90f85f4..e7b22842640 100644 --- a/src/lua/functions/creatures/monster/monster_functions.cpp +++ b/src/lua/functions/creatures/monster/monster_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/game.hpp" #include "creatures/creature.hpp" #include "creatures/monsters/monster.hpp" diff --git a/src/lua/functions/creatures/monster/monster_spell_functions.cpp b/src/lua/functions/creatures/monster/monster_spell_functions.cpp index a20d57008d2..e9beb607bfc 100644 --- a/src/lua/functions/creatures/monster/monster_spell_functions.cpp +++ b/src/lua/functions/creatures/monster/monster_spell_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/functions/creatures/monster/monster_spell_functions.hpp" #include "creatures/monsters/monsters.hpp" diff --git a/src/lua/functions/creatures/monster/monster_type_functions.cpp b/src/lua/functions/creatures/monster/monster_type_functions.cpp index 2a6e3d1b581..f4d524a533c 100644 --- a/src/lua/functions/creatures/monster/monster_type_functions.cpp +++ b/src/lua/functions/creatures/monster/monster_type_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/game.hpp" #include "io/io_bosstiary.hpp" #include "creatures/combat/spells.hpp" diff --git a/src/lua/functions/creatures/npc/npc_functions.cpp b/src/lua/functions/creatures/npc/npc_functions.cpp index 13e9b499abc..3a161ba3501 100644 --- a/src/lua/functions/creatures/npc/npc_functions.cpp +++ b/src/lua/functions/creatures/npc/npc_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/game.hpp" #include "creatures/creature.hpp" #include "creatures/npcs/npc.hpp" diff --git a/src/lua/functions/creatures/npc/npc_type_functions.cpp b/src/lua/functions/creatures/npc/npc_type_functions.cpp index ef79b671a34..8084688deea 100644 --- a/src/lua/functions/creatures/npc/npc_type_functions.cpp +++ b/src/lua/functions/creatures/npc/npc_type_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/npcs/npcs.hpp" #include "lua/functions/creatures/npc/npc_type_functions.hpp" #include "lua/scripts/scripts.hpp" diff --git a/src/lua/functions/creatures/npc/shop_functions.cpp b/src/lua/functions/creatures/npc/shop_functions.cpp index 122e249a8db..388bda0e977 100644 --- a/src/lua/functions/creatures/npc/shop_functions.cpp +++ b/src/lua/functions/creatures/npc/shop_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/npcs/npcs.hpp" #include "lua/functions/creatures/npc/shop_functions.hpp" diff --git a/src/lua/functions/creatures/player/group_functions.cpp b/src/lua/functions/creatures/player/group_functions.cpp index f547eec1590..2fd414a2e4a 100644 --- a/src/lua/functions/creatures/player/group_functions.cpp +++ b/src/lua/functions/creatures/player/group_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/players/grouping/groups.hpp" #include "game/game.hpp" #include "lua/functions/creatures/player/group_functions.hpp" diff --git a/src/lua/functions/creatures/player/guild_functions.cpp b/src/lua/functions/creatures/player/guild_functions.cpp index 196f0f9d31e..d5706e0609b 100644 --- a/src/lua/functions/creatures/player/guild_functions.cpp +++ b/src/lua/functions/creatures/player/guild_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/game.hpp" #include "creatures/players/grouping/guild.hpp" #include "lua/functions/creatures/player/guild_functions.hpp" diff --git a/src/lua/functions/creatures/player/mount_functions.cpp b/src/lua/functions/creatures/player/mount_functions.cpp index 49b16db6caa..3decd6b2321 100644 --- a/src/lua/functions/creatures/player/mount_functions.cpp +++ b/src/lua/functions/creatures/player/mount_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/appearance/mounts/mounts.hpp" #include "game/game.hpp" #include "lua/functions/creatures/player/mount_functions.hpp" diff --git a/src/lua/functions/creatures/player/party_functions.cpp b/src/lua/functions/creatures/player/party_functions.cpp index d739cde3ceb..1791016bde3 100644 --- a/src/lua/functions/creatures/player/party_functions.cpp +++ b/src/lua/functions/creatures/player/party_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/players/grouping/party.hpp" #include "creatures/players/player.hpp" #include "game/game.hpp" diff --git a/src/lua/functions/creatures/player/player_functions.cpp b/src/lua/functions/creatures/player/player_functions.cpp index 421ceefcb0d..d148acf8397 100644 --- a/src/lua/functions/creatures/player/player_functions.cpp +++ b/src/lua/functions/creatures/player/player_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/functions/creatures/player/player_functions.hpp" #include "creatures/combat/spells.hpp" diff --git a/src/lua/functions/creatures/player/vocation_functions.cpp b/src/lua/functions/creatures/player/vocation_functions.cpp index 15cf888bf8a..15e1603cc54 100644 --- a/src/lua/functions/creatures/player/vocation_functions.cpp +++ b/src/lua/functions/creatures/player/vocation_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/players/vocations/vocation.hpp" #include "lua/functions/creatures/player/vocation_functions.hpp" diff --git a/src/lua/functions/events/action_functions.cpp b/src/lua/functions/events/action_functions.cpp index 31b202465c7..c5cf4c73c29 100644 --- a/src/lua/functions/events/action_functions.cpp +++ b/src/lua/functions/events/action_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/creature/actions.hpp" #include "lua/functions/events/action_functions.hpp" #include "game/game.hpp" diff --git a/src/lua/functions/events/creature_event_functions.cpp b/src/lua/functions/events/creature_event_functions.cpp index 7edbabad1d3..ddba9f153fd 100644 --- a/src/lua/functions/events/creature_event_functions.cpp +++ b/src/lua/functions/events/creature_event_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/creature/creatureevent.hpp" #include "lua/functions/events/creature_event_functions.hpp" #include "utils/tools.hpp" diff --git a/src/lua/functions/events/event_callback_functions.cpp b/src/lua/functions/events/event_callback_functions.cpp index ef1c348c113..0968df435ba 100644 --- a/src/lua/functions/events/event_callback_functions.cpp +++ b/src/lua/functions/events/event_callback_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/functions/events/event_callback_functions.hpp" #include "lua/callbacks/event_callback.hpp" diff --git a/src/lua/functions/events/events_scheduler_functions.cpp b/src/lua/functions/events/events_scheduler_functions.cpp index e26794e218a..eb16cf5c340 100644 --- a/src/lua/functions/events/events_scheduler_functions.cpp +++ b/src/lua/functions/events/events_scheduler_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/scheduling/events_scheduler.hpp" #include "lua/functions/events/events_scheduler_functions.hpp" diff --git a/src/lua/functions/events/global_event_functions.cpp b/src/lua/functions/events/global_event_functions.cpp index 129a466e97c..c858ee9a831 100644 --- a/src/lua/functions/events/global_event_functions.cpp +++ b/src/lua/functions/events/global_event_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/functions/events/global_event_functions.hpp" #include "game/game.hpp" #include "lua/global/globalevent.hpp" diff --git a/src/lua/functions/events/move_event_functions.cpp b/src/lua/functions/events/move_event_functions.cpp index 8340dded92f..cfd8588d19b 100644 --- a/src/lua/functions/events/move_event_functions.cpp +++ b/src/lua/functions/events/move_event_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/creature.hpp" #include "lua/creature/movement.hpp" #include "lua/functions/events/move_event_functions.hpp" diff --git a/src/lua/functions/events/talk_action_functions.cpp b/src/lua/functions/events/talk_action_functions.cpp index 559e251eb8e..4a8e9850d7f 100644 --- a/src/lua/functions/events/talk_action_functions.cpp +++ b/src/lua/functions/events/talk_action_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "account/account.hpp" #include "lua/creature/talkaction.hpp" #include "lua/functions/events/talk_action_functions.hpp" diff --git a/src/lua/functions/items/container_functions.cpp b/src/lua/functions/items/container_functions.cpp index 30eb26c6801..7cc06745b18 100644 --- a/src/lua/functions/items/container_functions.cpp +++ b/src/lua/functions/items/container_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/game.hpp" #include "items/item.hpp" #include "lua/functions/items/container_functions.hpp" diff --git a/src/lua/functions/items/imbuement_functions.cpp b/src/lua/functions/items/imbuement_functions.cpp index f24a3f564d7..1faed911621 100644 --- a/src/lua/functions/items/imbuement_functions.cpp +++ b/src/lua/functions/items/imbuement_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/weapons/weapons.hpp" #include "creatures/players/imbuements/imbuements.hpp" #include "lua/functions/items/imbuement_functions.hpp" diff --git a/src/lua/functions/items/item_classification_functions.cpp b/src/lua/functions/items/item_classification_functions.cpp index aa8cf19d589..4df6d6f9ea8 100644 --- a/src/lua/functions/items/item_classification_functions.cpp +++ b/src/lua/functions/items/item_classification_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/game.hpp" #include "lua/functions/items/item_classification_functions.hpp" diff --git a/src/lua/functions/items/item_functions.cpp b/src/lua/functions/items/item_functions.cpp index 361a469da32..5d22b6d3102 100644 --- a/src/lua/functions/items/item_functions.cpp +++ b/src/lua/functions/items/item_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/functions/items/item_functions.hpp" #include "game/game.hpp" diff --git a/src/lua/functions/items/item_type_functions.cpp b/src/lua/functions/items/item_type_functions.cpp index b528795a050..333e00bf763 100644 --- a/src/lua/functions/items/item_type_functions.cpp +++ b/src/lua/functions/items/item_type_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/item.hpp" #include "items/items.hpp" #include "lua/functions/items/item_type_functions.hpp" diff --git a/src/lua/functions/items/weapon_functions.cpp b/src/lua/functions/items/weapon_functions.cpp index 61eff2dfb66..cd0acf94849 100644 --- a/src/lua/functions/items/weapon_functions.cpp +++ b/src/lua/functions/items/weapon_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/functions/items/weapon_functions.hpp" #include "game/game.hpp" diff --git a/src/lua/functions/lua_functions_loader.cpp b/src/lua/functions/lua_functions_loader.cpp index c2dedfb57b6..ad52431a661 100644 --- a/src/lua/functions/lua_functions_loader.cpp +++ b/src/lua/functions/lua_functions_loader.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/combat/spells.hpp" #include "creatures/monsters/monster.hpp" #include "creatures/npcs/npc.hpp" diff --git a/src/lua/functions/map/house_functions.cpp b/src/lua/functions/map/house_functions.cpp index ffba0d0b5a9..b13e47eae10 100644 --- a/src/lua/functions/map/house_functions.cpp +++ b/src/lua/functions/map/house_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/bed.hpp" #include "game/game.hpp" #include "game/movement/position.hpp" diff --git a/src/lua/functions/map/position_functions.cpp b/src/lua/functions/map/position_functions.cpp index 0e4397f3fce..b9f5b5947f6 100644 --- a/src/lua/functions/map/position_functions.cpp +++ b/src/lua/functions/map/position_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/game.hpp" #include "game/movement/position.hpp" #include "lua/functions/map/position_functions.hpp" diff --git a/src/lua/functions/map/teleport_functions.cpp b/src/lua/functions/map/teleport_functions.cpp index 32fce583057..5a5a25a20e6 100644 --- a/src/lua/functions/map/teleport_functions.cpp +++ b/src/lua/functions/map/teleport_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/movement/teleport.hpp" #include "items/item.hpp" #include "lua/functions/map/teleport_functions.hpp" diff --git a/src/lua/functions/map/tile_functions.cpp b/src/lua/functions/map/tile_functions.cpp index cdd82abda8c..8ff44064079 100644 --- a/src/lua/functions/map/tile_functions.cpp +++ b/src/lua/functions/map/tile_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/game.hpp" #include "lua/functions/map/tile_functions.hpp" diff --git a/src/lua/functions/map/town_functions.cpp b/src/lua/functions/map/town_functions.cpp index 053aca36b82..3ccf112e772 100644 --- a/src/lua/functions/map/town_functions.cpp +++ b/src/lua/functions/map/town_functions.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/game.hpp" #include "lua/functions/map/town_functions.hpp" #include "map/town.hpp" diff --git a/src/lua/global/baseevents.cpp b/src/lua/global/baseevents.cpp index 3b312100d3b..e4f4dfa05a5 100644 --- a/src/lua/global/baseevents.cpp +++ b/src/lua/global/baseevents.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/global/baseevents.hpp" #include "lua/scripts/lua_environment.hpp" #include "utils/tools.hpp" diff --git a/src/lua/global/globalevent.cpp b/src/lua/global/globalevent.cpp index a9d589a1f76..9cb24292b12 100644 --- a/src/lua/global/globalevent.cpp +++ b/src/lua/global/globalevent.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/global/globalevent.hpp" #include "utils/tools.hpp" #include "game/game.hpp" diff --git a/src/lua/modules/modules.cpp b/src/lua/modules/modules.cpp index 8b79524ec2c..04cddc43443 100644 --- a/src/lua/modules/modules.cpp +++ b/src/lua/modules/modules.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/modules/modules.hpp" #include "creatures/players/player.hpp" #include "game/game.hpp" diff --git a/src/lua/scripts/lua_environment.cpp b/src/lua/scripts/lua_environment.cpp index cd5023a8d4b..04afd75f958 100644 --- a/src/lua/scripts/lua_environment.cpp +++ b/src/lua/scripts/lua_environment.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "declarations.hpp" #include "lua/scripts/lua_environment.hpp" #include "lua/functions/lua_functions_loader.hpp" diff --git a/src/lua/scripts/luascript.cpp b/src/lua/scripts/luascript.cpp index d67b90e9d18..2daab6c0532 100644 --- a/src/lua/scripts/luascript.cpp +++ b/src/lua/scripts/luascript.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lua/scripts/luascript.hpp" #include "lua/scripts/lua_environment.hpp" #include "lib/metrics/metrics.hpp" diff --git a/src/lua/scripts/script_environment.cpp b/src/lua/scripts/script_environment.cpp index 4a7ad7acd94..e1c5e3a9c85 100644 --- a/src/lua/scripts/script_environment.cpp +++ b/src/lua/scripts/script_environment.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/game.hpp" #include "lua/scripts/luascript.hpp" #include "lua/scripts/script_environment.hpp" diff --git a/src/lua/scripts/scripts.cpp b/src/lua/scripts/scripts.cpp index cb92c1cc29a..3a35750c1af 100644 --- a/src/lua/scripts/scripts.cpp +++ b/src/lua/scripts/scripts.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/players/imbuements/imbuements.hpp" #include "lua/global/globalevent.hpp" #include "items/weapons/weapons.hpp" diff --git a/src/main.cpp b/src/main.cpp index be289d397f6..8534bbb6911 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,7 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" #include "canary_server.hpp" #include "lib/di/container.hpp" diff --git a/src/map/house/house.cpp b/src/map/house/house.cpp index f2cb26114bf..ba5e782e5de 100644 --- a/src/map/house/house.cpp +++ b/src/map/house/house.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "utils/pugicast.hpp" #include "map/house/house.hpp" #include "io/iologindata.hpp" diff --git a/src/map/house/housetile.cpp b/src/map/house/housetile.cpp index 5e728a14ea3..8a3217cc011 100644 --- a/src/map/house/housetile.cpp +++ b/src/map/house/housetile.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "items/tile.hpp" #include "creatures/monsters/monster.hpp" #include "map/house/housetile.hpp" diff --git a/src/map/map.cpp b/src/map/map.cpp index b1706be0759..ce73464b80c 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "map.hpp" #include "utils/astarnodes.hpp" diff --git a/src/map/mapcache.cpp b/src/map/mapcache.cpp index ad3c909a8bf..33a069f5ae9 100644 --- a/src/map/mapcache.cpp +++ b/src/map/mapcache.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "mapcache.hpp" #include "game/movement/teleport.hpp" diff --git a/src/map/spectators.cpp b/src/map/spectators.cpp index 405119b83e9..29c81617019 100644 --- a/src/map/spectators.cpp +++ b/src/map/spectators.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "spectators.hpp" #include "game/game.hpp" diff --git a/src/map/utils/astarnodes.cpp b/src/map/utils/astarnodes.cpp index e7c5b7ce48e..4645cd30b62 100644 --- a/src/map/utils/astarnodes.cpp +++ b/src/map/utils/astarnodes.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "astarnodes.hpp" #include "creatures/monsters/monster.hpp" #include "creatures/combat/combat.hpp" diff --git a/src/map/utils/mapsector.cpp b/src/map/utils/mapsector.cpp index de036728b76..064ff837e8b 100644 --- a/src/map/utils/mapsector.cpp +++ b/src/map/utils/mapsector.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/creature.hpp" #include "mapsector.hpp" diff --git a/src/pch.cpp b/src/pch.cpp new file mode 100644 index 00000000000..c76b9e42cf8 --- /dev/null +++ b/src/pch.cpp @@ -0,0 +1,11 @@ +/** + * Canary - A free and open-source MMORPG server emulator + * Copyright (©) 2019-2024 OpenTibiaBR + * Repository: https://github.com/opentibiabr/canary + * License: https://github.com/opentibiabr/canary/blob/main/LICENSE + * Contributors: https://github.com/opentibiabr/canary/graphs/contributors + * Website: https://docs.opentibiabr.com/ + */ + +// The visual studio solution requires a pch.cpp including the pch.hpp +#include "pch.hpp" diff --git a/src/security/argon.cpp b/src/security/argon.cpp index fe11ab0724a..41b65b64908 100644 --- a/src/security/argon.cpp +++ b/src/security/argon.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "config/configmanager.hpp" #include "database/database.hpp" #include "security/argon.hpp" diff --git a/src/security/rsa.cpp b/src/security/rsa.cpp index fc28d931f66..220ba94a43d 100644 --- a/src/security/rsa.cpp +++ b/src/security/rsa.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "lib/di/container.hpp" #include "security/rsa.hpp" diff --git a/src/server/network/connection/connection.cpp b/src/server/network/connection/connection.cpp index a3782d56cba..b5ebdebc648 100644 --- a/src/server/network/connection/connection.cpp +++ b/src/server/network/connection/connection.cpp @@ -7,14 +7,20 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "server/network/connection/connection.hpp" + +#include "config/configmanager.hpp" +#include "lib/di/container.hpp" #include "server/network/message/outputmessage.hpp" #include "server/network/protocol/protocol.hpp" #include "game/scheduling/dispatcher.hpp" +#include "server/network/message/networkmessage.hpp" #include "server/server.hpp" +ConnectionManager &ConnectionManager::getInstance() { + return inject(); +} + Connection_ptr ConnectionManager::createConnection(asio::io_service &io_service, ConstServicePort_ptr servicePort) { auto connection = std::make_shared(io_service, servicePort); connections.emplace(connection); @@ -47,7 +53,7 @@ Connection::Connection(asio::io_service &initIoService, ConstServicePort_ptr ini readTimer(initIoService), writeTimer(initIoService), service_port(std::move(initservicePort)), - socket(initIoService) { + socket(initIoService), m_msg() { } void Connection::close(bool force) { @@ -108,7 +114,7 @@ void Connection::acceptInternal(bool toggleParseHeader) { readTimer.async_wait([self = std::weak_ptr(shared_from_this())](const std::error_code &error) { Connection::handleTimeout(self, error); }); try { - asio::async_read(socket, asio::buffer(msg.getBuffer(), HEADER_LENGTH), [self = shared_from_this(), toggleParseHeader](const std::error_code &error, std::size_t N) { + asio::async_read(socket, asio::buffer(m_msg.getBuffer(), HEADER_LENGTH), [self = shared_from_this(), toggleParseHeader](const std::error_code &error, std::size_t N) { if (toggleParseHeader) { self->parseHeader(error); } else { @@ -132,7 +138,7 @@ void Connection::parseProxyIdentification(const std::error_code &error) { return; } - uint8_t* msgBuffer = msg.getBuffer(); + uint8_t* msgBuffer = m_msg.getBuffer(); auto charData = static_cast(static_cast(msgBuffer)); std::string serverName = g_configManager().getString(SERVER_NAME, __FUNCTION__) + "\n"; if (connectionState == CONNECTION_STATE_IDENTIFYING) { @@ -150,7 +156,7 @@ void Connection::parseProxyIdentification(const std::error_code &error) { readTimer.async_wait([self = std::weak_ptr(shared_from_this())](const std::error_code &error) { Connection::handleTimeout(self, error); }); // Read the remainder of proxy identification - asio::async_read(socket, asio::buffer(msg.getBuffer(), remainder), [self = shared_from_this()](const std::error_code &error, std::size_t N) { self->parseProxyIdentification(error); }); + asio::async_read(socket, asio::buffer(m_msg.getBuffer(), remainder), [self = shared_from_this()](const std::error_code &error, std::size_t N) { self->parseProxyIdentification(error); }); } catch (const std::system_error &e) { g_logger().error("Connection::parseProxyIdentification] - error: {}", e.what()); close(FORCE_CLOSE); @@ -200,7 +206,7 @@ void Connection::parseHeader(const std::error_code &error) { packetsSent = 0; } - uint16_t size = msg.getLengthHeader(); + uint16_t size = m_msg.getLengthHeader(); if (size == 0 || size > INPUTMESSAGE_MAXSIZE) { close(FORCE_CLOSE); return; @@ -211,9 +217,9 @@ void Connection::parseHeader(const std::error_code &error) { readTimer.async_wait([self = std::weak_ptr(shared_from_this())](const std::error_code &error) { Connection::handleTimeout(self, error); }); // Read packet content - msg.setLength(size + HEADER_LENGTH); + m_msg.setLength(size + HEADER_LENGTH); // Read the remainder of proxy identification - asio::async_read(socket, asio::buffer(msg.getBodyBuffer(), size), [self = shared_from_this()](const std::error_code &error, std::size_t N) { self->parsePacket(error); }); + asio::async_read(socket, asio::buffer(m_msg.getBodyBuffer(), size), [self = shared_from_this()](const std::error_code &error, std::size_t N) { self->parsePacket(error); }); } catch (const std::system_error &e) { g_logger().error("[Connection::parseHeader] - error: {}", e.what()); close(FORCE_CLOSE); @@ -240,21 +246,21 @@ void Connection::parsePacket(const std::error_code &error) { if (!protocol) { // Check packet checksum uint32_t checksum; - if (int32_t len = msg.getLength() - msg.getBufferPosition() - CHECKSUM_LENGTH; + if (int32_t len = m_msg.getLength() - m_msg.getBufferPosition() - CHECKSUM_LENGTH; len > 0) { - checksum = adlerChecksum(msg.getBuffer() + msg.getBufferPosition() + CHECKSUM_LENGTH, len); + checksum = adlerChecksum(m_msg.getBuffer() + m_msg.getBufferPosition() + CHECKSUM_LENGTH, len); } else { checksum = 0; } - uint32_t recvChecksum = msg.get(); + uint32_t recvChecksum = m_msg.get(); if (recvChecksum != checksum) { // it might not have been the checksum, step back - msg.skipBytes(-CHECKSUM_LENGTH); + m_msg.skipBytes(-CHECKSUM_LENGTH); } // Game protocol has already been created at this point - protocol = service_port->make_protocol(recvChecksum == checksum, msg, shared_from_this()); + protocol = service_port->make_protocol(recvChecksum == checksum, m_msg, shared_from_this()); if (!protocol) { close(FORCE_CLOSE); return; @@ -262,15 +268,15 @@ void Connection::parsePacket(const std::error_code &error) { } else { // It is rather hard to detect if we have checksum or sequence method here so let's skip checksum check // it doesn't generate any problem because olders protocol don't use 'server sends first' feature - msg.get(); + m_msg.get(); // Skip protocol ID - msg.skipBytes(1); + m_msg.skipBytes(1); } - protocol->onRecvFirstMessage(msg); + protocol->onRecvFirstMessage(m_msg); } else { // Send the packet to the current protocol - skipReadingNextPacket = protocol->onRecvMessage(msg); + skipReadingNextPacket = protocol->onRecvMessage(m_msg); } try { @@ -279,7 +285,7 @@ void Connection::parsePacket(const std::error_code &error) { if (!skipReadingNextPacket) { // Wait to the next packet - asio::async_read(socket, asio::buffer(msg.getBuffer(), HEADER_LENGTH), [self = shared_from_this()](const std::error_code &error, std::size_t N) { self->parseHeader(error); }); + asio::async_read(socket, asio::buffer(m_msg.getBuffer(), HEADER_LENGTH), [self = shared_from_this()](const std::error_code &error, std::size_t N) { self->parseHeader(error); }); } } catch (const std::system_error &e) { g_logger().error("[Connection::parsePacket] - error: {}", e.what()); @@ -292,7 +298,7 @@ void Connection::resumeWork() { readTimer.async_wait([self = std::weak_ptr(shared_from_this())](const std::error_code &error) { Connection::handleTimeout(self, error); }); try { - asio::async_read(socket, asio::buffer(msg.getBuffer(), HEADER_LENGTH), [self = shared_from_this()](const std::error_code &error, std::size_t N) { self->parseHeader(error); }); + asio::async_read(socket, asio::buffer(m_msg.getBuffer(), HEADER_LENGTH), [self = shared_from_this()](const std::error_code &error, std::size_t N) { self->parseHeader(error); }); } catch (const std::system_error &e) { g_logger().error("[Connection::resumeWork] - Exception in async_read: {}", e.what()); close(FORCE_CLOSE); diff --git a/src/server/network/connection/connection.hpp b/src/server/network/connection/connection.hpp index 76d9b1c1876..0666ef35d8d 100644 --- a/src/server/network/connection/connection.hpp +++ b/src/server/network/connection/connection.hpp @@ -10,7 +10,7 @@ #pragma once #include "declarations.hpp" -#include "lib/di/container.hpp" +// TODO: Remove circular includes (maybe shared_ptr?) #include "server/network/message/networkmessage.hpp" static constexpr int32_t CONNECTION_WRITE_TIMEOUT = 30; @@ -28,14 +28,13 @@ using Service_ptr = std::shared_ptr; class ServicePort; using ServicePort_ptr = std::shared_ptr; using ConstServicePort_ptr = std::shared_ptr; +class NetworkMessage; class ConnectionManager { public: ConnectionManager() = default; - static ConnectionManager &getInstance() { - return inject(); - } + static ConnectionManager &getInstance(); Connection_ptr createConnection(asio::io_service &io_service, ConstServicePort_ptr servicePort); void releaseConnection(const Connection_ptr &connection); @@ -86,8 +85,6 @@ class Connection : public std::enable_shared_from_this { return socket; } - NetworkMessage msg; - asio::high_resolution_timer readTimer; asio::high_resolution_timer writeTimer; @@ -100,6 +97,8 @@ class Connection : public std::enable_shared_from_this { asio::ip::tcp::socket socket; + NetworkMessage m_msg; + std::time_t timeConnected = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); uint32_t packetsSent = 0; uint32_t ip = 1; diff --git a/src/server/network/message/networkmessage.cpp b/src/server/network/message/networkmessage.cpp index d8cb599a07c..3f7147e8411 100644 --- a/src/server/network/message/networkmessage.cpp +++ b/src/server/network/message/networkmessage.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "server/network/message/networkmessage.hpp" #include "items/containers/container.hpp" diff --git a/src/server/network/message/outputmessage.cpp b/src/server/network/message/outputmessage.cpp index efed7fe8367..bb4dab4526d 100644 --- a/src/server/network/message/outputmessage.cpp +++ b/src/server/network/message/outputmessage.cpp @@ -7,14 +7,18 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "outputmessage.hpp" + +#include "lib/di/container.hpp" #include "server/network/protocol/protocol.hpp" #include "game/scheduling/dispatcher.hpp" const std::chrono::milliseconds OUTPUTMESSAGE_AUTOSEND_DELAY { 10 }; +OutputMessagePool &OutputMessagePool::getInstance() { + return inject(); +} + void OutputMessagePool::scheduleSendAll() { g_dispatcher().scheduleEvent( OUTPUTMESSAGE_AUTOSEND_DELAY.count(), [this] { sendAll(); }, "OutputMessagePool::sendAll" diff --git a/src/server/network/message/outputmessage.hpp b/src/server/network/message/outputmessage.hpp index 459e243cea3..a7e2e72d63f 100644 --- a/src/server/network/message/outputmessage.hpp +++ b/src/server/network/message/outputmessage.hpp @@ -93,9 +93,7 @@ class OutputMessagePool { OutputMessagePool(const OutputMessagePool &) = delete; OutputMessagePool &operator=(const OutputMessagePool &) = delete; - static OutputMessagePool &getInstance() { - return inject(); - } + static OutputMessagePool &getInstance(); void sendAll(); void scheduleSendAll(); diff --git a/src/server/network/protocol/protocol.cpp b/src/server/network/protocol/protocol.cpp index c40ead17ab0..ce3d1339648 100644 --- a/src/server/network/protocol/protocol.cpp +++ b/src/server/network/protocol/protocol.cpp @@ -7,13 +7,17 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "server/network/protocol/protocol.hpp" + +#include "config/configmanager.hpp" +#include "server/network/connection/connection.hpp" #include "server/network/message/outputmessage.hpp" #include "security/rsa.hpp" #include "game/scheduling/dispatcher.hpp" +Protocol::Protocol(Connection_ptr initConnection) : + connectionPtr(initConnection) { } + void Protocol::onSendMessage(const OutputMessage_ptr &msg) { if (!rawMessages) { const uint32_t sendMessageChecksum = msg->getLength() >= 128 && compression(*msg) ? (1U << 31) : 0; @@ -109,17 +113,29 @@ OutputMessage_ptr Protocol::getOutputBuffer(int32_t size) { return outputBuffer; } -void Protocol::XTEA_encrypt(OutputMessage &msg) const { +void Protocol::send(OutputMessage_ptr msg) const { + if (auto connection = getConnection()) { + connection->send(msg); + } +} + +void Protocol::disconnect() const { + if (auto connection = getConnection()) { + connection->close(); + } +} + +void Protocol::XTEA_encrypt(OutputMessage &outputMessage) const { const uint32_t delta = 0x61C88647; // The message must be a multiple of 8 - size_t paddingBytes = msg.getLength() & 7; + size_t paddingBytes = outputMessage.getLength() & 7; if (paddingBytes != 0) { - msg.addPaddingBytes(8 - paddingBytes); + outputMessage.addPaddingBytes(8 - paddingBytes); } - uint8_t* buffer = msg.getOutputBuffer(); - auto messageLength = static_cast(msg.getLength()); + uint8_t* buffer = outputMessage.getOutputBuffer(); + auto messageLength = static_cast(outputMessage.getLength()); int32_t readPos = 0; const std::array newKey = { key[0], key[1], key[2], key[3] }; // TODO: refactor this for not use c-style @@ -193,6 +209,14 @@ bool Protocol::RSA_decrypt(NetworkMessage &msg) { return (msg.getByte() == 0); } +bool Protocol::isConnectionExpired() const { + return connectionPtr.expired(); +} + +Connection_ptr Protocol::getConnection() const { + return connectionPtr.lock(); +} + uint32_t Protocol::getIP() const { if (auto protocolConnection = getConnection()) { return protocolConnection->getIP(); @@ -201,7 +225,7 @@ uint32_t Protocol::getIP() const { return 0; } -bool Protocol::compression(OutputMessage &msg) const { +bool Protocol::compression(OutputMessage &outputMessage) const { if (checksumMethod != CHECKSUM_METHOD_SEQUENCE) { return false; } @@ -211,13 +235,13 @@ bool Protocol::compression(OutputMessage &msg) const { return false; } - const auto outputMessageSize = msg.getLength(); + const auto outputMessageSize = outputMessage.getLength(); if (outputMessageSize > NETWORKMESSAGE_MAXSIZE) { g_logger().error("[NetworkMessage::compression] - Exceded NetworkMessage max size: {}, actually size: {}", NETWORKMESSAGE_MAXSIZE, outputMessageSize); return false; } - compress->stream->next_in = msg.getOutputBuffer(); + compress->stream->next_in = outputMessage.getOutputBuffer(); compress->stream->avail_in = outputMessageSize; compress->stream->next_out = reinterpret_cast(compress->buffer.data()); compress->stream->avail_out = NETWORKMESSAGE_MAXSIZE; @@ -234,8 +258,25 @@ bool Protocol::compression(OutputMessage &msg) const { return false; } - msg.reset(); - msg.addBytes(compress->buffer.data(), totalSize); + outputMessage.reset(); + outputMessage.addBytes(compress->buffer.data(), totalSize); return true; } + +Protocol::ZStream::ZStream() noexcept { + const int32_t compressionLevel = g_configManager().getNumber(COMPRESSION_LEVEL, __FUNCTION__); + if (compressionLevel <= 0) { + return; + } + + stream = std::make_unique(); + stream->zalloc = nullptr; + stream->zfree = nullptr; + stream->opaque = nullptr; + + if (deflateInit2(stream.get(), compressionLevel, Z_DEFLATED, -15, 9, Z_DEFAULT_STRATEGY) != Z_OK) { + stream.reset(); + g_logger().error("[Protocol::enableCompression()] - Zlib deflateInit2 error: {}", (stream->msg ? stream->msg : " unknown error")); + } +} diff --git a/src/server/network/protocol/protocol.hpp b/src/server/network/protocol/protocol.hpp index 54e3dcfd4c3..033e2069ff5 100644 --- a/src/server/network/protocol/protocol.hpp +++ b/src/server/network/protocol/protocol.hpp @@ -9,13 +9,19 @@ #pragma once -#include "server/network/connection/connection.hpp" -#include "config/configmanager.hpp" +#include "server/server_definitions.hpp" + +class OutputMessage; +using OutputMessage_ptr = std::shared_ptr; +class Connection; +using Connection_ptr = std::shared_ptr; +using ConnectionWeak_ptr = std::weak_ptr; + +class NetworkMessage; class Protocol : public std::enable_shared_from_this { public: - explicit Protocol(Connection_ptr initConnection) : - connectionPtr(initConnection) { } + explicit Protocol(Connection_ptr initConnection); virtual ~Protocol() = default; @@ -31,13 +37,9 @@ class Protocol : public std::enable_shared_from_this { virtual void onRecvFirstMessage(NetworkMessage &msg) = 0; virtual void onConnect() { } - bool isConnectionExpired() const { - return connectionPtr.expired(); - } + bool isConnectionExpired() const; - Connection_ptr getConnection() const { - return connectionPtr.lock(); - } + Connection_ptr getConnection() const; uint32_t getIP() const; @@ -48,19 +50,10 @@ class Protocol : public std::enable_shared_from_this { return outputBuffer; } - void send(OutputMessage_ptr msg) const { - if (auto connection = getConnection(); - connection != nullptr) { - connection->send(msg); - } - } + void send(OutputMessage_ptr msg) const; protected: - void disconnect() const { - if (auto connection = getConnection()) { - connection->close(); - } - } + void disconnect() const; void enableXTEAEncryption() { encryptionEnabled = true; @@ -82,22 +75,7 @@ class Protocol : public std::enable_shared_from_this { private: struct ZStream { - ZStream() noexcept { - const int32_t compressionLevel = g_configManager().getNumber(COMPRESSION_LEVEL, __FUNCTION__); - if (compressionLevel <= 0) { - return; - } - - stream = std::make_unique(); - stream->zalloc = nullptr; - stream->zfree = nullptr; - stream->opaque = nullptr; - - if (deflateInit2(stream.get(), compressionLevel, Z_DEFLATED, -15, 9, Z_DEFAULT_STRATEGY) != Z_OK) { - stream.reset(); - g_logger().error("[Protocol::enableCompression()] - Zlib deflateInit2 error: {}", (stream->msg ? stream->msg : " unknown error")); - } - } + ZStream() noexcept; ~ZStream() { deflateEnd(stream.get()); diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index 560ae1168c5..e3d94942670 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "creatures/players/management/ban.hpp" #include "core.hpp" #include "declarations.hpp" @@ -984,7 +982,7 @@ void ProtocolGame::addBless() { player->checkAndShowBlessingMessage(); } -void ProtocolGame::parsePacketFromDispatcher(NetworkMessage msg, uint8_t recvbyte) { +void ProtocolGame::parsePacketFromDispatcher(NetworkMessage &msg, uint8_t recvbyte) { if (!acceptPackets || g_game().getGameState() == GAME_STATE_SHUTDOWN) { return; } diff --git a/src/server/network/protocol/protocolgame.hpp b/src/server/network/protocol/protocolgame.hpp index 769771c975a..fe83ed01cf1 100644 --- a/src/server/network/protocol/protocolgame.hpp +++ b/src/server/network/protocol/protocolgame.hpp @@ -96,7 +96,7 @@ class ProtocolGame final : public Protocol { // we have all the parse methods void parsePacket(NetworkMessage &msg) override; - void parsePacketFromDispatcher(NetworkMessage msg, uint8_t recvbyte); + void parsePacketFromDispatcher(NetworkMessage &msg, uint8_t recvbyte); void onRecvFirstMessage(NetworkMessage &msg) override; void onConnect() override; diff --git a/src/server/network/protocol/protocollogin.cpp b/src/server/network/protocol/protocollogin.cpp index 9cf6cc1c370..d3ee6030e1d 100644 --- a/src/server/network/protocol/protocollogin.cpp +++ b/src/server/network/protocol/protocollogin.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "server/network/protocol/protocollogin.hpp" #include "server/network/message/outputmessage.hpp" #include "game/scheduling/dispatcher.hpp" diff --git a/src/server/network/protocol/protocolstatus.cpp b/src/server/network/protocol/protocolstatus.cpp index 1e7e68e1542..4239d6f2300 100644 --- a/src/server/network/protocol/protocolstatus.cpp +++ b/src/server/network/protocol/protocolstatus.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "core.hpp" #include "server/network/protocol/protocolstatus.hpp" diff --git a/src/server/network/webhook/webhook.cpp b/src/server/network/webhook/webhook.cpp index f80ff4e59b3..7ee4ca31f09 100644 --- a/src/server/network/webhook/webhook.cpp +++ b/src/server/network/webhook/webhook.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "server/network/webhook/webhook.hpp" #include "config/configmanager.hpp" #include "game/scheduling/dispatcher.hpp" diff --git a/src/server/server.cpp b/src/server/server.cpp index fc8690468fe..5ed528f5045 100644 --- a/src/server/server.cpp +++ b/src/server/server.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "server/network/message/outputmessage.hpp" #include "server/server.hpp" #include "config/configmanager.hpp" diff --git a/src/server/server_definitions.hpp b/src/server/server_definitions.hpp index b957292b579..79dd89df511 100644 --- a/src/server/server_definitions.hpp +++ b/src/server/server_definitions.hpp @@ -9,6 +9,8 @@ #pragma once +#include "utils/const.hpp" + // Enums // Connection and networkmessage. enum { FORCE_CLOSE = true }; diff --git a/src/server/signals.cpp b/src/server/signals.cpp index ae71d833c93..cb4e083b60c 100644 --- a/src/server/signals.cpp +++ b/src/server/signals.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "game/game.hpp" #include "game/scheduling/dispatcher.hpp" #include "game/scheduling/save_manager.hpp" diff --git a/src/utils/pugicast.cpp b/src/utils/pugicast.cpp index 62717c33621..2269e62b1fb 100644 --- a/src/utils/pugicast.cpp +++ b/src/utils/pugicast.cpp @@ -6,7 +6,7 @@ * Contributors: https://github.com/opentibiabr/canary/graphs/contributors * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" + #include "lib/logging/log_with_spd_log.hpp" namespace pugi { diff --git a/src/utils/tools.cpp b/src/utils/tools.cpp index f89b2c2f217..8df1fde1065 100644 --- a/src/utils/tools.cpp +++ b/src/utils/tools.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "core.hpp" #include "items/item.hpp" #include "utils/tools.hpp" diff --git a/src/utils/wildcardtree.cpp b/src/utils/wildcardtree.cpp index 4fd830b64cb..a8ddf98e442 100644 --- a/src/utils/wildcardtree.cpp +++ b/src/utils/wildcardtree.cpp @@ -7,8 +7,6 @@ * Website: https://docs.opentibiabr.com/ */ -#include "pch.hpp" - #include "utils/wildcardtree.hpp" std::shared_ptr WildcardTreeNode::getChild(char ch) { diff --git a/tests/build_and_run.sh b/tests/build_and_run.sh index ac4ccad512c..f885525353f 100755 --- a/tests/build_and_run.sh +++ b/tests/build_and_run.sh @@ -1,14 +1,22 @@ #!/usr/bin/env bash +# Clean up existing containers, images and volumes and start over docker-compose down --rmi all -v --remove-orphans docker-compose up --build -d + +# Check if the build directory exists, if it doesn't exist it creates it cd .. if [ ! -d "build" ]; then mkdir build fi cd build || exit -cmake -DCMAKE_BUILD_TYPE=Debug -DPACKAGE_TESTS=On .. ; make -j"$(nproc)" + +# Configure the build using vcpkg and compile the project with 6 threads +cmake -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Debug -DPACKAGE_TESTS=On .. ; make -j"$(nproc)" + +# Run tests after compilation ./tests/unit/canary_ut --reporter compact --success -cd .. -cd tests || exit + +# Go back to the tests folder and clean the Docker environment again +cd ../tests || exit docker-compose down --rmi all -v --remove-orphans diff --git a/tests/integration/main.cpp b/tests/integration/main.cpp index 3a34285f163..6fb0c291e49 100644 --- a/tests/integration/main.cpp +++ b/tests/integration/main.cpp @@ -1,6 +1,7 @@ #include #include "account/account_repository_db.hpp" +#include "database/database.hpp" #include "lib/logging/in_memory_logger.hpp" #include "utils/tools.hpp" #include "enums/account_type.hpp" diff --git a/vcproj/canary.vcxproj b/vcproj/canary.vcxproj index 77ece957935..eafe0b8000c 100644 --- a/vcproj/canary.vcxproj +++ b/vcproj/canary.vcxproj @@ -414,9 +414,10 @@ - + Create Create + Create @@ -544,7 +545,7 @@ Level1 true stdcpp20 - + pch.hpp true ProgramDatabase true @@ -552,6 +553,7 @@ true /Zc:__cplusplus %(AdditionalOptions) _DISABLE_VECTOR_ANNOTATION;_DISABLE_STRING_ANNOTATION;NDEBUG;%(PreprocessorDefinitions) + Use Console @@ -594,14 +596,15 @@ false + NotUsing false + NotUsing - - + \ No newline at end of file