From adc23a0676aebdc8cfa14d77d448c3f5a2cae6f3 Mon Sep 17 00:00:00 2001 From: Zach Toogood Date: Thu, 21 Nov 2024 14:55:45 +0000 Subject: [PATCH] Run clang-format --- modules/renamer/cpp/renamer.cpp | 2 +- src/common/application.cpp | 2 +- src/common/application.h | 2 +- src/common/async.cpp | 6 +- src/common/async.h | 6 +- src/common/circular_buffer.h | 4 +- src/common/console_service.cpp | 2 +- src/common/console_service.h | 2 +- src/common/database.cpp | 2 +- src/common/database.h | 10 +- src/common/debug_linux.cpp | 4 +- src/common/filewatcher.cpp | 6 +- src/common/filewatcher.h | 4 +- src/common/logging.cpp | 6 +- src/common/logging.h | 6 +- src/common/lua.cpp | 6 +- src/common/lua.h | 2 +- src/common/mmo.h | 168 +++---- src/common/rng/mersennetwister.h | 4 +- src/common/rng/mersennetwister64.h | 4 +- src/common/rng/pcg.h | 4 +- src/common/rng/pcg64.h | 4 +- src/common/settings.cpp | 6 +- src/common/socket.cpp | 62 ++- src/common/socket.h | 8 +- src/common/sql.cpp | 10 +- src/common/sql.h | 4 +- src/common/string.h | 18 +- src/common/taskmgr.cpp | 4 +- src/common/taskmgr.h | 8 +- src/common/timer.cpp | 11 +- src/common/utils.cpp | 23 +- src/common/utils.h | 18 +- src/common/vana_time.cpp | 3 +- src/common/zlib.cpp | 8 +- src/login/auth_session.cpp | 18 +- src/login/cert_helpers.h | 4 +- src/login/connect_server.cpp | 8 +- src/login/data_session.cpp | 38 +- src/login/login_helpers.cpp | 42 +- src/login/login_helpers.h | 6 +- src/login/view_session.cpp | 23 +- src/map/ai/ai_container.cpp | 2 +- .../ai/controllers/automaton_controller.cpp | 79 ++- src/map/ai/controllers/mob_controller.cpp | 33 +- src/map/ai/controllers/pet_controller.cpp | 7 +- src/map/ai/controllers/trust_controller.cpp | 9 +- src/map/ai/helpers/event_handler.cpp | 6 +- src/map/ai/helpers/event_handler.h | 10 +- src/map/ai/helpers/gambits_container.cpp | 25 +- src/map/ai/helpers/gambits_container.h | 8 +- src/map/ai/helpers/targetfind.cpp | 10 +- src/map/ai/states/ability_state.cpp | 10 +- src/map/ai/states/attack_state.cpp | 3 +- src/map/ai/states/inactive_state.cpp | 3 +- src/map/ai/states/item_state.cpp | 3 +- src/map/ai/states/magic_state.cpp | 18 +- src/map/ai/states/magic_state.h | 2 +- src/map/ai/states/mobskill_state.cpp | 6 +- src/map/ai/states/range_state.cpp | 4 +- src/map/alliance.cpp | 16 +- src/map/attack.cpp | 17 +- src/map/attackround.cpp | 12 +- src/map/autotranslate.cpp | 4 +- src/map/autotranslate.h | 2 +- src/map/battlefield.cpp | 12 +- src/map/battlefield.h | 12 +- src/map/char_recast_container.cpp | 8 +- src/map/conquest_data.cpp | 4 +- src/map/conquest_data.h | 6 +- src/map/conquest_system.cpp | 8 +- src/map/conquest_system.h | 10 +- src/map/entities/baseentity.h | 2 +- src/map/entities/battleentity.cpp | 51 +- src/map/entities/battleentity.h | 2 +- src/map/entities/charentity.cpp | 57 +-- src/map/entities/charentity.h | 14 +- src/map/entities/mobentity.cpp | 4 +- src/map/entities/petentity.cpp | 2 +- src/map/entities/trustentity.cpp | 11 +- src/map/guild.h | 2 +- src/map/instance.cpp | 4 +- src/map/instance.h | 4 +- src/map/instance_loader.cpp | 8 +- src/map/item_container.cpp | 3 +- src/map/items/item.cpp | 10 +- src/map/items/item.h | 10 +- src/map/items/item_furnishing.cpp | 20 +- src/map/items/item_linkshell.cpp | 2 +- src/map/items/item_linkshell.h | 2 +- src/map/job_points.cpp | 73 ++- src/map/latent_effect.cpp | 11 +- src/map/linkshell.cpp | 11 +- src/map/los/common.h | 14 +- src/map/los/zone_los.cpp | 6 +- src/map/los/zone_los.h | 6 +- src/map/lua/lua_baseentity.cpp | 454 +++++++++--------- src/map/lua/lua_baseentity.h | 258 +++++----- src/map/lua/lua_battlefield.cpp | 23 +- src/map/lua/lua_battlefield.h | 8 +- src/map/lua/lua_instance.cpp | 6 +- src/map/lua/lua_instance.h | 6 +- src/map/lua/lua_item.cpp | 6 +- src/map/lua/lua_item.h | 4 +- src/map/lua/lua_loot.cpp | 6 +- src/map/lua/lua_loot.h | 6 +- src/map/lua/lua_trade_container.cpp | 10 +- src/map/lua/lua_trade_container.h | 10 +- src/map/lua/lua_zone.cpp | 6 +- src/map/lua/lua_zone.h | 2 +- src/map/lua/luautils.cpp | 80 ++- src/map/lua/luautils.h | 44 +- src/map/map.cpp | 29 +- src/map/merit.cpp | 14 +- src/map/merit.h | 2 +- src/map/message.cpp | 24 +- src/map/message.h | 10 +- src/map/mob_spell_container.cpp | 31 +- src/map/mob_spell_list.cpp | 2 +- src/map/monstrosity.cpp | 49 +- src/map/navmesh.cpp | 4 +- src/map/navmesh.h | 2 +- src/map/packet_system.cpp | 189 +++----- src/map/packets/campaign_map.cpp | 2 +- src/map/packets/campaign_map.h | 2 +- src/map/packets/char.h | 158 +++--- src/map/packets/char_emote_list.h | 4 +- src/map/packets/char_jobs.cpp | 5 +- src/map/packets/char_update.cpp | 112 ++--- src/map/packets/chat_message.cpp | 4 +- src/map/packets/chat_message.h | 2 +- src/map/packets/delivery_box.cpp | 4 +- src/map/packets/event_string.cpp | 2 +- src/map/packets/event_update.cpp | 2 +- src/map/packets/event_update.h | 2 +- src/map/packets/event_update_string.cpp | 6 +- src/map/packets/event_update_string.h | 6 +- src/map/packets/fishing.cpp | 9 +- src/map/packets/fishing.h | 2 +- src/map/packets/menu_config.cpp | 2 +- src/map/packets/message_name.cpp | 4 +- src/map/packets/message_name.h | 2 +- src/map/packets/message_special.h | 2 +- src/map/packets/send_blacklist.cpp | 2 +- src/map/packets/zone_in.cpp | 4 +- src/map/party.cpp | 26 +- src/map/recast_container.cpp | 6 +- src/map/roe.cpp | 6 +- src/map/roe.h | 10 +- src/map/spell.cpp | 12 +- src/map/status_effect_container.cpp | 118 ++--- src/map/treasure_pool.cpp | 4 +- src/map/utils/attackutils.h | 2 +- src/map/utils/battleutils.cpp | 173 +++---- src/map/utils/battleutils.h | 6 +- src/map/utils/blueutils.cpp | 2 +- src/map/utils/charutils.cpp | 281 +++++------ src/map/utils/charutils.h | 24 +- src/map/utils/fishingcontest.cpp | 47 +- src/map/utils/fishingcontest.h | 6 +- src/map/utils/fishingutils.cpp | 30 +- src/map/utils/fishingutils.h | 12 +- src/map/utils/gardenutils.cpp | 3 +- src/map/utils/guildutils.cpp | 6 +- src/map/utils/instanceutils.cpp | 37 +- src/map/utils/mobutils.cpp | 97 +--- src/map/utils/moduleutils.cpp | 14 +- src/map/utils/moduleutils.h | 10 +- src/map/utils/petutils.cpp | 34 +- src/map/utils/puppetutils.cpp | 7 +- src/map/utils/serverutils.cpp | 10 +- src/map/utils/serverutils.h | 10 +- src/map/utils/synergyutils.cpp | 9 +- src/map/utils/synthutils.cpp | 18 +- src/map/utils/trustutils.cpp | 26 +- src/map/utils/zoneutils.cpp | 2 +- src/map/utils/zoneutils.h | 2 +- src/map/zone.cpp | 37 +- src/map/zone.h | 20 +- src/map/zone_entities.cpp | 6 +- src/map/zone_instance.cpp | 4 +- src/search/data_loader.cpp | 48 +- src/search/packets/search_comment.cpp | 5 +- src/search/packets/search_comment.h | 5 +- src/search/search.cpp | 20 +- src/search/tcp_request.cpp | 2 +- src/world/conquest_system.cpp | 8 +- src/world/conquest_system.h | 4 +- src/world/message_server.cpp | 10 +- src/world/message_server.h | 4 +- 190 files changed, 1813 insertions(+), 2289 deletions(-) diff --git a/modules/renamer/cpp/renamer.cpp b/modules/renamer/cpp/renamer.cpp index 9c78f68b48b..b89d3d207c4 100644 --- a/modules/renamer/cpp/renamer.cpp +++ b/modules/renamer/cpp/renamer.cpp @@ -7,7 +7,7 @@ extern std::function #endif -Application::Application(std::string const& serverName, int argc, char** argv) +Application::Application(const std::string& serverName, int argc, char** argv) : m_ServerName(serverName) , m_RequestExit(false) , gArgParser(std::make_unique(argv[0])) diff --git a/src/common/application.h b/src/common/application.h index fbcb07ec10c..961a24f57db 100644 --- a/src/common/application.h +++ b/src/common/application.h @@ -31,7 +31,7 @@ class Application { public: - Application(std::string const& serverName, int argc, char** argv); + Application(const std::string& serverName, int argc, char** argv); virtual ~Application() = default; Application(const Application&) = delete; diff --git a/src/common/async.cpp b/src/common/async.cpp index baf12155ec7..40c7f49eb0a 100644 --- a/src/common/async.cpp +++ b/src/common/async.cpp @@ -29,7 +29,7 @@ Async::Async() { } -void Async::query(std::string const& query) +void Async::query(const std::string& query) { // clang-format off this->schedule([query]() @@ -49,7 +49,7 @@ void Async::query(std::string const& query) // : If you define your arg as _sql, but then call sql, it will use the global // : SQLConnection, which is on the main thread. // : Remember that SQLConnection is NOT THREAD-SAFE! -void Async::query(std::function const& func) +void Async::query(const std::function& func) { // clang-format off this->schedule([func]() @@ -65,7 +65,7 @@ void Async::query(std::function const& func) // clang-format on } -void Async::submit(std::function const& func) +void Async::submit(const std::function& func) { // clang-format off this->schedule([func]() diff --git a/src/common/async.h b/src/common/async.h index dbfe39aa1a6..04c562353bf 100644 --- a/src/common/async.h +++ b/src/common/async.h @@ -31,9 +31,9 @@ class Async : public Singleton, private ts::task_system { public: - void query(std::string const& query); - void query(std::function const& func); - void submit(std::function const& func); + void query(const std::string& query); + void query(const std::function& func); + void submit(const std::function& func); protected: Async(); diff --git a/src/common/circular_buffer.h b/src/common/circular_buffer.h index 6199124c917..a91fa0af994 100644 --- a/src/common/circular_buffer.h +++ b/src/common/circular_buffer.h @@ -22,9 +22,9 @@ class CircularBuffer public: CircularBuffer(std::size_t max_size) : buffer(std::unique_ptr(new T[max_size])) - , max_size(max_size){}; + , max_size(max_size) {}; - void enqueue(T const& item) + void enqueue(const T& item) { std::lock_guard lock(mutex); diff --git a/src/common/console_service.cpp b/src/common/console_service.cpp index 058066a5484..e56583d0b31 100644 --- a/src/common/console_service.cpp +++ b/src/common/console_service.cpp @@ -214,7 +214,7 @@ ConsoleService::~ConsoleService() // NOTE: If you capture things in this function, make sure they're protected (locked or atomic)! // NOTE: If you're going to print, use fmt::print, rather than ShowInfo etc. -void ConsoleService::RegisterCommand(std::string const& name, std::string const& description, std::function&)> func) +void ConsoleService::RegisterCommand(const std::string& name, const std::string& description, std::function&)> func) { std::lock_guard lock(m_consoleInputBottleneck); diff --git a/src/common/console_service.h b/src/common/console_service.h index f1c40cbf1e2..7ee8d95ae46 100644 --- a/src/common/console_service.h +++ b/src/common/console_service.h @@ -56,7 +56,7 @@ class ConsoleService // NOTE: If you capture things in this function, make sure they're protected (locked or atomic)! // NOTE: If you're going to print, use fmt::print, rather than ShowInfo etc. - void RegisterCommand(std::string const& name, std::string const& description, std::function&)> func); + void RegisterCommand(const std::string& name, const std::string& description, std::function&)> func); // Call this to stop processing commands void stop(); diff --git a/src/common/database.cpp b/src/common/database.cpp index a65b5b001ee..4c77e49489b 100644 --- a/src/common/database.cpp +++ b/src/common/database.cpp @@ -127,7 +127,7 @@ mutex_guarded& db::detail::getState() return state; } -std::unique_ptr db::query(std::string const& rawQuery) +std::unique_ptr db::query(const std::string& rawQuery) { TracyZoneScoped; TracyZoneString(rawQuery); diff --git a/src/common/database.h b/src/common/database.h index 8aa6a2f57b7..7b64cd8f37d 100644 --- a/src/common/database.h +++ b/src/common/database.h @@ -55,7 +55,7 @@ namespace db auto getState() -> mutex_guarded&; - auto sanitise(std::string const& query) -> std::string; + auto sanitise(const std::string& query) -> std::string; // Helpers to provide information to the static_assert below template @@ -156,7 +156,7 @@ namespace db // @param query The query string to execute. // @return A unique pointer to the result set of the query. // @note Everything in database-land is 1-indexed, not 0-indexed. - auto query(std::string const& rawQuery) -> std::unique_ptr; + auto query(const std::string& rawQuery) -> std::unique_ptr; // @brief Execute a prepared statement with the given query string and arguments. // @param query The query string to execute. @@ -165,7 +165,7 @@ namespace db // @note If the query hasn't been seen before it will generate a prepared statement for it to be used immediately and in the future. // @note Everything in database-land is 1-indexed, not 0-indexed. template - std::unique_ptr preparedStmt(std::string const& rawQuery, Args&&... args) + std::unique_ptr preparedStmt(const std::string& rawQuery, Args&&... args) { TracyZoneScoped; TracyZoneString(rawQuery); @@ -222,7 +222,7 @@ namespace db // @note This is a workaround for the fact that MariaDB's C++ connector hasn't yet implemented ResultSet::rowUpdated(), ResultSet::rowInserted(), // and ResultSet::rowDeleted(). template - std::pair, std::size_t> preparedStmtWithAffectedRows(std::string const& rawQuery, Args&&... args) + std::pair, std::size_t> preparedStmtWithAffectedRows(const std::string& rawQuery, Args&&... args) { TracyZoneScoped; TracyZoneString(rawQuery); @@ -360,7 +360,7 @@ namespace db // @param blobKey The key of the blob in the result set. // @param destination The struct to extract the blob into. template - void extractFromBlob(std::unique_ptr& rset, std::string const& blobKey, T& destination) + void extractFromBlob(std::unique_ptr& rset, const std::string& blobKey, T& destination) { static_assert(std::is_trivially_copyable_v, "T must be trivially copyable"); diff --git a/src/common/debug_linux.cpp b/src/common/debug_linux.cpp index 9680e933e2f..770b370a7d8 100644 --- a/src/common/debug_linux.cpp +++ b/src/common/debug_linux.cpp @@ -65,9 +65,7 @@ void dumpBacktrace(int signal) void debug::init() { - struct rlimit core_limits - { - }; + struct rlimit core_limits{}; core_limits.rlim_cur = core_limits.rlim_max = RLIM_INFINITY; setrlimit(RLIMIT_CORE, &core_limits); diff --git a/src/common/filewatcher.cpp b/src/common/filewatcher.cpp index 47878f06a8e..95fe2e92bbe 100644 --- a/src/common/filewatcher.cpp +++ b/src/common/filewatcher.cpp @@ -28,7 +28,7 @@ #include #include -Filewatcher::Filewatcher(std::vector const& paths) +Filewatcher::Filewatcher(const std::vector& paths) #ifdef USE_GENERIC_FILEWATCHER : fileWatcherImpl(std::make_unique(true)) #else @@ -53,7 +53,7 @@ Filewatcher::~Filewatcher() } // cppcheck-suppress passedByValue -void Filewatcher::handleFileAction(efsw::WatchID watchid, std::string const& dir, std::string const& filename, efsw::Action action, std::string oldFilename) +void Filewatcher::handleFileAction(efsw::WatchID watchid, const std::string& dir, const std::string& filename, efsw::Action action, std::string oldFilename) { TracySetThreadName("Filewatcher Thread"); TracyZoneScoped; @@ -97,7 +97,7 @@ auto Filewatcher::getChangedLuaFiles() -> std::vector> results; results.reserve(actions.size()); - for (auto const& [path, action] : actions) + for (const auto& [path, action] : actions) { results.emplace_back(path, action); } diff --git a/src/common/filewatcher.h b/src/common/filewatcher.h index 9606db5b0e1..c291f2d5a34 100644 --- a/src/common/filewatcher.h +++ b/src/common/filewatcher.h @@ -34,13 +34,13 @@ class Filewatcher : public efsw::FileWatchListener { public: - Filewatcher(std::vector const& paths); + Filewatcher(const std::vector& paths); ~Filewatcher() override; DISALLOW_COPY_AND_MOVE(Filewatcher); // efsw::FileWatchListener - void handleFileAction(efsw::WatchID watchid, std::string const& dir, std::string const& filename, efsw::Action action, std::string oldFilename) override; + void handleFileAction(efsw::WatchID watchid, const std::string& dir, const std::string& filename, efsw::Action action, std::string oldFilename) override; enum class Action { diff --git a/src/common/logging.cpp b/src/common/logging.cpp index 281f48c8238..83d2ccee688 100755 --- a/src/common/logging.cpp +++ b/src/common/logging.cpp @@ -127,7 +127,7 @@ namespace logging "trace", }; - void InitializeLog(std::string const& serverName, std::string const& logFile, bool appendDate) + void InitializeLog(const std::string& serverName, const std::string& logFile, bool appendDate) { ServerName = serverName; @@ -168,7 +168,7 @@ namespace logging spdlog::shutdown(); } - void SetPattern(std::string const& str) + void SetPattern(const std::string& str) { // https://github.com/gabime/spdlog/wiki/3.-Custom-formatting auto formatter = std::make_unique(); @@ -180,7 +180,7 @@ namespace logging spdlog::set_formatter(std::move(formatter)); } - void AddBacktrace(std::string const& str) + void AddBacktrace(const std::string& str) { BacktraceBuffer.enqueue(str); } diff --git a/src/common/logging.h b/src/common/logging.h index 693cf66ebd2..5c5cfa7f332 100644 --- a/src/common/logging.h +++ b/src/common/logging.h @@ -53,12 +53,12 @@ namespace settings namespace logging { - void InitializeLog(std::string const& serverName, std::string const& logFile, bool appendDate); + void InitializeLog(const std::string& serverName, const std::string& logFile, bool appendDate); void ShutDown(); - void SetPattern(std::string const& str); + void SetPattern(const std::string& str); - void AddBacktrace(std::string const& str); + void AddBacktrace(const std::string& str); auto GetBacktrace() -> std::vector; } // namespace logging diff --git a/src/common/lua.cpp b/src/common/lua.cpp index 121e208d5ec..4749c39baf0 100644 --- a/src/common/lua.cpp +++ b/src/common/lua.cpp @@ -71,7 +71,7 @@ void lua_init() /** * @brief */ -std::string lua_to_string_depth(sol::object const& obj, std::size_t depth) +std::string lua_to_string_depth(const sol::object& obj, std::size_t depth) { switch (obj.get_type()) { @@ -135,7 +135,7 @@ std::string lua_to_string_depth(sol::object const& obj, std::size_t depth) // Stringify everything first std::vector stringVec; - for (auto const& [keyObj, valObj] : table) + for (const auto& [keyObj, valObj] : table) { if (keyObj.get_type() == sol::type::string) { @@ -206,7 +206,7 @@ void lua_print(sol::variadic_args va) std::string lua_fmt(std::string fmtStr, sol::variadic_args va) { fmt::dynamic_format_arg_store store; - for (auto const& arg : va) + for (const auto& arg : va) { switch (arg.get_type()) { diff --git a/src/common/lua.h b/src/common/lua.h index 5a68598d9c6..11d73025c3f 100644 --- a/src/common/lua.h +++ b/src/common/lua.h @@ -28,7 +28,7 @@ extern sol::state lua; void lua_init(); -auto lua_to_string_depth(sol::object const& obj, std::size_t depth) -> std::string; +auto lua_to_string_depth(const sol::object& obj, std::size_t depth) -> std::string; auto lua_to_string(sol::variadic_args va) -> std::string; void lua_print(sol::variadic_args va); auto lua_fmt(std::string fmtStr, sol::variadic_args va) -> std::string; diff --git a/src/common/mmo.h b/src/common/mmo.h index 3084efa365c..fbcfebdf3fd 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -177,101 +177,101 @@ constexpr auto msgTypeToStr = [](uint8 msgtype) // See https://github.com/atom0s/XiPackets/tree/main/world/server/0x00B4 struct filters1_t { - uint32_t say : 1; - uint32_t shout : 1; - uint32_t unused02 : 1; - uint32_t emotes : 1; - uint32_t special_actions_started_on_by_you : 1; - uint32_t special_action_effects_on_by_you : 1; - uint32_t attacks_by_you : 1; - uint32_t missed_attacks_by_you : 1; - uint32_t attacks_you_evade : 1; - uint32_t damage_you_take : 1; - uint32_t special_action_effects_on_by_npcs : 1; - uint32_t attacks_by_npcs : 1; - uint32_t missed_attacks_by_npcs : 1; - uint32_t special_action_effects_on_by_party : 1; - uint32_t attacks_by_party : 1; - uint32_t missed_attacks_by_party : 1; - uint32_t attacks_evaded_by_party : 1; - uint32_t damage_taken_by_party : 1; - uint32_t special_action_effects_on_by_allies : 1; - uint32_t attacks_by_allies : 1; - uint32_t missed_attacks_by_allies : 1; - uint32_t attacks_evaded_by_allies : 1; - uint32_t damage_taken_by_allies : 1; - uint32_t special_actions_started_on_by_party : 1; + uint32_t say : 1; + uint32_t shout : 1; + uint32_t unused02 : 1; + uint32_t emotes : 1; + uint32_t special_actions_started_on_by_you : 1; + uint32_t special_action_effects_on_by_you : 1; + uint32_t attacks_by_you : 1; + uint32_t missed_attacks_by_you : 1; + uint32_t attacks_you_evade : 1; + uint32_t damage_you_take : 1; + uint32_t special_action_effects_on_by_npcs : 1; + uint32_t attacks_by_npcs : 1; + uint32_t missed_attacks_by_npcs : 1; + uint32_t special_action_effects_on_by_party : 1; + uint32_t attacks_by_party : 1; + uint32_t missed_attacks_by_party : 1; + uint32_t attacks_evaded_by_party : 1; + uint32_t damage_taken_by_party : 1; + uint32_t special_action_effects_on_by_allies : 1; + uint32_t attacks_by_allies : 1; + uint32_t missed_attacks_by_allies : 1; + uint32_t attacks_evaded_by_allies : 1; + uint32_t damage_taken_by_allies : 1; + uint32_t special_actions_started_on_by_party : 1; uint32_t special_actions_started_on_by_allies : 1; - uint32_t special_actions_started_on_by_npcs : 1; + uint32_t special_actions_started_on_by_npcs : 1; uint32_t others_synthesis_and_fishing_results : 1; - uint32_t lot_results : 1; - uint32_t attacks_by_others : 1; - uint32_t missed_attacks_by_others : 1; - uint32_t unused30 : 1; - uint32_t unused31 : 1; + uint32_t lot_results : 1; + uint32_t attacks_by_others : 1; + uint32_t missed_attacks_by_others : 1; + uint32_t unused30 : 1; + uint32_t unused31 : 1; }; struct filters2_t { - uint32_t attacks_evaded_by_others : 1; - uint32_t damage_taken_by_others : 1; - uint32_t special_action_effects_on_by_others : 1; + uint32_t attacks_evaded_by_others : 1; + uint32_t damage_taken_by_others : 1; + uint32_t special_action_effects_on_by_others : 1; uint32_t special_actions_started_on_by_others : 1; - uint32_t attacks_by_foes : 1; - uint32_t missed_attacks_by_foes : 1; - uint32_t attacks_evaded_by_foes : 1; - uint32_t damage_taken_by_foes : 1; - uint32_t special_action_effects_on_by_foes : 1; - uint32_t special_actions_started_on_by_foes : 1; - uint32_t campaign_related_data : 1; - uint32_t tell_messages_deemed_spam : 1; - uint32_t shout_yell_messages_deemed_spam : 1; - uint32_t unused13 : 1; - uint32_t unused14 : 1; - uint32_t job_specific_emote : 1; - uint32_t yell : 1; - uint32_t messages_from_alter_egos : 1; - uint32_t unused18 : 1; - uint32_t assist_j : 1; - uint32_t assist_e : 1; - uint32_t unused21 : 1; - uint32_t unused22 : 1; - uint32_t unused23 : 1; - uint32_t unused24 : 1; - uint32_t unused25 : 1; - uint32_t unused26 : 1; - uint32_t unused27 : 1; - uint32_t unused28 : 1; - uint32_t unused29 : 1; - uint32_t unused30 : 1; - uint32_t unused31 : 1; + uint32_t attacks_by_foes : 1; + uint32_t missed_attacks_by_foes : 1; + uint32_t attacks_evaded_by_foes : 1; + uint32_t damage_taken_by_foes : 1; + uint32_t special_action_effects_on_by_foes : 1; + uint32_t special_actions_started_on_by_foes : 1; + uint32_t campaign_related_data : 1; + uint32_t tell_messages_deemed_spam : 1; + uint32_t shout_yell_messages_deemed_spam : 1; + uint32_t unused13 : 1; + uint32_t unused14 : 1; + uint32_t job_specific_emote : 1; + uint32_t yell : 1; + uint32_t messages_from_alter_egos : 1; + uint32_t unused18 : 1; + uint32_t assist_j : 1; + uint32_t assist_e : 1; + uint32_t unused21 : 1; + uint32_t unused22 : 1; + uint32_t unused23 : 1; + uint32_t unused24 : 1; + uint32_t unused25 : 1; + uint32_t unused26 : 1; + uint32_t unused27 : 1; + uint32_t unused28 : 1; + uint32_t unused29 : 1; + uint32_t unused30 : 1; + uint32_t unused31 : 1; }; struct SAVE_CONF { - uint8_t InviteFlg : 1; - uint8_t AwayFlg : 1; + uint8_t InviteFlg : 1; + uint8_t AwayFlg : 1; uint8_t AnonymityFlg : 1; - uint8_t Language : 2; - uint8_t unknown05 : 3; + uint8_t Language : 2; + uint8_t unknown05 : 3; - uint8_t unknown08 : 1; - uint8_t unknown09 : 1; - uint8_t unknown10 : 1; + uint8_t unknown08 : 1; + uint8_t unknown09 : 1; + uint8_t unknown10 : 1; uint8_t SysMesFilterLevel : 2; - uint8_t unknown13 : 1; - uint8_t AutoTargetOffFlg : 1; - uint8_t AutoPartyFlg : 1; + uint8_t unknown13 : 1; + uint8_t AutoTargetOffFlg : 1; + uint8_t AutoPartyFlg : 1; uint8_t unknown16 : 8; - uint8_t MentorUnlockedFlg : 1; - uint8_t MentorFlg : 1; + uint8_t MentorUnlockedFlg : 1; + uint8_t MentorFlg : 1; uint8_t NewAdventurerOffFlg : 1; - uint8_t DisplayHeadOffFlg : 1; - uint8_t unknown28 : 1; - uint8_t RecruitFlg : 1; - uint8_t unused : 2; + uint8_t DisplayHeadOffFlg : 1; + uint8_t unknown28 : 1; + uint8_t RecruitFlg : 1; + uint8_t unused : 2; filters1_t MassageFilter; filters2_t MassageFilter2; @@ -282,11 +282,11 @@ struct SAVE_CONF struct languages_t { uint8_t Japanese : 1; - uint8_t English : 1; - uint8_t German : 1; - uint8_t French : 1; - uint8_t Other : 1; - uint8_t unused : 3; + uint8_t English : 1; + uint8_t German : 1; + uint8_t French : 1; + uint8_t Other : 1; + uint8_t unused : 3; }; // For characters, the size is stored in `size`. @@ -662,14 +662,14 @@ class char_mini m_zone = 0; m_nation = 0; }; - ~char_mini(){}; + ~char_mini() {}; }; // https://github.com/atom0s/XiPackets/tree/main/world/client/0x000A // Defined here for use in both map.cpp and packet_system.cpp struct GP_CLI_LOGIN { - uint16_t id : 9; + uint16_t id : 9; uint16_t size : 7; uint16_t sync; uint8_t LoginPacketCheck; // PS2: LoginPacketCheck diff --git a/src/common/rng/mersennetwister.h b/src/common/rng/mersennetwister.h index 339ab6a3ee6..86cc0b8f314 100644 --- a/src/common/rng/mersennetwister.h +++ b/src/common/rng/mersennetwister.h @@ -47,12 +47,12 @@ class xirand { // start with a C++ equivalent of time(nullptr) - UNIX time in seconds *it = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()) + std::chrono::system_clock::now().time_since_epoch()) .count(); // mix with a high precision time in microseconds *it ^= std::chrono::duration_cast( - std::chrono::high_resolution_clock::now().time_since_epoch()) + std::chrono::high_resolution_clock::now().time_since_epoch()) .count(); // *it ^= more_external_random_stuff; diff --git a/src/common/rng/mersennetwister64.h b/src/common/rng/mersennetwister64.h index 4eaf42ae888..39cb1be5ec2 100644 --- a/src/common/rng/mersennetwister64.h +++ b/src/common/rng/mersennetwister64.h @@ -47,12 +47,12 @@ class xirand { // start with a C++ equivalent of time(nullptr) - UNIX time in seconds *it = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()) + std::chrono::system_clock::now().time_since_epoch()) .count(); // mix with a high precision time in microseconds *it ^= std::chrono::duration_cast( - std::chrono::high_resolution_clock::now().time_since_epoch()) + std::chrono::high_resolution_clock::now().time_since_epoch()) .count(); // *it ^= more_external_random_stuff; diff --git a/src/common/rng/pcg.h b/src/common/rng/pcg.h index cbe3060ea66..9b389e0f02a 100644 --- a/src/common/rng/pcg.h +++ b/src/common/rng/pcg.h @@ -50,12 +50,12 @@ class xirand { // start with a C++ equivalent of time(nullptr) - UNIX time in seconds *it = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()) + std::chrono::system_clock::now().time_since_epoch()) .count(); // mix with a high precision time in microseconds *it ^= std::chrono::duration_cast( - std::chrono::high_resolution_clock::now().time_since_epoch()) + std::chrono::high_resolution_clock::now().time_since_epoch()) .count(); // *it ^= more_external_random_stuff; diff --git a/src/common/rng/pcg64.h b/src/common/rng/pcg64.h index b2e15e2419b..27b9b23d1c9 100644 --- a/src/common/rng/pcg64.h +++ b/src/common/rng/pcg64.h @@ -50,12 +50,12 @@ class xirand { // start with a C++ equivalent of time(nullptr) - UNIX time in seconds *it = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()) + std::chrono::system_clock::now().time_since_epoch()) .count(); // mix with a high precision time in microseconds *it ^= std::chrono::duration_cast( - std::chrono::high_resolution_clock::now().time_since_epoch()) + std::chrono::high_resolution_clock::now().time_since_epoch()) .count(); // *it ^= more_external_random_stuff; diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 1c23d1ad715..2af30dd2cbf 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -39,7 +39,7 @@ namespace settings // so we can pass them to the lua settings properly typed. bool isNumber(const std::string& stringValue) { - for (char const c : stringValue) + for (const char c : stringValue) { if (std::isdigit(c) == 0) { @@ -58,7 +58,7 @@ namespace settings void init() { // Load defaults - for (auto const& entry : sorted_directory_iterator("./settings/default/")) + for (const auto& entry : sorted_directory_iterator("./settings/default/")) { auto path = entry.relative_path(); auto isLua = path.extension() == ".lua"; @@ -121,7 +121,7 @@ namespace settings } // Load user settings - for (auto const& entry : sorted_directory_iterator("./settings/")) + for (const auto& entry : sorted_directory_iterator("./settings/")) { auto path = entry.relative_path(); auto isLua = path.extension() == ".lua"; diff --git a/src/common/socket.cpp b/src/common/socket.cpp index 9d633d4a097..c4e979013db 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -182,11 +182,9 @@ time_t stall_time = 60; int32 makeConnection(uint32 ip, uint16 port, int32 type) { TracyZoneScoped; - struct sockaddr_in remote_address - { - }; - int32 fd = 0; - int32 result = 0; + struct sockaddr_in remote_address{}; + int32 fd = 0; + int32 result = 0; fd = sSocket(AF_INET, type, 0); @@ -204,14 +202,12 @@ int32 makeConnection(uint32 ip, uint16 port, int32 type) if (fd >= MAX_FD) { // socket number too big ShowError("make_connection: New socket #%d is greater than can we handle! Increase the value of MAX_FD (currently %d) for your OS to fix this!", - fd, MAX_FD); + fd, MAX_FD); sClose(fd); return -1; } - struct linger opt - { - }; + struct linger opt{}; opt.l_onoff = 0; // SO_DONTLINGER opt.l_linger = 0; // Do not care if (sSetsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&opt, sizeof(opt))) @@ -422,7 +418,7 @@ static int connect_check_(uint32 ip) int connect_ok = 0; // Search the allow list - for (auto const& entry : access_allow) + for (const auto& entry : access_allow) { if ((ip & entry.mask) == (entry.ip & entry.mask)) { @@ -430,16 +426,16 @@ static int connect_check_(uint32 ip) { ShowInfo( fmt::format("connect_check: Found match from allow list:{} IP:{} Mask:{}", - ip2str(ip), - ip2str(entry.ip), - ip2str(entry.mask))); + ip2str(ip), + ip2str(entry.ip), + ip2str(entry.mask))); } is_allowip = 1; break; } } // Search the deny list - for (auto const& entry : access_deny) + for (const auto& entry : access_deny) { if ((ip & entry.mask) == (entry.ip & entry.mask)) { @@ -447,9 +443,9 @@ static int connect_check_(uint32 ip) { ShowInfo( fmt::format("connect_check: Found match from deny list:{} IP:{} Mask:{}", - ip2str(ip), - ip2str(entry.ip), - ip2str(entry.mask))); + ip2str(ip), + ip2str(entry.ip), + ip2str(entry.mask))); } is_denyip = 1; break; @@ -598,10 +594,10 @@ int access_ipmask(const char* str, AccessControl* acc) else { if (((n = sscanf(str, "%u.%u.%u.%u/%u.%u.%u.%u", a, a + 1, a + 2, a + 3, m, m + 1, m + 2, m + 3)) != 8 && // not an ip + standard mask - (n = sscanf(str, "%u.%u.%u.%u/%u", a, a + 1, a + 2, a + 3, m)) != 5 && // not an ip + bit mask - (n = sscanf(str, "%u.%u.%u.%u", a, a + 1, a + 2, a + 3)) != 4) || // not an ip - a[0] > 255 || - a[1] > 255 || a[2] > 255 || a[3] > 255 || // invalid ip + (n = sscanf(str, "%u.%u.%u.%u/%u", a, a + 1, a + 2, a + 3, m)) != 5 && // not an ip + bit mask + (n = sscanf(str, "%u.%u.%u.%u", a, a + 1, a + 2, a + 3)) != 4) + || // not an ip + a[0] > 255 || a[1] > 255 || a[2] > 255 || a[3] > 255 || // invalid ip (n == 8 && (m[0] > 255 || m[1] > 255 || m[2] > 255 || m[3] > 255)) || // invalid standard mask (n == 5 && m[0] > 32)) { // invalid bit mask @@ -785,7 +781,7 @@ int connect_client(int listen_fd, sockaddr_in& client_address) if (fd >= MAX_FD) { // socket number too big ShowError("connect_client: New socket #%d is greater than can we handle! Increase the value of MAX_FD (currently %d) for your OS to fix this!", - fd, MAX_FD); + fd, MAX_FD); sClose(fd); return -1; } @@ -809,11 +805,9 @@ int connect_client(int listen_fd, sockaddr_in& client_address) int32 makeListenBind_tcp(const char* ip, uint16 port, RecvFunc connect_client) { TracyZoneScoped; - struct sockaddr_in server_address - { - }; - int fd = 0; - int result = 0; + struct sockaddr_in server_address{}; + int fd = 0; + int result = 0; fd = sSocket(AF_INET, SOCK_STREAM, 0); @@ -834,7 +828,7 @@ int32 makeListenBind_tcp(const char* ip, uint16 port, RecvFunc connect_client) if (fd >= MAX_FD) { // socket number too big ShowError("make_listen_bind: New socket #%d is greater than can we handle! Increase the value of MAX_FD (currently %d) for your OS to fix this!", - fd, MAX_FD); + fd, MAX_FD); sClose(fd); return -1; } @@ -927,7 +921,7 @@ void do_close_tcp(int32 fd) /// The access list that we are parsing for individual entries. /// std::vector collection that contains all AccessControl entries. /// -std::vector get_access_list(std::string const& access_list) +std::vector get_access_list(const std::string& access_list) { // with the provided comma delimited access list, we will convert into a // vector of string entries @@ -1210,11 +1204,9 @@ void set_nonblocking(int fd, unsigned long yes) int32 makeBind_udp(uint32 ip, uint16 port) { TracyZoneScoped; - struct sockaddr_in server_address - { - }; - int fd = 0; - int result = 0; + struct sockaddr_in server_address{}; + int fd = 0; + int result = 0; fd = sSocket(AF_INET, SOCK_DGRAM, 0); @@ -1232,7 +1224,7 @@ int32 makeBind_udp(uint32 ip, uint16 port) if (fd >= MAX_FD) { // socket number too big ShowError("make_listen_bind: New socket #%d is greater than can we handle! Increase the value of MAX_FD (currently %d) for your OS to fix this!", - fd, MAX_FD); + fd, MAX_FD); sClose(fd); return -1; } diff --git a/src/common/socket.h b/src/common/socket.h index aa5886d6896..308c92d857b 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -155,9 +155,9 @@ int sSocket(int af, int type, int protocol); #endif -#define TOB(n) ((uint8)((n)&std::numeric_limits::max())) -#define TOW(n) ((uint16)((n)&std::numeric_limits::max())) -#define TOL(n) ((uint32)((n)&std::numeric_limits::max())) +#define TOB(n) ((uint8)((n) & std::numeric_limits::max())) +#define TOW(n) ((uint16)((n) & std::numeric_limits::max())) +#define TOL(n) ((uint32)((n) & std::numeric_limits::max())) enum class socket_type { @@ -250,7 +250,7 @@ struct socket_data { struct { - unsigned char eof : 1; + unsigned char eof : 1; unsigned char server : 1; } flag; diff --git a/src/common/sql.cpp b/src/common/sql.cpp index 942158f3ec8..2c617106736 100644 --- a/src/common/sql.cpp +++ b/src/common/sql.cpp @@ -42,10 +42,10 @@ std::atomic gProcessLoaded = false; SqlConnection::SqlConnection() : SqlConnection(settings::get("network.SQL_LOGIN").c_str(), - settings::get("network.SQL_PASSWORD").c_str(), - settings::get("network.SQL_HOST").c_str(), - settings::get("network.SQL_PORT"), - settings::get("network.SQL_DATABASE").c_str()) + settings::get("network.SQL_PASSWORD").c_str(), + settings::get("network.SQL_HOST").c_str(), + settings::get("network.SQL_PORT"), + settings::get("network.SQL_DATABASE").c_str()) { // Just forwarding the default credentials to the next constructor } @@ -287,7 +287,7 @@ size_t SqlConnection::EscapeString(char* out_to, const char* from) return EscapeStringLen(out_to, from, strlen(from)); } -std::string SqlConnection::EscapeString(std::string const& input) +std::string SqlConnection::EscapeString(const std::string& input) { TracyZoneScoped; std::string escaped_full_string; diff --git a/src/common/sql.h b/src/common/sql.h index e12ba582aa2..72f491e3b1d 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -142,7 +142,7 @@ class SqlConnection /// Escapes a string. /// /// @return The escaped string - std::string EscapeString(std::string const& input); + std::string EscapeString(const std::string& input); /// Executes a query. /// Any previous result is freed. @@ -201,7 +201,7 @@ class SqlConnection /// Establishes keepalive (periodic ping) on the connection /// /// @return the keepalive timer id, or INVALID_TIMER - int32 Keepalive(std::string const& keepalive_name); + int32 Keepalive(const std::string& keepalive_name); /// Gets the data of a column. /// The data remains valid until the next row is fetched or the result is freed. diff --git a/src/common/string.h b/src/common/string.h index 6788a003bff..90948dffd31 100644 --- a/src/common/string.h +++ b/src/common/string.h @@ -50,7 +50,7 @@ namespace marshal buffer[std::min(index, capacity - 1)] = '\0'; } - void assign(std::string const& text) + void assign(const std::string& text) { auto index = std::min(text.length(), capacity); std::copy_n(text.begin(), index, buffer); @@ -66,16 +66,16 @@ namespace marshal // Copy template - string(string const& other) + string(const string& other) : string(std::string(other)) { } - string(char const* text) + string(const char* text) : string(std::string(text)) { } - string(std::string const& text) + string(const std::string& text) { assign(text); } @@ -115,17 +115,17 @@ namespace marshal return buffer + capacity; } - char const* cbegin() + const char* cbegin() { return buffer; } - char const* cend() + const char* cend() { return buffer + capacity; } - char const* data() + const char* data() { return buffer; } @@ -141,13 +141,13 @@ namespace marshal // Stream operators template - friend std::ostream operator<<(std::ostream& stream, string const& str); + friend std::ostream operator<<(std::ostream& stream, const string& str); template friend std::istream operator>>(std::istream& stream, string& str); }; template - std::ostream& operator<<(std::ostream& stream, string const& str) + std::ostream& operator<<(std::ostream& stream, const string& str) { return stream << std::string(str); } diff --git a/src/common/taskmgr.cpp b/src/common/taskmgr.cpp index d45e732f691..8900604f04f 100644 --- a/src/common/taskmgr.cpp +++ b/src/common/taskmgr.cpp @@ -38,7 +38,7 @@ CTaskMgr::~CTaskMgr() } } -CTaskMgr::CTask* CTaskMgr::AddTask(std::string const& InitName, time_point InitTick, std::any InitData, TASKTYPE InitType, TaskFunc_t InitFunc, duration InitInterval) +CTaskMgr::CTask* CTaskMgr::AddTask(const std::string& InitName, time_point InitTick, std::any InitData, TASKTYPE InitType, TaskFunc_t InitFunc, duration InitInterval) { TracyZoneScoped; return AddTask(new CTask(InitName, InitTick, std::move(InitData), InitType, InitFunc, InitInterval)); @@ -51,7 +51,7 @@ CTaskMgr::CTask* CTaskMgr::AddTask(CTask* PTask) return PTask; } -void CTaskMgr::RemoveTask(std::string const& TaskName) +void CTaskMgr::RemoveTask(const std::string& TaskName) { TracyZoneScoped; // m_TaskList is a priority_queue, so we can't directly pull members out of it. diff --git a/src/common/taskmgr.h b/src/common/taskmgr.h index 2a102d3fc98..b28fd3b35e0 100644 --- a/src/common/taskmgr.h +++ b/src/common/taskmgr.h @@ -60,10 +60,10 @@ class CTaskMgr : public Singleton }; CTask* AddTask(CTask*); - CTask* AddTask(std::string const& InitName, time_point InitTick, std::any InitData, TASKTYPE InitType, TaskFunc_t InitFunc, duration InitInterval = 1s); + CTask* AddTask(const std::string& InitName, time_point InitTick, std::any InitData, TASKTYPE InitType, TaskFunc_t InitFunc, duration InitInterval = 1s); duration DoTimer(time_point tick); - void RemoveTask(std::string const& TaskName); + void RemoveTask(const std::string& TaskName); protected: CTaskMgr() = default; @@ -75,13 +75,13 @@ class CTaskMgr : public Singleton class CTaskMgr::CTask { public: - CTask(std::string const& InitName, time_point InitTick, std::any InitData, TASKTYPE InitType, TaskFunc_t InitFunc, duration InitInterval = 1s) + CTask(const std::string& InitName, time_point InitTick, std::any InitData, TASKTYPE InitType, TaskFunc_t InitFunc, duration InitInterval = 1s) : m_name(InitName) , m_type(InitType) , m_tick(InitTick) , m_interval(InitInterval) , m_data(InitData) - , m_func(InitFunc){}; + , m_func(InitFunc) {}; std::string m_name; TASKTYPE m_type; diff --git a/src/common/timer.cpp b/src/common/timer.cpp index 29fa5d61313..04fa204f668 100644 --- a/src/common/timer.cpp +++ b/src/common/timer.cpp @@ -94,17 +94,12 @@ static uint32 tick() // return (uint32)((_rdtsc() - RDTSC_BEGINTICK) / RDTSC_CLOCK); // -#elif (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK) /* posix compliant */) || \ - (defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 500005 /* FreeBSD >= 5.1.0 */) - struct timespec tval - { - }; +#elif (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK) /* posix compliant */) || (defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 500005 /* FreeBSD >= 5.1.0 */) + struct timespec tval{}; clock_gettime(CLOCK_MONOTONIC, &tval); return tval.tv_sec * 1000 + tval.tv_nsec / 1000000; #else - struct timeval tval - { - }; + struct timeval tval{}; gettimeofday(&tval, nullptr); return tval.tv_sec * 1000 + tval.tv_usec / 1000; #endif diff --git a/src/common/utils.cpp b/src/common/utils.cpp index 33f4bcb5788..372344602cf 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -43,8 +43,7 @@ //-------------------------------------------------- int config_switch(const char* str) { - if (strcmpi(str, "true") == 0 || strcmpi(str, "on") == 0 || strcmpi(str, "yes") == 0 || strcmpi(str, "oui") == 0 || strcmpi(str, "ja") == 0 || - strcmpi(str, "si") == 0) + if (strcmpi(str, "true") == 0 || strcmpi(str, "on") == 0 || strcmpi(str, "yes") == 0 || strcmpi(str, "oui") == 0 || strcmpi(str, "ja") == 0 || strcmpi(str, "si") == 0) { return 1; } @@ -740,7 +739,7 @@ std::string UnpackSoultrapperName(uint8 input[]) return output; } -std::string escape(std::string const& s) +std::string escape(const std::string& s) { std::size_t n = s.length(); std::string escaped; @@ -756,7 +755,7 @@ std::string escape(std::string const& s) return escaped; } -std::vector split(std::string const& s, std::string const& delimiter) +std::vector split(const std::string& s, const std::string& delimiter) { std::size_t pos_start = 0; std::size_t pos_end = 0; @@ -776,7 +775,7 @@ std::vector split(std::string const& s, std::string const& delimite return res; } -std::string to_lower(std::string const& s) +std::string to_lower(const std::string& s) { // clang-format off std::string data = s; @@ -789,7 +788,7 @@ std::string to_lower(std::string const& s) return data; } -std::string to_upper(std::string const& s) +std::string to_upper(const std::string& s) { // clang-format off std::string data = s; @@ -803,7 +802,7 @@ std::string to_upper(std::string const& s) } // https://stackoverflow.com/questions/313970/how-to-convert-an-instance-of-stdstring-to-lower-case -std::string trim(std::string const& str, std::string const& whitespace) +std::string trim(const std::string& str, const std::string& whitespace) { const auto strBegin = str.find_first_not_of(whitespace); if (strBegin == std::string::npos) @@ -830,17 +829,17 @@ void rtrim(std::string& s) } // Returns true if the given str matches the given pattern using standard regex -bool matches(std::string const& target, std::string const& pattern) +bool matches(const std::string& target, const std::string& pattern) { return std::regex_match(target, std::regex(pattern)); } -bool starts_with(std::string const& target, std::string const& pattern) +bool starts_with(const std::string& target, const std::string& pattern) { return target.rfind(pattern, 0) != std::string::npos; } -std::string replace(std::string const& target, std::string const& search, std::string const& replace) +std::string replace(const std::string& target, const std::string& search, const std::string& replace) { try { @@ -939,12 +938,12 @@ void crash() *ptr = 0xDEAD; } -std::unique_ptr utils::openFile(std::string const& path, std::string const& mode) +std::unique_ptr utils::openFile(const std::string& path, const std::string& mode) { return std::unique_ptr(fopen(path.c_str(), mode.c_str())); } -std::string utils::toASCII(std::string const& target, unsigned char replacement) +std::string utils::toASCII(const std::string& target, unsigned char replacement) { std::string out; out.reserve(target.size()); diff --git a/src/common/utils.h b/src/common/utils.h index afadbb37806..2b712b9f7ec 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -89,15 +89,15 @@ void DecodeStringSignature(const std::string& signature, char* target); void PackSoultrapperName(std::string name, uint8 output[]); std::string UnpackSoultrapperName(uint8 input[]); -auto escape(std::string const& s) -> std::string; -auto split(std::string const& s, std::string const& delimiter = " ") -> std::vector; -auto to_lower(std::string const& s) -> std::string; -auto to_upper(std::string const& s) -> std::string; +auto escape(const std::string& s) -> std::string; +auto split(const std::string& s, const std::string& delimiter = " ") -> std::vector; +auto to_lower(const std::string& s) -> std::string; +auto to_upper(const std::string& s) -> std::string; auto trim(const std::string& str, const std::string& whitespace = " \t") -> std::string; void rtrim(std::string& s); -bool matches(std::string const& target, std::string const& pattern); -bool starts_with(std::string const& target, std::string const& pattern); -auto replace(std::string const& target, std::string const& search, std::string const& replace) -> std::string; +bool matches(const std::string& target, const std::string& pattern); +bool starts_with(const std::string& target, const std::string& pattern); +auto replace(const std::string& target, const std::string& search, const std::string& replace) -> std::string; look_t stringToLook(std::string str); @@ -123,8 +123,8 @@ std::set sorted_directory_iterator(std::string path_name) namespace utils { - auto openFile(std::string const& path, std::string const& mode) -> std::unique_ptr; - auto toASCII(std::string const& target, unsigned char replacement = '\0') -> std::string; + auto openFile(const std::string& path, const std::string& mode) -> std::unique_ptr; + auto toASCII(const std::string& target, unsigned char replacement = '\0') -> std::string; } // namespace utils // clang-format off diff --git a/src/common/vana_time.cpp b/src/common/vana_time.cpp index 916edaabc97..27c0627904f 100644 --- a/src/common/vana_time.cpp +++ b/src/common/vana_time.cpp @@ -268,8 +268,7 @@ uint8 CVanaTime::getRSELocation() const TIMETYPE CVanaTime::SyncTime() { - m_vanaDate = (uint32)(this->getVanaTime() / 60.0 * 25) + - 886 * VTIME_YEAR; // convert vana time (from SE epoch in earth seconds) to vanadiel minutes and add 886 vana years + m_vanaDate = (uint32)(this->getVanaTime() / 60.0 * 25) + 886 * VTIME_YEAR; // convert vana time (from SE epoch in earth seconds) to vanadiel minutes and add 886 vana years m_vYear = m_vanaDate / VTIME_YEAR; m_vMon = (m_vanaDate / VTIME_MONTH) % 12 + 1; diff --git a/src/common/zlib.cpp b/src/common/zlib.cpp index c54f35d7fa0..8e22a687e6f 100644 --- a/src/common/zlib.cpp +++ b/src/common/zlib.cpp @@ -9,9 +9,7 @@ #include #include -#if (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) || (defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN) || \ - defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || defined(_MIBSEB) || defined(__MIBSEB) || \ - defined(__MIBSEB__) +#if (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) || (defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN) || defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__) #define XI_BIG_ENDIAN 1 #else #define XI_BIG_ENDIAN 0 @@ -40,7 +38,7 @@ #endif // Resolve the next address in jump table (0 == no jump, 1 == next address) -#define JMPBIT(table, i) (((table)[(i) / 8] >> ((i)&7)) & 1) +#define JMPBIT(table, i) (((table)[(i) / 8] >> ((i) & 7)) & 1) struct zlib_jump { @@ -65,7 +63,7 @@ static void swap32_if_be(const uint32* v, const size_t memb) #endif } -static bool read_to_vector(std::string const& filename, std::vector& vec) +static bool read_to_vector(const std::string& filename, std::vector& vec) { auto fp = utils::openFile(filename, "rb"); if (!fp) diff --git a/src/login/auth_session.cpp b/src/login/auth_session.cpp index 0f4b75d5ba2..7f789614af8 100644 --- a/src/login/auth_session.cpp +++ b/src/login/auth_session.cpp @@ -51,11 +51,8 @@ namespace constexpr bool isBcryptHash(const std::string& passHash) { - return std::size(passHash) == 60 && - passHash[0] == '$' && - passHash[1] == '2' && - (passHash[2] == 'a' || passHash[2] == 'b' || passHash[2] == 'y' || passHash[2] == 'x') && // bcrypt hash versions - passHash[3] == '$'; + return std::size(passHash) == 60 && passHash[0] == '$' && passHash[1] == '2' && (passHash[2] == 'a' || passHash[2] == 'b' || passHash[2] == 'y' || passHash[2] == 'x') && // bcrypt hash versions + passHash[3] == '$'; } } // namespace @@ -249,7 +246,7 @@ void auth_session::read_func() FROM accounts_sessions JOIN accounts \ ON accounts_sessions.accid = accounts.id \ WHERE accounts.id = %d", - accountID); + accountID); if (ret != SQL_ERROR && _sql->NumRows() == 1) { @@ -336,7 +333,7 @@ void auth_session::read_func() if (!settings::get("login.ACCOUNT_CREATION")) { ShowWarningFmt("login_parse: New account attempt <{}> but is disabled in settings.", - username); + username); ref(data_, 0) = LOGIN_ERROR_CREATE_DISABLED; do_write(1); return; @@ -382,7 +379,8 @@ void auth_session::read_func() if (_sql->Query("INSERT INTO accounts(id,login,password,timecreate,timelastmodify,status,priv) \ VALUES(%d,'%s','%s','%s',NULL,%d,%d)", - accid, username, BCrypt::generateHash(escaped_pass), strtimecreate, ACCOUNT_STATUS_CODE::NORMAL, ACCOUNT_PRIVILEGE_CODE::USER) == SQL_ERROR) + accid, username, BCrypt::generateHash(escaped_pass), strtimecreate, ACCOUNT_STATUS_CODE::NORMAL, ACCOUNT_PRIVILEGE_CODE::USER) + == SQL_ERROR) { ref(data_, 0) = LOGIN_ERROR_CREATE; do_write(1); @@ -460,7 +458,7 @@ void auth_session::read_func() int32 ret = _sql->Query("SELECT accounts.id, accounts.status \ FROM accounts \ WHERE accounts.login = '%s'", - username); + username); if (ret == SQL_ERROR || _sql->NumRows() == 0) { ShowWarningFmt("login_parse: user <{}> could not be found using the provided information. Aborting.", username); @@ -502,7 +500,7 @@ void auth_session::read_func() _sql->Query("UPDATE accounts SET accounts.timelastmodify = NULL WHERE accounts.id = %d", accid); ret = _sql->Query("UPDATE accounts SET accounts.password = '%s' WHERE accounts.id = %d", - BCrypt::generateHash(updated_password), accid); + BCrypt::generateHash(updated_password), accid); if (ret == SQL_ERROR) { ShowWarningFmt("login_parse: Error trying to update password in database for user <{}>.", username); diff --git a/src/login/cert_helpers.h b/src/login/cert_helpers.h index bebdf0e84c6..2ae7541aa55 100644 --- a/src/login/cert_helpers.h +++ b/src/login/cert_helpers.h @@ -106,9 +106,9 @@ namespace certificateHelpers /* X509_NAME_add_entry_by_txt(name, "C", MBSTRING_ASC, (unsigned char*)"CA", -1, -1, 0);*/ X509_NAME_add_entry_by_txt(name, "O", MBSTRING_ASC, - (unsigned char*)"LSB self-signed certificate for login server", -1, -1, 0); + (unsigned char*)"LSB self-signed certificate for login server", -1, -1, 0); X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, - commonNameIpAddr, -1, -1, 0); + commonNameIpAddr, -1, -1, 0); X509_set_issuer_name(x509, name); diff --git a/src/login/connect_server.cpp b/src/login/connect_server.cpp index eb8b0972656..1bc2063399e 100644 --- a/src/login/connect_server.cpp +++ b/src/login/connect_server.cpp @@ -50,9 +50,7 @@ ConnectServer::ConnectServer(int argc, char** argv) // clang-format on #ifndef _WIN32 - struct rlimit limits - { - }; + struct rlimit limits{}; uint32 newRLimit = 10240; @@ -129,9 +127,7 @@ void ConnectServer::periodicCleanup(const asio::error_code& error, asio::steady_ session_t& session = sessionIterator->second; // If it's been 15 minutes, erase it from the session list - if (!session.data_session && - !session.view_session && - (server_clock::now() - session.authorizedTime) > std::chrono::minutes(15)) + if (!session.data_session && !session.view_session && (server_clock::now() - session.authorizedTime) > std::chrono::minutes(15)) { sessionIterator = ipAddrIterator->second.erase(sessionIterator); } diff --git a/src/login/data_session.cpp b/src/login/data_session.cpp index 1be7cd0d277..a02e84dd5f3 100644 --- a/src/login/data_session.cpp +++ b/src/login/data_session.cpp @@ -78,8 +78,7 @@ void data_session::read_func() return; } - const char* pfmtQuery = - "SELECT charid, charname, pos_zone, pos_prevzone, mjob,\ + const char* pfmtQuery = "SELECT charid, charname, pos_zone, pos_prevzone, mjob,\ race, face, head, body, hands, legs, feet, main, sub,\ war, mnk, whm, blm, rdm, thf, pld, drk, bst, brd, rng,\ sam, nin, drg, smn, blu, cor, pup, dnc, sch, geo, run, \ @@ -274,8 +273,9 @@ void data_session::read_func() if (_sql->Query("SELECT zoneip, zoneport, zoneid, pos_prevzone, gmlevel, accid, charname \ FROM zone_settings, chars \ WHERE IF(pos_zone = 0, zoneid = pos_prevzone, zoneid = pos_zone) AND charid = %u AND accid = %u", - charid, session.accountID) != SQL_ERROR && - _sql->NumRows() != 0) + charid, session.accountID) + != SQL_ERROR + && _sql->NumRows() != 0) { _sql->NextRow(); @@ -307,7 +307,7 @@ void data_session::read_func() characterSelectionResponse.server_id = (charid >> 16) & 0xFF; // Looks wrong? shouldn't this be a server index? ShowInfo(fmt::format("data_session: zoneid:({}), zoneip:({}), zoneport:({}) for char:({})", - ZoneID, loginHelpers::ip2str(ntohl(ZoneIP)), ZonePort, charid)); + ZoneID, loginHelpers::ip2str(ntohl(ZoneIP)), ZonePort, charid)); // Check the number of sessions uint16 sessionCount = 0; @@ -315,8 +315,9 @@ void data_session::read_func() if (_sql->Query("SELECT COUNT(client_addr) \ FROM accounts_sessions \ WHERE client_addr = %u", - accountIP) != SQL_ERROR && - _sql->NumRows() != 0) + accountIP) + != SQL_ERROR + && _sql->NumRows() != 0) { _sql->NextRow(); sessionCount = (uint16)_sql->GetIntData(0); @@ -327,8 +328,9 @@ void data_session::read_func() if (_sql->Query("SELECT * \ FROM accounts_sessions \ WHERE accid = %u AND client_port != '0'", - session.accountID) != SQL_ERROR && - _sql->NumRows() != 0) + session.accountID) + != SQL_ERROR + && _sql->NumRows() != 0) { _sql->NextRow(); hasActiveSession = true; @@ -338,8 +340,9 @@ void data_session::read_func() if (_sql->Query("SELECT * \ FROM accounts_sessions \ WHERE accid = %u AND client_port = '0' AND last_zoneout_time >= SUBTIME(NOW(), \"00:00:30\")", - session.accountID) != SQL_ERROR && - _sql->NumRows() != 0) + session.accountID) + != SQL_ERROR + && _sql->NumRows() != 0) { _sql->NextRow(); hasActiveSession = true; @@ -350,8 +353,9 @@ void data_session::read_func() if (_sql->Query("SELECT UNIX_TIMESTAMP(exception) \ FROM ip_exceptions \ WHERE accid = %u", - session.accountID) != SQL_ERROR && - _sql->NumRows() != 0) + session.accountID) + != SQL_ERROR + && _sql->NumRows() != 0) { _sql->NextRow(); exceptionTime = _sql->GetUInt64Data(0); @@ -401,8 +405,9 @@ void data_session::read_func() if (_sql->Query("INSERT INTO accounts_sessions(accid,charid,session_key,server_addr,server_port,client_addr, version_mismatch) " "VALUES(%u,%u,x'%s',%u,%u,%u,%u)", - session.accountID, charid, session_key, ZoneIP, ZonePort, accountIP, - session.versionMismatch ? 1 : 0) == SQL_ERROR) + session.accountID, charid, session_key, ZoneIP, ZonePort, accountIP, + session.versionMismatch ? 1 : 0) + == SQL_ERROR) { if (auto data = session.view_session.get()) { @@ -467,7 +472,8 @@ void data_session::read_func() if (_sql->Query("INSERT INTO account_ip_record(login_time,accid,charid,client_ip) \ VALUES ('%s', %u, %u, '%s')", - timeAndDate, session.accountID, charid, loginHelpers::ip2str(accountIP)) == SQL_ERROR) + timeAndDate, session.accountID, charid, loginHelpers::ip2str(accountIP)) + == SQL_ERROR) { ShowError("data_session: Could not write info to account_ip_record."); } diff --git a/src/login/login_helpers.cpp b/src/login/login_helpers.cpp index dd40afc802d..84e077d884a 100644 --- a/src/login/login_helpers.cpp +++ b/src/login/login_helpers.cpp @@ -31,7 +31,7 @@ namespace loginHelpers return authenticatedSessions_; } - bool check_string(std::string const& str, std::size_t max_length) + bool check_string(const std::string& str, std::size_t max_length) { // clang-format off return !str.empty() && @@ -44,7 +44,7 @@ namespace loginHelpers // clang-format on } - session_t& get_authenticated_session(std::string const& ipAddr, std::string const& sessionHash) + session_t& get_authenticated_session(const std::string& ipAddr, const std::string& sessionHash) { return authenticatedSessions_[ipAddr][sessionHash]; // NOTE: Will construct if doesn't exist } @@ -108,7 +108,7 @@ namespace loginHelpers }; // apply the expansion masks where available - for (auto const& expansion : expansions) + for (const auto& expansion : expansions) { if (settings::get(expansion.first)) { @@ -133,7 +133,7 @@ namespace loginHelpers }; // apply the feature masks where available - for (auto const& feature : features) + for (const auto& feature : features) { if (settings::get(feature.first)) { @@ -149,28 +149,32 @@ namespace loginHelpers auto _sql = std::make_unique(); if (_sql->Query("INSERT INTO chars(charid,accid,charname,pos_zone,nation) VALUES(%u,%u,'%s',%u,%u)", - charid, accid, str(createchar->m_name), createchar->m_zone, createchar->m_nation) == SQL_ERROR) + charid, accid, str(createchar->m_name), createchar->m_zone, createchar->m_nation) + == SQL_ERROR) { ShowDebug(fmt::format("lobby_ccsave: char<{}>, accid: {}, charid: {}", str(createchar->m_name), accid, charid)); return -1; } if (_sql->Query("INSERT INTO char_look(charid,face,race,size) VALUES(%u,%u,%u,%u)", - charid, createchar->m_look.face, createchar->m_look.race, createchar->m_look.size) == SQL_ERROR) + charid, createchar->m_look.face, createchar->m_look.race, createchar->m_look.size) + == SQL_ERROR) { ShowDebug(fmt::format("lobby_cLook: char<{}>, charid: {}", str(createchar->m_name), charid)); return -1; } if (_sql->Query("INSERT INTO char_stats(charid,mjob) VALUES(%u,%u)", - charid, createchar->m_mjob) == SQL_ERROR) + charid, createchar->m_mjob) + == SQL_ERROR) { ShowDebug(fmt::format("lobby_cStats: charid: {}", charid)); return -1; } if (_sql->Query("INSERT INTO char_exp(charid) VALUES(%u) ON DUPLICATE KEY UPDATE charid = charid", - charid, createchar->m_mjob) == SQL_ERROR) + charid, createchar->m_mjob) + == SQL_ERROR) { return -1; } @@ -181,31 +185,36 @@ namespace loginHelpers } if (_sql->Query("INSERT INTO char_jobs(charid) VALUES(%u) ON DUPLICATE KEY UPDATE charid = charid", - charid, createchar->m_mjob) == SQL_ERROR) + charid, createchar->m_mjob) + == SQL_ERROR) { return -1; } if (_sql->Query("INSERT INTO char_points(charid) VALUES(%u) ON DUPLICATE KEY UPDATE charid = charid", - charid, createchar->m_mjob) == SQL_ERROR) + charid, createchar->m_mjob) + == SQL_ERROR) { return -1; } if (_sql->Query("INSERT INTO char_unlocks(charid) VALUES(%u) ON DUPLICATE KEY UPDATE charid = charid", - charid, createchar->m_mjob) == SQL_ERROR) + charid, createchar->m_mjob) + == SQL_ERROR) { return -1; } if (_sql->Query("INSERT INTO char_profile(charid) VALUES(%u) ON DUPLICATE KEY UPDATE charid = charid", - charid, createchar->m_mjob) == SQL_ERROR) + charid, createchar->m_mjob) + == SQL_ERROR) { return -1; } if (_sql->Query("INSERT INTO char_storage(charid) VALUES(%u) ON DUPLICATE KEY UPDATE charid = charid", - charid, createchar->m_mjob) == SQL_ERROR) + charid, createchar->m_mjob) + == SQL_ERROR) { return -1; } @@ -223,7 +232,8 @@ namespace loginHelpers if (settings::get("main.NEW_CHARACTER_CUTSCENE")) { if (_sql->Query("INSERT INTO char_vars(charid, varname, value) VALUES(%u, '%s', %u)", - charid, "HQuest[newCharacterCS]notSeen", 1) == SQL_ERROR) + charid, "HQuest[newCharacterCS]notSeen", 1) + == SQL_ERROR) { return -1; } @@ -250,7 +260,7 @@ namespace loginHelpers if (mjob != createchar.m_mjob) { ShowInfo(fmt::format("{} attempted to create invalid starting job {} substituting {}", - session.requestedNewCharacterName, mjob, createchar.m_mjob)); + session.requestedNewCharacterName, mjob, createchar.m_mjob)); } createchar.m_nation = ref(buf, 54); @@ -326,7 +336,7 @@ namespace loginHelpers } } - std::string getHashFromPacket(std::string const& ip_str, char* data) + std::string getHashFromPacket(const std::string& ip_str, char* data) { std::string hash = std::string(data + 12, 16); diff --git a/src/login/login_helpers.h b/src/login/login_helpers.h index ec4003dd3ed..a4b6e98f2c9 100644 --- a/src/login/login_helpers.h +++ b/src/login/login_helpers.h @@ -78,9 +78,9 @@ namespace loginHelpers UNUSED_FEATURE_9 = 0x8000, }; - bool check_string(std::string const& str, std::size_t max_length); + bool check_string(const std::string& str, std::size_t max_length); - session_t& get_authenticated_session(std::string const& ipAddr, std::string const& sessionHash); + session_t& get_authenticated_session(const std::string& ipAddr, const std::string& sessionHash); // hostname/ip conversion functions std::string ip2str(uint32 ip); @@ -100,5 +100,5 @@ namespace loginHelpers void PrintPacket(const char* data, uint32 size); - std::string getHashFromPacket(std::string const& ip_str, char* data); + std::string getHashFromPacket(const std::string& ip_str, char* data); } // namespace loginHelpers diff --git a/src/login/view_session.cpp b/src/login/view_session.cpp index 4d5eb62ee93..ec2d00d8fdb 100644 --- a/src/login/view_session.cpp +++ b/src/login/view_session.cpp @@ -59,7 +59,7 @@ void view_session::read_func() uint32 accountID = 0; int32 ret = _sql->Query("SELECT accid FROM chars WHERE charid = %u AND charname = '%s' LIMIT 1", - requestedCharacterID, requestedCharacter); + requestedCharacterID, requestedCharacter); if (ret != SQL_ERROR && _sql->NumRows() != 0 && _sql->NextRow() == SQL_SUCCESS) { accountID = _sql->GetUIntData(0); @@ -117,7 +117,7 @@ void view_session::read_func() uint32 CharID = ref(data_, 0x20); ShowInfo(fmt::format("attempt to delete char:<{}> from ip:<{}>", - CharID, ipAddress)); + CharID, ipAddress)); uint32 accountID = 0; int32 ret = _sql->Query("SELECT accid FROM chars WHERE charid = %u LIMIT 1", CharID); @@ -139,7 +139,7 @@ void view_session::read_func() // This allows character recovery. _sql->Query("UPDATE chars SET accid = 0, original_accid = %i WHERE charid = %i AND accid = %i", - session.accountID, CharID, session.accountID); + session.accountID, CharID, session.accountID); } break; case 0x21: // 33: Registering character name onto the lobby server @@ -230,14 +230,13 @@ void view_session::read_func() // (optional) Check if the name is in use by NPC or Mob entities if (settings::get("login.DISABLE_MOB_NPC_CHAR_NAMES")) { - auto query = - "WITH results AS " - "( " - " SELECT polutils_name AS `name` FROM npc_list " - " UNION " - " SELECT packet_name AS `name` FROM mob_pools " - ") " - "SELECT * FROM results WHERE REPLACE(REPLACE(UPPER(`name`), '-', ''), '_', '') LIKE REPLACE(REPLACE(UPPER('%s'), '-', ''), '_', '')"; + auto query = "WITH results AS " + "( " + " SELECT polutils_name AS `name` FROM npc_list " + " UNION " + " SELECT packet_name AS `name` FROM mob_pools " + ") " + "SELECT * FROM results WHERE REPLACE(REPLACE(UPPER(`name`), '-', ''), '_', '') LIKE REPLACE(REPLACE(UPPER('%s'), '-', ''), '_', '')"; if (_sql->Query(query, nameStr) == SQL_ERROR) { @@ -254,7 +253,7 @@ void view_session::read_func() if (auto badWordsList = loginSettingsTable.get_or("BANNED_WORDS_LIST", sol::lua_nil); badWordsList.valid()) { auto potentialName = to_upper(nameStr); - for (auto const& entry : badWordsList) + for (const auto& entry : badWordsList) { auto badWord = to_upper(entry.second.as()); if (potentialName.find(badWord) != std::string::npos) diff --git a/src/map/ai/ai_container.cpp b/src/map/ai/ai_container.cpp index 358acc5db70..a3d0c0c3373 100644 --- a/src/map/ai/ai_container.cpp +++ b/src/map/ai/ai_container.cpp @@ -51,7 +51,7 @@ CAIContainer::CAIContainer(CBaseEntity* _PEntity) } CAIContainer::CAIContainer(CBaseEntity* _PEntity, std::unique_ptr&& _pathfind, std::unique_ptr&& _controller, - std::unique_ptr&& _targetfind) + std::unique_ptr&& _targetfind) : TargetFind(std::move(_targetfind)) , PathFind(std::move(_pathfind)) , Controller(std::move(_controller)) diff --git a/src/map/ai/controllers/automaton_controller.cpp b/src/map/ai/controllers/automaton_controller.cpp index 052935cdffe..6146288ffbc 100644 --- a/src/map/ai/controllers/automaton_controller.cpp +++ b/src/map/ai/controllers/automaton_controller.cpp @@ -168,9 +168,9 @@ CurrentManeuvers CAutomatonController::GetCurrentManeuvers() const { auto& statuses = PAutomaton->PMaster->StatusEffectContainer; return { statuses->GetEffectsCount(EFFECT_FIRE_MANEUVER), statuses->GetEffectsCount(EFFECT_ICE_MANEUVER), - statuses->GetEffectsCount(EFFECT_WIND_MANEUVER), statuses->GetEffectsCount(EFFECT_EARTH_MANEUVER), - statuses->GetEffectsCount(EFFECT_THUNDER_MANEUVER), statuses->GetEffectsCount(EFFECT_WATER_MANEUVER), - statuses->GetEffectsCount(EFFECT_LIGHT_MANEUVER), statuses->GetEffectsCount(EFFECT_DARK_MANEUVER) }; + statuses->GetEffectsCount(EFFECT_WIND_MANEUVER), statuses->GetEffectsCount(EFFECT_EARTH_MANEUVER), + statuses->GetEffectsCount(EFFECT_THUNDER_MANEUVER), statuses->GetEffectsCount(EFFECT_WATER_MANEUVER), + statuses->GetEffectsCount(EFFECT_LIGHT_MANEUVER), statuses->GetEffectsCount(EFFECT_DARK_MANEUVER) }; } void CAutomatonController::DoCombatTick(time_point tick) @@ -250,8 +250,7 @@ bool CAutomatonController::TryShieldBash() { CState* PState = PTarget->PAI->GetCurrentState(); - if (m_shieldbashCooldown > 0s && PState && PState->CanInterrupt() && - m_Tick > m_LastShieldBashTime + (m_shieldbashCooldown - std::chrono::seconds(PAutomaton->getMod(Mod::AUTO_SHIELD_BASH_DELAY)))) + if (m_shieldbashCooldown > 0s && PState && PState->CanInterrupt() && m_Tick > m_LastShieldBashTime + (m_shieldbashCooldown - std::chrono::seconds(PAutomaton->getMod(Mod::AUTO_SHIELD_BASH_DELAY)))) { return MobSkill(PTarget->targid, m_ShieldBashAbility); } @@ -261,8 +260,7 @@ bool CAutomatonController::TryShieldBash() bool CAutomatonController::TrySpellcast(const CurrentManeuvers& maneuvers) { - if (!PAutomaton->PMaster || m_magicCooldown == 0s || - m_Tick <= m_LastMagicTime + (m_magicCooldown - std::chrono::seconds(PAutomaton->getMod(Mod::AUTO_MAGIC_DELAY))) || !CanCastSpells()) + if (!PAutomaton->PMaster || m_magicCooldown == 0s || m_Tick <= m_LastMagicTime + (m_magicCooldown - std::chrono::seconds(PAutomaton->getMod(Mod::AUTO_MAGIC_DELAY))) || !CanCastSpells()) { return false; } @@ -402,8 +400,7 @@ bool CAutomatonController::TrySpellcast(const CurrentManeuvers& maneuvers) m_LastEnhanceTime = m_Tick; return true; } - else if ((maneuvers.dark || PAutomaton->GetHPP() <= 75 || PAutomaton->GetMPP() <= 75) && - TryEnfeeble(maneuvers)) // Dark or self HPP/MPP <= 75 -> Enfeeble + else if ((maneuvers.dark || PAutomaton->GetHPP() <= 75 || PAutomaton->GetMPP() <= 75) && TryEnfeeble(maneuvers)) // Dark or self HPP/MPP <= 75 -> Enfeeble { m_LastEnfeebleTime = m_Tick; return true; @@ -421,8 +418,7 @@ bool CAutomatonController::TrySpellcast(const CurrentManeuvers& maneuvers) bool CAutomatonController::TryHeal(const CurrentManeuvers& maneuvers) { - if (!PAutomaton->PMaster || m_healCooldown == 0s || - m_Tick <= m_LastHealTime + (m_healCooldown - std::chrono::seconds(PAutomaton->getMod(Mod::AUTO_HEALING_DELAY)))) + if (!PAutomaton->PMaster || m_healCooldown == 0s || m_Tick <= m_LastHealTime + (m_healCooldown - std::chrono::seconds(PAutomaton->getMod(Mod::AUTO_HEALING_DELAY)))) { return false; } @@ -1215,37 +1211,37 @@ bool CAutomatonController::TryEnhance() PAutomaton->PMaster->StatusEffectContainer->ForEachEffect( [&protect, &protectcount, &shell, &shellcount, &haste, &stoneskin, &phalanx](CStatusEffect* PStatus) + { + if (PStatus->GetDuration() > 0) { - if (PStatus->GetDuration() > 0) + if (PStatus->GetStatusID() == EFFECT_PROTECT) { - if (PStatus->GetStatusID() == EFFECT_PROTECT) - { - protect = true; - ++protectcount; - } + protect = true; + ++protectcount; + } - if (PStatus->GetStatusID() == EFFECT_SHELL) - { - shell = true; - ++shellcount; - } + if (PStatus->GetStatusID() == EFFECT_SHELL) + { + shell = true; + ++shellcount; + } - if (PStatus->GetStatusID() == EFFECT_HASTE || PStatus->GetStatusID() == EFFECT_GEO_HASTE) - { - haste = true; - } + if (PStatus->GetStatusID() == EFFECT_HASTE || PStatus->GetStatusID() == EFFECT_GEO_HASTE) + { + haste = true; + } - if (PStatus->GetStatusID() == EFFECT_STONESKIN) - { - stoneskin = true; - } + if (PStatus->GetStatusID() == EFFECT_STONESKIN) + { + stoneskin = true; + } - if (PStatus->GetStatusID() == EFFECT_PHALANX) - { - phalanx = true; - } + if (PStatus->GetStatusID() == EFFECT_PHALANX) + { + phalanx = true; } - }); + } + }); if (isEngaged) { @@ -1424,8 +1420,7 @@ bool CAutomatonController::TryEnhance() Cast(PAutomaton->targid, SpellID::Shellra_V); } - if (PRegenTarget && - !(PRegenTarget->StatusEffectContainer->HasStatusEffect(EFFECT_REGEN) || PRegenTarget->StatusEffectContainer->HasStatusEffect(EFFECT_GEO_REGEN))) + if (PRegenTarget && !(PRegenTarget->StatusEffectContainer->HasStatusEffect(EFFECT_REGEN) || PRegenTarget->StatusEffectContainer->HasStatusEffect(EFFECT_GEO_REGEN))) { if (Cast(PRegenTarget->targid, SpellID::Regen_III) || Cast(PRegenTarget->targid, SpellID::Regen_II) || Cast(PRegenTarget->targid, SpellID::Regen)) { @@ -1435,9 +1430,7 @@ bool CAutomatonController::TryEnhance() if (PProtectTarget) { - if (Cast(PProtectTarget->targid, SpellID::Protect_V) || Cast(PProtectTarget->targid, SpellID::Protect_IV) || - Cast(PProtectTarget->targid, SpellID::Protect_III) || Cast(PProtectTarget->targid, SpellID::Protect_II) || - Cast(PProtectTarget->targid, SpellID::Protect)) + if (Cast(PProtectTarget->targid, SpellID::Protect_V) || Cast(PProtectTarget->targid, SpellID::Protect_IV) || Cast(PProtectTarget->targid, SpellID::Protect_III) || Cast(PProtectTarget->targid, SpellID::Protect_II) || Cast(PProtectTarget->targid, SpellID::Protect)) { return true; } @@ -1445,8 +1438,7 @@ bool CAutomatonController::TryEnhance() if (PShellTarget) { - if (Cast(PShellTarget->targid, SpellID::Shell_V) || Cast(PShellTarget->targid, SpellID::Shell_IV) || Cast(PShellTarget->targid, SpellID::Shell_III) || - Cast(PShellTarget->targid, SpellID::Shell_II) || Cast(PShellTarget->targid, SpellID::Shell)) + if (Cast(PShellTarget->targid, SpellID::Shell_V) || Cast(PShellTarget->targid, SpellID::Shell_IV) || Cast(PShellTarget->targid, SpellID::Shell_III) || Cast(PShellTarget->targid, SpellID::Shell_II) || Cast(PShellTarget->targid, SpellID::Shell)) { return true; } @@ -1498,8 +1490,7 @@ bool CAutomatonController::TryTPMove() for (auto skillid : FamilySkills) { auto* PSkill = battleutils::GetMobSkill(skillid); - if (PSkill && PAutomaton->GetSkill(skilltype) > PSkill->getParam() && PSkill->getParam() != -1 && - distance(PAutomaton->loc.p, PTarget->loc.p) < PSkill->getRadius()) + if (PSkill && PAutomaton->GetSkill(skilltype) > PSkill->getParam() && PSkill->getParam() != -1 && distance(PAutomaton->loc.p, PTarget->loc.p) < PSkill->getRadius()) { validSkills.emplace_back(PSkill); } diff --git a/src/map/ai/controllers/mob_controller.cpp b/src/map/ai/controllers/mob_controller.cpp index 80e477b2ccb..1351311a611 100644 --- a/src/map/ai/controllers/mob_controller.cpp +++ b/src/map/ai/controllers/mob_controller.cpp @@ -74,10 +74,7 @@ bool CMobController::TryDeaggro() } // target is no longer valid, so wipe them from our enmity list - if (!PTarget || PTarget->isDead() || PTarget->isMounted() || PTarget->loc.zone->GetID() != PMob->loc.zone->GetID() || - PMob->StatusEffectContainer->GetConfrontationEffect() != PTarget->StatusEffectContainer->GetConfrontationEffect() || - PMob->allegiance == PTarget->allegiance || CheckDetection(PTarget) || CheckHide(PTarget) || CheckLock(PTarget) || - PMob->getBattleID() != PTarget->getBattleID()) + if (!PTarget || PTarget->isDead() || PTarget->isMounted() || PTarget->loc.zone->GetID() != PMob->loc.zone->GetID() || PMob->StatusEffectContainer->GetConfrontationEffect() != PTarget->StatusEffectContainer->GetConfrontationEffect() || PMob->allegiance == PTarget->allegiance || CheckDetection(PTarget) || CheckHide(PTarget) || CheckLock(PTarget) || PMob->getBattleID() != PTarget->getBattleID()) { if (PTarget) { @@ -161,8 +158,7 @@ bool CMobController::CheckLock(CBattleEntity* PTarget) bool CMobController::CheckDetection(CBattleEntity* PTarget) { TracyZoneScoped; - if (CanPursueTarget(PTarget) || CanDetectTarget(PTarget) || - PMob->StatusEffectContainer->HasStatusEffect({ EFFECT_BIND, EFFECT_SLEEP, EFFECT_SLEEP_II, EFFECT_LULLABY, EFFECT_PETRIFICATION })) + if (CanPursueTarget(PTarget) || CanDetectTarget(PTarget) || PMob->StatusEffectContainer->HasStatusEffect({ EFFECT_BIND, EFFECT_SLEEP, EFFECT_SLEEP_II, EFFECT_LULLABY, EFFECT_PETRIFICATION })) { TapDeaggroTime(); } @@ -280,8 +276,7 @@ bool CMobController::CanDetectTarget(CBattleEntity* PTarget, bool forceSight) return isTargetAndInRange || PMob->CanSeeTarget(PTarget); } - if ((detects & DETECT_MAGIC) && currentDistance < PMob->getMobMod(MOBMOD_MAGIC_RANGE) && - PTarget->PAI->IsCurrentState() && static_cast(PTarget->PAI->GetCurrentState())->GetSpell()->hasMPCost()) + if ((detects & DETECT_MAGIC) && currentDistance < PMob->getMobMod(MOBMOD_MAGIC_RANGE) && PTarget->PAI->IsCurrentState() && static_cast(PTarget->PAI->GetCurrentState())->GetSpell()->hasMPCost()) { return isTargetAndInRange || PMob->CanSeeTarget(PTarget); } @@ -759,8 +754,7 @@ void CMobController::Move() { for (auto PSpawnedMob : static_cast(PTarget)->SpawnMOBList) { - if (PSpawnedMob.second != PMob && !PSpawnedMob.second->PAI->PathFind->IsFollowingPath() && - distance(PSpawnedMob.second->loc.p, PMob->loc.p) < 1.f) + if (PSpawnedMob.second != PMob && !PSpawnedMob.second->PAI->PathFind->IsFollowingPath() && distance(PSpawnedMob.second->loc.p, PMob->loc.p) < 1.f) { auto angle = worldAngle(PMob->loc.p, PTarget->loc.p) + 64; @@ -995,8 +989,7 @@ void CMobController::DoRoamTick(time_point tick) else { // No longer including conditional for ROAMFLAG_AMBUSH now that using mixin to handle mob hiding - if (PMob->getMobMod(MOBMOD_SPECIAL_SKILL) != 0 && - m_Tick >= m_LastSpecialTime + std::chrono::milliseconds(PMob->getBigMobMod(MOBMOD_SPECIAL_COOL)) && TrySpecialSkill()) + if (PMob->getMobMod(MOBMOD_SPECIAL_SKILL) != 0 && m_Tick >= m_LastSpecialTime + std::chrono::milliseconds(PMob->getBigMobMod(MOBMOD_SPECIAL_COOL)) && TrySpecialSkill()) { // I spawned a pet } @@ -1202,14 +1195,12 @@ bool CMobController::Engage(uint16 targid) // Don't cast magic or use special ability right away if (PMob->getBigMobMod(MOBMOD_MAGIC_DELAY) != 0) { - m_nextMagicTime = - m_Tick + std::chrono::milliseconds(PMob->getBigMobMod(MOBMOD_MAGIC_COOL) + xirand::GetRandomNumber(PMob->getBigMobMod(MOBMOD_MAGIC_DELAY))); + m_nextMagicTime = m_Tick + std::chrono::milliseconds(PMob->getBigMobMod(MOBMOD_MAGIC_COOL) + xirand::GetRandomNumber(PMob->getBigMobMod(MOBMOD_MAGIC_DELAY))); } if (PMob->getBigMobMod(MOBMOD_SPECIAL_DELAY) != 0) { - m_LastSpecialTime = m_Tick - std::chrono::milliseconds(PMob->getBigMobMod(MOBMOD_SPECIAL_COOL) + - xirand::GetRandomNumber(PMob->getBigMobMod(MOBMOD_SPECIAL_DELAY))); + m_LastSpecialTime = m_Tick - std::chrono::milliseconds(PMob->getBigMobMod(MOBMOD_SPECIAL_COOL) + xirand::GetRandomNumber(PMob->getBigMobMod(MOBMOD_SPECIAL_DELAY))); } // Pet should also fight the target if they can @@ -1252,9 +1243,7 @@ bool CMobController::CanAggroTarget(CBattleEntity* PTarget) } // Do not aggro if a normal CoP Fomor and the player has low enough fomor hate - if (PMob->m_Family == 115 && !(PMob->m_Type & MOBTYPE_NOTORIOUS) && - (PMob->getZone() >= ZONE_LUFAISE_MEADOWS && PMob->getZone() <= ZONE_SACRARIUM) && - PTarget->objtype == TYPE_PC) + if (PMob->m_Family == 115 && !(PMob->m_Type & MOBTYPE_NOTORIOUS) && (PMob->getZone() >= ZONE_LUFAISE_MEADOWS && PMob->getZone() <= ZONE_SACRARIUM) && PTarget->objtype == TYPE_PC) { if (static_cast(PTarget)->getCharVar("FOMOR_HATE") < 8) { @@ -1352,11 +1341,7 @@ bool CMobController::CanMoveForward(float currentDistance) } auto standbackThreshold = PMob->getMobMod(MOBMOD_HP_STANDBACK); - if (currentDistance < standbackRange && - standbackThreshold > 0 && - PMob->getMobMod(MOBMOD_NO_STANDBACK) == 0 && - PMob->GetHPP() >= standbackThreshold && - (PMob->GetMaxMP() == 0 || PMob->GetMPP() >= standbackThreshold)) + if (currentDistance < standbackRange && standbackThreshold > 0 && PMob->getMobMod(MOBMOD_NO_STANDBACK) == 0 && PMob->GetHPP() >= standbackThreshold && (PMob->GetMaxMP() == 0 || PMob->GetMPP() >= standbackThreshold)) { // Excluding Nins, mobs should not standback if can't cast magic return PMob->GetMJob() != JOB_NIN && PMob->SpellContainer->HasSpells() && !CanCastSpells(); diff --git a/src/map/ai/controllers/pet_controller.cpp b/src/map/ai/controllers/pet_controller.cpp index 373d862efb5..b363f6d987f 100644 --- a/src/map/ai/controllers/pet_controller.cpp +++ b/src/map/ai/controllers/pet_controller.cpp @@ -113,8 +113,7 @@ void CPetController::DoRoamTick(time_point tick) { if (currentDistance < 35.0f) { - if (!PPet->PAI->PathFind->IsFollowingPath() || - distance(PPet->PAI->PathFind->GetDestination(), PPet->PMaster->loc.p) > 2.0f) // recalculate path only if owner moves more than X yalms + if (!PPet->PAI->PathFind->IsFollowingPath() || distance(PPet->PAI->PathFind->GetDestination(), PPet->PMaster->loc.p) > 2.0f) // recalculate path only if owner moves more than X yalms { if (!PPet->PAI->PathFind->PathAround(PPet->PMaster->loc.p, 2.0f, PATHFLAG_RUN | PATHFLAG_WALLHACK)) { @@ -162,9 +161,7 @@ bool CPetController::TryDeaggro() } // target is no longer valid, so wipe them from our enmity list - if (PTarget->isDead() || PTarget->isMounted() || PTarget->loc.zone->GetID() != PPet->loc.zone->GetID() || - PPet->StatusEffectContainer->GetConfrontationEffect() != PTarget->StatusEffectContainer->GetConfrontationEffect() || - PPet->getBattleID() != PTarget->getBattleID()) + if (PTarget->isDead() || PTarget->isMounted() || PTarget->loc.zone->GetID() != PPet->loc.zone->GetID() || PPet->StatusEffectContainer->GetConfrontationEffect() != PTarget->StatusEffectContainer->GetConfrontationEffect() || PPet->getBattleID() != PTarget->getBattleID()) { return true; } diff --git a/src/map/ai/controllers/trust_controller.cpp b/src/map/ai/controllers/trust_controller.cpp index 00ca405ea79..947417d4ed6 100644 --- a/src/map/ai/controllers/trust_controller.cpp +++ b/src/map/ai/controllers/trust_controller.cpp @@ -175,8 +175,7 @@ void CTrustController::DoCombatTick(time_point tick) { if (currentDistanceToTarget > RoamDistance) { - if (currentDistanceToTarget < RoamDistance * 3.0f && - POwner->PAI->PathFind->PathAround(PTarget->loc.p, RoamDistance, PATHFLAG_RUN | PATHFLAG_WALLHACK)) + if (currentDistanceToTarget < RoamDistance * 3.0f && POwner->PAI->PathFind->PathAround(PTarget->loc.p, RoamDistance, PATHFLAG_RUN | PATHFLAG_WALLHACK)) { POwner->PAI->PathFind->FollowPath(m_Tick); } @@ -294,8 +293,7 @@ void CTrustController::DoRoamTick(time_point tick) } } - if (POwner->CanRest() && m_Tick - POwner->LastAttacked > m_tickDelays.at(0) && m_Tick - m_CombatEndTime > m_tickDelays.at(0) && - m_Tick - m_LastHealTickTime > m_tickDelays.at(m_NumHealingTicks)) + if (POwner->CanRest() && m_Tick - POwner->LastAttacked > m_tickDelays.at(0) && m_Tick - m_CombatEndTime > m_tickDelays.at(0) && m_Tick - m_LastHealTickTime > m_tickDelays.at(m_NumHealingTicks)) { if (POwner->health.hp != POwner->health.maxhp || POwner->health.mp != POwner->health.maxmp) { @@ -360,8 +358,7 @@ void CTrustController::PathOutToDistance(CBattleEntity* PTarget, float amount) } // Invalidate position and pick new one (limit: every 3s) - if ((currentDistanceToTarget < amount - 2.5f || currentDistanceToTarget > amount + 2.5f || !POwner->PAI->PathFind->ValidPosition(POwner->loc.p)) && - m_Tick - m_LastRepositionTime > 3s && !m_InTransit) + if ((currentDistanceToTarget < amount - 2.5f || currentDistanceToTarget > amount + 2.5f || !POwner->PAI->PathFind->ValidPosition(POwner->loc.p)) && m_Tick - m_LastRepositionTime > 3s && !m_InTransit) { std::vector positions(5); for (auto& position : positions) diff --git a/src/map/ai/helpers/event_handler.cpp b/src/map/ai/helpers/event_handler.cpp index d6c463a96af..082d426fc3a 100644 --- a/src/map/ai/helpers/event_handler.cpp +++ b/src/map/ai/helpers/event_handler.cpp @@ -21,7 +21,7 @@ #include "event_handler.h" -void CAIEventHandler::addListener(std::string const& eventname, sol::function const& lua_func, std::string const& identifier) +void CAIEventHandler::addListener(const std::string& eventname, const sol::function& lua_func, const std::string& identifier) { TracyZoneScoped; TracyZoneString(eventname); @@ -34,7 +34,7 @@ void CAIEventHandler::addListener(std::string const& eventname, sol::function co eventListeners[eventname].emplace_back(identifier, lua_func); } -void CAIEventHandler::removeListener(std::string const& identifier) +void CAIEventHandler::removeListener(const std::string& identifier) { TracyZoneScoped; TracyZoneString(identifier); @@ -51,7 +51,7 @@ void CAIEventHandler::removeListener(std::string const& identifier) removeFromAllListeners(identifier); } -bool CAIEventHandler::hasListener(std::string const& eventName) +bool CAIEventHandler::hasListener(const std::string& eventName) { const auto& listeners = eventListeners.find(eventName); return listeners != eventListeners.end() && !listeners->second.empty(); diff --git a/src/map/ai/helpers/event_handler.h b/src/map/ai/helpers/event_handler.h index 14a2ea263d6..dbc563ccb2e 100644 --- a/src/map/ai/helpers/event_handler.h +++ b/src/map/ai/helpers/event_handler.h @@ -34,7 +34,7 @@ struct ai_event_t std::string identifier; sol::function lua_func; - ai_event_t(std::string const& _ident, sol::function _lua_func) + ai_event_t(const std::string& _ident, sol::function _lua_func) : identifier(_ident) , lua_func(_lua_func) { @@ -44,13 +44,13 @@ struct ai_event_t class CAIEventHandler { public: - void addListener(std::string const& eventname, sol::function const& lua_func, std::string const& identifier); - void removeListener(std::string const& identifier); - bool hasListener(std::string const& eventName); + void addListener(const std::string& eventname, const sol::function& lua_func, const std::string& identifier); + void removeListener(const std::string& identifier); + bool hasListener(const std::string& eventName); // calls event from core template - void triggerListener(std::string const& eventname, Args&&... args) + void triggerListener(const std::string& eventname, Args&&... args) { TracyZoneScoped; TracyZoneString(eventname); diff --git a/src/map/ai/helpers/gambits_container.cpp b/src/map/ai/helpers/gambits_container.cpp index 87b6cabd8cd..a31e0df1fe1 100644 --- a/src/map/ai/helpers/gambits_container.cpp +++ b/src/map/ai/helpers/gambits_container.cpp @@ -22,7 +22,7 @@ namespace gambits { // Validate gambit before it's inserted into the gambit list // Check levels, etc. - std::string CGambitsContainer::AddGambit(Gambit_t const& gambit) + std::string CGambitsContainer::AddGambit(const Gambit_t& gambit) { TracyZoneScoped; @@ -45,12 +45,14 @@ namespace gambits return ""; } - void CGambitsContainer::RemoveGambit(std::string const& id) + void CGambitsContainer::RemoveGambit(const std::string& id) { gambits.erase( std::remove_if(gambits.begin(), gambits.end(), - [&id](Gambit_t const& gambit) - { return gambit.identifier == id; }), + [&id](const Gambit_t& gambit) + { + return gambit.identifier == id; + }), gambits.end()); } @@ -74,9 +76,7 @@ namespace gambits // TODO: Is this necessary? // Not already doing something - if (POwner->PAI->IsCurrentState() || POwner->PAI->IsCurrentState() || POwner->PAI->IsCurrentState() || - POwner->PAI->IsCurrentState() || POwner->PAI->IsCurrentState() || - POwner->PAI->IsCurrentState()) + if (POwner->PAI->IsCurrentState() || POwner->PAI->IsCurrentState() || POwner->PAI->IsCurrentState() || POwner->PAI->IsCurrentState() || POwner->PAI->IsCurrentState() || POwner->PAI->IsCurrentState()) { return; } @@ -170,11 +170,12 @@ namespace gambits { auto result = false; static_cast(POwner->PMaster)->ForPartyWithTrusts([&](CBattleEntity* PMember) - { + { if (isValidMember(PMember) && CheckTrigger(PMember, predicate) && (PMember->GetMJob() == JOB_RNG || PMember->GetMJob() == JOB_COR)) { result = true; - } }); + } + }); return result; } else if (predicate.target == G_TARGET::CASTER) @@ -271,8 +272,7 @@ namespace gambits auto isValidMember = [this](CBattleEntity* PSettableTarget, CBattleEntity* PPartyTarget) { - return !PSettableTarget && PPartyTarget->isAlive() && POwner->loc.zone == PPartyTarget->loc.zone && - distance(POwner->loc.p, PPartyTarget->loc.p) <= 15.0f; + return !PSettableTarget && PPartyTarget->isAlive() && POwner->loc.zone == PPartyTarget->loc.zone && distance(POwner->loc.p, PPartyTarget->loc.p) <= 15.0f; }; // TODO: This whole section is messy and bonkers @@ -723,8 +723,7 @@ namespace gambits case G_CONDITION::NO_SAMBA: { bool noSamba = true; - if (trigger_target->StatusEffectContainer->HasStatusEffect(EFFECT_DRAIN_SAMBA) || - trigger_target->StatusEffectContainer->HasStatusEffect(EFFECT_HASTE_SAMBA)) + if (trigger_target->StatusEffectContainer->HasStatusEffect(EFFECT_DRAIN_SAMBA) || trigger_target->StatusEffectContainer->HasStatusEffect(EFFECT_HASTE_SAMBA)) { noSamba = false; } diff --git a/src/map/ai/helpers/gambits_container.h b/src/map/ai/helpers/gambits_container.h index 444ec3f0572..698f0b1ddb9 100644 --- a/src/map/ai/helpers/gambits_container.h +++ b/src/map/ai/helpers/gambits_container.h @@ -113,7 +113,7 @@ namespace gambits { } - bool parseInput(std::string const& key, uint32 value) + bool parseInput(const std::string& key, uint32 value) { if (key.compare("target") == 0) { @@ -142,7 +142,7 @@ namespace gambits G_SELECT select; uint32 select_arg = 0; - bool parseInput(std::string const& key, uint32 value) + bool parseInput(const std::string& key, uint32 value) { if (key.compare("reaction") == 0) { @@ -227,8 +227,8 @@ namespace gambits } ~CGambitsContainer() = default; - auto AddGambit(Gambit_t const& gambit) -> std::string; - void RemoveGambit(std::string const& id); + auto AddGambit(const Gambit_t& gambit) -> std::string; + void RemoveGambit(const std::string& id); void RemoveAllGambits(); void Tick(time_point tick); diff --git a/src/map/ai/helpers/targetfind.cpp b/src/map/ai/helpers/targetfind.cpp index f2a259906d2..f19e44abe68 100644 --- a/src/map/ai/helpers/targetfind.cpp +++ b/src/map/ai/helpers/targetfind.cpp @@ -339,8 +339,7 @@ void CTargetFind::addAllInRange(CBattleEntity* PTarget, float radius, ALLEGIANCE for (const auto& pair : list) { CBattleEntity* PBattleEntity = static_cast(pair.second); - if (PBattleEntity && isWithinArea(&(PBattleEntity->loc.p)) && !PBattleEntity->isDead() && - PBattleEntity->allegiance == ALLEGIANCE_TYPE::PLAYER) + if (PBattleEntity && isWithinArea(&(PBattleEntity->loc.p)) && !PBattleEntity->isDead() && PBattleEntity->allegiance == ALLEGIANCE_TYPE::PLAYER) { m_targets.emplace_back(PBattleEntity); } @@ -431,9 +430,7 @@ bool CTargetFind::validEntity(CBattleEntity* PTarget) return false; } - if (m_PBattleEntity->StatusEffectContainer->GetConfrontationEffect() != PTarget->StatusEffectContainer->GetConfrontationEffect() || - m_PBattleEntity->PBattlefield != PTarget->PBattlefield || m_PBattleEntity->PInstance != PTarget->PInstance || - ((m_findFlags & FINDFLAGS_IGNORE_BATTLEID) == FINDFLAGS_NONE && m_PBattleEntity->getBattleID() != PTarget->getBattleID())) + if (m_PBattleEntity->StatusEffectContainer->GetConfrontationEffect() != PTarget->StatusEffectContainer->GetConfrontationEffect() || m_PBattleEntity->PBattlefield != PTarget->PBattlefield || m_PBattleEntity->PInstance != PTarget->PInstance || ((m_findFlags & FINDFLAGS_IGNORE_BATTLEID) == FINDFLAGS_NONE && m_PBattleEntity->getBattleID() != PTarget->getBattleID())) { return false; } @@ -462,8 +459,7 @@ bool CTargetFind::validEntity(CBattleEntity* PTarget) // If offensive, don't target other entities with same allegiance // Cures can be AoE with Accession and Majesty, ideally we would use SPELLGROUP or some other mechanism, but TargetFind wasn't designed with that in mind - if ((m_targetFlags & TARGET_ENEMY) && !(m_targetFlags & TARGET_PLAYER_PARTY) && - m_PBattleEntity->allegiance == PTarget->allegiance) + if ((m_targetFlags & TARGET_ENEMY) && !(m_targetFlags & TARGET_PLAYER_PARTY) && m_PBattleEntity->allegiance == PTarget->allegiance) { return false; } diff --git a/src/map/ai/states/ability_state.cpp b/src/map/ai/states/ability_state.cpp index 538608bad8d..826fe9b42ab 100644 --- a/src/map/ai/states/ability_state.cpp +++ b/src/map/ai/states/ability_state.cpp @@ -184,12 +184,7 @@ bool CAbilityState::CanUseAbility() return false; } - if (PChar->StatusEffectContainer->HasStatusEffect(EFFECT_AMNESIA) || - (PChar->StatusEffectContainer->HasStatusEffect(EFFECT_IMPAIRMENT) && (PChar->StatusEffectContainer->GetStatusEffect(EFFECT_IMPAIRMENT)->GetPower() == 0x01 || PChar->StatusEffectContainer->GetStatusEffect(EFFECT_IMPAIRMENT)->GetPower() == 0x03)) || - (PAbility->getID() >= ABILITY_CONCENTRIC_PULSE && PAbility->getID() <= ABILITY_RADIAL_ARCANA && - PAbility->isPetAbility() && !charutils::hasAbility(PChar, PAbility->getID())) || - (!PAbility->isPetAbility() && !charutils::hasAbility(PChar, PAbility->getID())) || - (PAbility->isPetAbility() && PAbility->getID() >= ABILITY_HEALING_RUBY && !charutils::hasPetAbility(PChar, PAbility->getID() - ABILITY_HEALING_RUBY))) + if (PChar->StatusEffectContainer->HasStatusEffect(EFFECT_AMNESIA) || (PChar->StatusEffectContainer->HasStatusEffect(EFFECT_IMPAIRMENT) && (PChar->StatusEffectContainer->GetStatusEffect(EFFECT_IMPAIRMENT)->GetPower() == 0x01 || PChar->StatusEffectContainer->GetStatusEffect(EFFECT_IMPAIRMENT)->GetPower() == 0x03)) || (PAbility->getID() >= ABILITY_CONCENTRIC_PULSE && PAbility->getID() <= ABILITY_RADIAL_ARCANA && PAbility->isPetAbility() && !charutils::hasAbility(PChar, PAbility->getID())) || (!PAbility->isPetAbility() && !charutils::hasAbility(PChar, PAbility->getID())) || (PAbility->isPetAbility() && PAbility->getID() >= ABILITY_HEALING_RUBY && !charutils::hasPetAbility(PChar, PAbility->getID() - ABILITY_HEALING_RUBY))) { PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, 0, 0, MSGBASIC_UNABLE_TO_USE_JA2)); return false; @@ -244,8 +239,7 @@ bool CAbilityState::CanUseAbility() cancelAbility = true; } - if (hasAmnesia || - (hasImpairment && (impairmentPower == 0x01 || impairmentPower == 0x03))) + if (hasAmnesia || (hasImpairment && (impairmentPower == 0x01 || impairmentPower == 0x03))) { cancelAbility = true; } diff --git a/src/map/ai/states/attack_state.cpp b/src/map/ai/states/attack_state.cpp index 4c237450560..a372f439e6e 100644 --- a/src/map/ai/states/attack_state.cpp +++ b/src/map/ai/states/attack_state.cpp @@ -125,8 +125,7 @@ void CAttackState::UpdateTarget(uint16 targid) { for (auto&& PPotentialTarget : PChar->SpawnMOBList) { - if (PPotentialTarget.second->animation == ANIMATION_ATTACK && facing(PChar->loc.p, PPotentialTarget.second->loc.p, 64) && - distance(PChar->loc.p, PPotentialTarget.second->loc.p) <= 10) + if (PPotentialTarget.second->animation == ANIMATION_ATTACK && facing(PChar->loc.p, PPotentialTarget.second->loc.p, 64) && distance(PChar->loc.p, PPotentialTarget.second->loc.p) <= 10) { std::unique_ptr errMsg; if (PChar->IsValidTarget(PPotentialTarget.second->targid, TARGET_ENEMY, errMsg)) diff --git a/src/map/ai/states/inactive_state.cpp b/src/map/ai/states/inactive_state.cpp index 8add9dcf9e3..498cb536be7 100644 --- a/src/map/ai/states/inactive_state.cpp +++ b/src/map/ai/states/inactive_state.cpp @@ -46,8 +46,7 @@ bool CInactiveState::Update(time_point tick) return true; } - if (!PBattleEntity->StatusEffectContainer->HasPreventActionEffect() || - (PBattleEntity->StatusEffectContainer->HasStatusEffect({ EFFECT_CHARM, EFFECT_CHARM_II }) && !PBattleEntity->StatusEffectContainer->HasPreventActionEffect(true))) + if (!PBattleEntity->StatusEffectContainer->HasPreventActionEffect() || (PBattleEntity->StatusEffectContainer->HasStatusEffect({ EFFECT_CHARM, EFFECT_CHARM_II }) && !PBattleEntity->StatusEffectContainer->HasPreventActionEffect(true))) { return true; } diff --git a/src/map/ai/states/item_state.cpp b/src/map/ai/states/item_state.cpp index 4ab289d1378..1236200cd4b 100644 --- a/src/map/ai/states/item_state.cpp +++ b/src/map/ai/states/item_state.cpp @@ -305,6 +305,5 @@ void CItemState::FinishItem(action_t& action) bool CItemState::HasMoved() { - return floorf(m_startPos.x * 10 + 0.5f) / 10 != floorf(m_PEntity->loc.p.x * 10 + 0.5f) / 10 || - floorf(m_startPos.z * 10 + 0.5f) / 10 != floorf(m_PEntity->loc.p.z * 10 + 0.5f) / 10; + return floorf(m_startPos.x * 10 + 0.5f) / 10 != floorf(m_PEntity->loc.p.x * 10 + 0.5f) / 10 || floorf(m_startPos.z * 10 + 0.5f) / 10 != floorf(m_PEntity->loc.p.z * 10 + 0.5f) / 10; } diff --git a/src/map/ai/states/magic_state.cpp b/src/map/ai/states/magic_state.cpp index 6f55c4cf614..a9c9f6194f8 100644 --- a/src/map/ai/states/magic_state.cpp +++ b/src/map/ai/states/magic_state.cpp @@ -64,7 +64,7 @@ CMagicState::CMagicState(CBattleEntity* PEntity, uint16 targid, SpellID spellid, if (errorMsg) { throw CStateInitException(std::make_unique(m_PEntity, PTarget, static_cast(m_PSpell->getID()), 0, - errorMsg == 1 ? MSGBASIC_CANNOT_CAST_SPELL : errorMsg)); + errorMsg == 1 ? MSGBASIC_CANNOT_CAST_SPELL : errorMsg)); } m_castTime = std::chrono::milliseconds(battleutils::CalculateSpellCastTime(m_PEntity, this)); @@ -106,8 +106,7 @@ bool CMagicState::Update(time_point tick) action_t action; - if (!PTarget || m_errorMsg || !CanCastSpell(PTarget, true) || - (HasMoved() && (m_PEntity->objtype != TYPE_PET || static_cast(m_PEntity)->getPetType() != PET_TYPE::AUTOMATON))) + if (!PTarget || m_errorMsg || !CanCastSpell(PTarget, true) || (HasMoved() && (m_PEntity->objtype != TYPE_PET || static_cast(m_PEntity)->getPetType() != PET_TYPE::AUTOMATON))) { m_PEntity->OnCastInterrupted(*this, action, msg, false); m_PEntity->loc.zone->PushPacket(m_PEntity, CHAR_INRANGE_SELF, new CActionPacket(action)); @@ -368,8 +367,7 @@ bool CMagicState::HasCost() } } // check has mp available - else if (!m_PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_MANAFONT) && !(m_flags & MAGICFLAGS_IGNORE_MP) && - battleutils::CalculateSpellCost(m_PEntity, GetSpell()) > m_PEntity->health.mp) + else if (!m_PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_MANAFONT) && !(m_flags & MAGICFLAGS_IGNORE_MP) && battleutils::CalculateSpellCost(m_PEntity, GetSpell()) > m_PEntity->health.mp) { if (m_PEntity->objtype == TYPE_MOB && m_PEntity->health.maxmp == 0) { @@ -419,8 +417,7 @@ uint32 CMagicState::GetRecast() { uint32 RecastTime = 0; - if (!m_PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_CHAINSPELL) && !m_PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_SPONTANEITY) && - !m_instantCast) + if (!m_PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_CHAINSPELL) && !m_PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_SPONTANEITY) && !m_instantCast) { RecastTime = battleutils::CalculateSpellRecastTime(m_PEntity, GetSpell()); } @@ -513,9 +510,7 @@ void CMagicState::ApplyEnmity(CBattleEntity* PTarget, int ce, int ve) m_PEntity->delModifier(Mod::ENMITY, -(m_PEntity->getMod(Mod::DIVINE_BENISON) >> 1)); // Half of divine benison mod amount = -enmity } - if (m_PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_DIVINE_EMBLEM) && - m_PSpell->getSkillType() == SKILL_DIVINE_MAGIC && - enmityApplied) + if (m_PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_DIVINE_EMBLEM) && m_PSpell->getSkillType() == SKILL_DIVINE_MAGIC && enmityApplied) { m_PEntity->StatusEffectContainer->DelStatusEffect(EFFECT_DIVINE_EMBLEM); } @@ -523,8 +518,7 @@ void CMagicState::ApplyEnmity(CBattleEntity* PTarget, int ce, int ve) bool CMagicState::HasMoved() { - return floorf(m_startPos.x * 10 + 0.5f) / 10 != floorf(m_PEntity->loc.p.x * 10 + 0.5f) / 10 || - floorf(m_startPos.z * 10 + 0.5f) / 10 != floorf(m_PEntity->loc.p.z * 10 + 0.5f) / 10; + return floorf(m_startPos.x * 10 + 0.5f) / 10 != floorf(m_PEntity->loc.p.x * 10 + 0.5f) / 10 || floorf(m_startPos.z * 10 + 0.5f) / 10 != floorf(m_PEntity->loc.p.z * 10 + 0.5f) / 10; } void CMagicState::TryInterrupt(CBattleEntity* PAttacker) diff --git a/src/map/ai/states/magic_state.h b/src/map/ai/states/magic_state.h index 03ca681abd0..6cb96484d3c 100644 --- a/src/map/ai/states/magic_state.h +++ b/src/map/ai/states/magic_state.h @@ -58,7 +58,7 @@ class CMagicState : public CState void ApplyEnmity(CBattleEntity* PTarget, int ce, int ve); void ApplyMagicCoverEnmity(CBattleEntity* PCoverAbilityTarget, CBattleEntity* PCoverAbilityUser, CMobEntity* PMob); - void SetInstantCast(bool const bInstantCast) + void SetInstantCast(const bool bInstantCast) { m_instantCast = bInstantCast; } diff --git a/src/map/ai/states/mobskill_state.cpp b/src/map/ai/states/mobskill_state.cpp index c2f7bbf1fc6..4c79add3f8f 100644 --- a/src/map/ai/states/mobskill_state.cpp +++ b/src/map/ai/states/mobskill_state.cpp @@ -95,8 +95,7 @@ void CMobSkillState::SpendCost() m_spentTP = m_PEntity->addTP(-1000); m_PEntity->StatusEffectContainer->DelStatusEffect(EFFECT_SEKKANOKI); } - else if (m_PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_MEIKYO_SHISUI) && - m_PEntity->GetLocalVar("[MeikyoShisui]MobSkillCount") > 0) + else if (m_PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_MEIKYO_SHISUI) && m_PEntity->GetLocalVar("[MeikyoShisui]MobSkillCount") > 0) { auto currentCount = m_PEntity->GetLocalVar("[MeikyoShisui]MobSkillCount"); m_PEntity->SetLocalVar("[MeikyoShisui]MobSkillCount", currentCount - 1); @@ -181,8 +180,7 @@ void CMobSkillState::Cleanup(time_point tick) // charm -> build tp -> leave -> stun -> interrupt TP move with weapon bash -> charm and check TP. Note that weapon bash incurs damage and thus adds TP. // Note: this is very incomplete. Further testing shows that other statuses also reduce TP but in addition it seems that specific mobskills may reduce TP more or less than these numbers // Thus while incomplete, is better than nothing. - if (m_PEntity->StatusEffectContainer && - m_PEntity->StatusEffectContainer->HasStatusEffect({ EFFECT::EFFECT_STUN, EFFECT::EFFECT_TERROR, EFFECT::EFFECT_PETRIFICATION, EFFECT::EFFECT_SLEEP, EFFECT::EFFECT_SLEEP_II, EFFECT::EFFECT_LULLABY })) + if (m_PEntity->StatusEffectContainer && m_PEntity->StatusEffectContainer->HasStatusEffect({ EFFECT::EFFECT_STUN, EFFECT::EFFECT_TERROR, EFFECT::EFFECT_PETRIFICATION, EFFECT::EFFECT_SLEEP, EFFECT::EFFECT_SLEEP_II, EFFECT::EFFECT_LULLABY })) { int16 tp = m_spentTP; if (tp >= 2900) diff --git a/src/map/ai/states/range_state.cpp b/src/map/ai/states/range_state.cpp index 84a8e512848..4d4a641718a 100644 --- a/src/map/ai/states/range_state.cpp +++ b/src/map/ai/states/range_state.cpp @@ -244,7 +244,5 @@ bool CRangeState::CanUseRangedAttack(CBattleEntity* PTarget, bool isEndOfAttack) bool CRangeState::HasMoved() { - return floorf(m_startPos.x * 10 + 0.5f) / 10 != floorf(m_PEntity->loc.p.x * 10 + 0.5f) / 10 || - floorf(m_startPos.y * 10 + 0.5f) / 10 != floorf(m_PEntity->loc.p.y * 10 + 0.5f) / 10 || - floorf(m_startPos.z * 10 + 0.5f) / 10 != floorf(m_PEntity->loc.p.z * 10 + 0.5f) / 10; + return floorf(m_startPos.x * 10 + 0.5f) / 10 != floorf(m_PEntity->loc.p.x * 10 + 0.5f) / 10 || floorf(m_startPos.y * 10 + 0.5f) / 10 != floorf(m_PEntity->loc.p.y * 10 + 0.5f) / 10 || floorf(m_startPos.z * 10 + 0.5f) / 10 != floorf(m_PEntity->loc.p.z * 10 + 0.5f) / 10; } diff --git a/src/map/alliance.cpp b/src/map/alliance.cpp index d8b755faf2e..44afbe2b22a 100644 --- a/src/map/alliance.cpp +++ b/src/map/alliance.cpp @@ -57,7 +57,7 @@ CAlliance::CAlliance(CBattleEntity* PEntity) addParty(PEntity->PParty); this->aLeader = PEntity->PParty; _sql->Query("UPDATE accounts_parties SET partyflag = partyflag | %d WHERE partyid = %u AND partyflag & %d", ALLIANCE_LEADER, m_AllianceID, - PARTY_LEADER); + PARTY_LEADER); } CAlliance::CAlliance(uint32 id) @@ -88,7 +88,7 @@ void CAlliance::dissolveAlliance(bool playerInitiated) _sql->Query("UPDATE accounts_parties JOIN accounts_sessions USING (charid) \ SET allianceid = 0, partyflag = partyflag & ~%d \ WHERE allianceid = %u AND IF(%u = 0 AND %u = 0, true, server_addr = %u AND server_port = %u)", - ALLIANCE_LEADER | PARTY_SECOND | PARTY_THIRD, m_AllianceID, map_ip.s_addr, map_port, map_ip.s_addr, map_port); + ALLIANCE_LEADER | PARTY_SECOND | PARTY_THIRD, m_AllianceID, map_ip.s_addr, map_port, map_ip.s_addr, map_port); // Remove all parties. The `delParty` call removes a party from `partyList`. while (partyList.size() > 0) @@ -148,7 +148,7 @@ void CAlliance::removeParty(CParty* party) int ret = _sql->Query("SELECT charname FROM accounts_sessions JOIN chars ON accounts_sessions.charid = chars.charid \ JOIN accounts_parties ON accounts_parties.charid = chars.charid WHERE allianceid = %u AND partyflag & %d \ AND partyid != %d ORDER BY timestamp ASC LIMIT 1", - m_AllianceID, PARTY_LEADER, party->GetPartyID()); + m_AllianceID, PARTY_LEADER, party->GetPartyID()); if (ret != SQL_ERROR && _sql->NumRows() != 0 && _sql->NextRow() == SQL_SUCCESS) { std::string newLeader((const char*)_sql->GetData(0)); @@ -164,7 +164,7 @@ void CAlliance::removeParty(CParty* party) delParty(party); _sql->Query("UPDATE accounts_parties SET allianceid = 0, partyflag = partyflag & ~%d WHERE partyid = %u", - ALLIANCE_LEADER | PARTY_SECOND | PARTY_THIRD, party->GetPartyID()); + ALLIANCE_LEADER | PARTY_SECOND | PARTY_THIRD, party->GetPartyID()); // notify alliance uint8 data[4]{}; @@ -242,7 +242,7 @@ void CAlliance::addParty(CParty* party) uint8 newparty = 0; int ret = _sql->Query("SELECT partyflag & %d FROM accounts_parties WHERE allianceid = %d ORDER BY partyflag & %d ASC", PARTY_SECOND | PARTY_THIRD, - m_AllianceID, PARTY_SECOND | PARTY_THIRD); + m_AllianceID, PARTY_SECOND | PARTY_THIRD); if (ret != SQL_ERROR && _sql->NumRows() > 0) { @@ -263,7 +263,7 @@ void CAlliance::addParty(CParty* party) PChar->m_charHistory.joinedAlliances++; } _sql->Query("UPDATE accounts_parties SET allianceid = %u, partyflag = partyflag | %d WHERE partyid = %u", m_AllianceID, newparty, - party->GetPartyID()); + party->GetPartyID()); party->SetPartyNumber(newparty); uint8 data[4]{}; @@ -276,7 +276,7 @@ void CAlliance::addParty(uint32 partyid) const int newparty = 0; int ret = _sql->Query("SELECT partyflag FROM accounts_parties WHERE allianceid = %d ORDER BY partyflag & %d ASC", m_AllianceID, - PARTY_SECOND | PARTY_THIRD); + PARTY_SECOND | PARTY_THIRD); if (ret != SQL_ERROR && _sql->NumRows() > 0) { @@ -332,7 +332,7 @@ void CAlliance::assignAllianceLeader(const char* name) int charid = _sql->GetUIntData(0); _sql->Query("UPDATE accounts_parties SET partyflag = partyflag & ~%d WHERE allianceid = %u AND partyflag & %d", ALLIANCE_LEADER, m_AllianceID, - ALLIANCE_LEADER); + ALLIANCE_LEADER); _sql->Query("UPDATE accounts_parties SET allianceid = %u WHERE allianceid = %u", charid, m_AllianceID); m_AllianceID = charid; diff --git a/src/map/attack.cpp b/src/map/attack.cpp index 5c7e9a3acbb..c7f55802617 100644 --- a/src/map/attack.cpp +++ b/src/map/attack.cpp @@ -507,9 +507,7 @@ bool CAttack::CheckCounter() // Do not counter if PD is up if (!m_attacker->StatusEffectContainer->HasStatusEffect(EFFECT_PERFECT_DODGE)) { - if ((xirand::GetRandomNumber(100) < std::clamp(m_victim->getMod(Mod::COUNTER) + meritCounter, 0, 80) || - xirand::GetRandomNumber(100) < seiganChance) && - facing(m_victim->loc.p, m_attacker->loc.p, 64) && xirand::GetRandomNumber(100) < battleutils::GetHitRate(m_victim, m_attacker)) + if ((xirand::GetRandomNumber(100) < std::clamp(m_victim->getMod(Mod::COUNTER) + meritCounter, 0, 80) || xirand::GetRandomNumber(100) < seiganChance) && facing(m_victim->loc.p, m_attacker->loc.p, 64) && xirand::GetRandomNumber(100) < battleutils::GetHitRate(m_victim, m_attacker)) { m_isCountered = true; m_isCritical = (xirand::GetRandomNumber(100) < battleutils::GetCritHitRate(m_victim, m_attacker, false)); @@ -557,9 +555,7 @@ void CAttack::ProcessDamage() auto saDmgBonus = false; auto taDmgBonus = false; // Sneak attack. - if (m_attacker->GetMJob() == JOB_THF && m_isFirstSwing && m_attacker->StatusEffectContainer->HasStatusEffect(EFFECT_SNEAK_ATTACK) && - (behind(m_attacker->loc.p, m_victim->loc.p, 64) || m_attacker->StatusEffectContainer->HasStatusEffect(EFFECT_HIDE) || - m_victim->StatusEffectContainer->HasStatusEffect(EFFECT_DOUBT))) + if (m_attacker->GetMJob() == JOB_THF && m_isFirstSwing && m_attacker->StatusEffectContainer->HasStatusEffect(EFFECT_SNEAK_ATTACK) && (behind(m_attacker->loc.p, m_victim->loc.p, 64) || m_attacker->StatusEffectContainer->HasStatusEffect(EFFECT_HIDE) || m_victim->StatusEffectContainer->HasStatusEffect(EFFECT_DOUBT))) { m_bonusBasePhysicalDamage += m_attacker->DEX() * (1.0f + m_attacker->getMod(Mod::SNEAK_ATK_DEX) / 100.0f); saDmgBonus = true; @@ -624,15 +620,13 @@ void CAttack::ProcessDamage() } // Set attack type to Samba if the attack type is normal. Don't overwrite other types. Used for Samba double damage. - if (m_attackType == PHYSICAL_ATTACK_TYPE::NORMAL && (m_attacker->StatusEffectContainer->HasStatusEffect(EFFECT_DRAIN_SAMBA) || - m_attacker->StatusEffectContainer->HasStatusEffect(EFFECT_ASPIR_SAMBA) || m_attacker->StatusEffectContainer->HasStatusEffect(EFFECT_HASTE_SAMBA))) + if (m_attackType == PHYSICAL_ATTACK_TYPE::NORMAL && (m_attacker->StatusEffectContainer->HasStatusEffect(EFFECT_DRAIN_SAMBA) || m_attacker->StatusEffectContainer->HasStatusEffect(EFFECT_ASPIR_SAMBA) || m_attacker->StatusEffectContainer->HasStatusEffect(EFFECT_HASTE_SAMBA))) { SetAttackType(PHYSICAL_ATTACK_TYPE::SAMBA); } // Get damage multipliers. - m_damage = - attackutils::CheckForDamageMultiplier((CCharEntity*)m_attacker, dynamic_cast(m_attacker->m_Weapons[slot]), m_damage, m_attackType, slot, m_isFirstSwing); + m_damage = attackutils::CheckForDamageMultiplier((CCharEntity*)m_attacker, dynamic_cast(m_attacker->m_Weapons[slot]), m_damage, m_attackType, slot, m_isFirstSwing); // Apply Sneak Attack Augment Mod if (m_attacker->getMod(Mod::AUGMENTS_SA) > 0 && saDmgBonus && m_attacker->StatusEffectContainer->HasStatusEffect(EFFECT_SNEAK_ATTACK)) @@ -660,8 +654,7 @@ void CAttack::ProcessDamage() charutils::TrySkillUP((CCharEntity*)m_attacker, (SKILLTYPE)weapon->getSkillType(), m_victim->GetMLevel()); } } - else if (m_attacker->objtype == TYPE_PET && m_attacker->PMaster && m_attacker->PMaster->objtype == TYPE_PC && - static_cast(m_attacker)->getPetType() == PET_TYPE::AUTOMATON) + else if (m_attacker->objtype == TYPE_PET && m_attacker->PMaster && m_attacker->PMaster->objtype == TYPE_PC && static_cast(m_attacker)->getPetType() == PET_TYPE::AUTOMATON) { puppetutils::TrySkillUP((CAutomatonEntity*)m_attacker, SKILL_AUTOMATON_MELEE, m_victim->GetMLevel()); } diff --git a/src/map/attackround.cpp b/src/map/attackround.cpp index b7ff7a4016d..e18d7bec011 100644 --- a/src/map/attackround.cpp +++ b/src/map/attackround.cpp @@ -267,8 +267,7 @@ void CAttackRound::CreateAttacks(CItemWeapon* PWeapon, PHYSICAL_ATTACK_DIRECTION } // Ambush Augment adds +1% Triple Attack per merit (need to satisfy conditions for Ambush) - if (charutils::hasTrait(PChar, TRAIT_AMBUSH) && PChar->getMod(Mod::AUGMENTS_AMBUSH) > 0 && - abs(m_defender->loc.p.rotation - m_attacker->loc.p.rotation) < 23) + if (charutils::hasTrait(PChar, TRAIT_AMBUSH) && PChar->getMod(Mod::AUGMENTS_AMBUSH) > 0 && abs(m_defender->loc.p.rotation - m_attacker->loc.p.rotation) < 23) { tripleAttack += PChar->PMeritPoints->GetMerit(MERIT_AMBUSH)->count; } @@ -351,8 +350,7 @@ void CAttackRound::CreateAttacks(CItemWeapon* PWeapon, PHYSICAL_ATTACK_DIRECTION uint8 ammoCount = 0; // Two handed and Hand-to-Hand - if (battleutils::GetScaledItemModifier(PChar, PMain, Mod::AMMO_SWING_TYPE) == 2 && - xirand::GetRandomNumber(100) < m_attacker->getMod(Mod::AMMO_SWING) && PAmmo != nullptr && ammoCount < PAmmo->getQuantity()) + if (battleutils::GetScaledItemModifier(PChar, PMain, Mod::AMMO_SWING_TYPE) == 2 && xirand::GetRandomNumber(100) < m_attacker->getMod(Mod::AMMO_SWING) && PAmmo != nullptr && ammoCount < PAmmo->getQuantity()) { AddAttackSwing(PHYSICAL_ATTACK_TYPE::NORMAL, direction, 1); ammoCount += 1; @@ -360,14 +358,12 @@ void CAttackRound::CreateAttacks(CItemWeapon* PWeapon, PHYSICAL_ATTACK_DIRECTION // One handed else { - if (direction == RIGHTATTACK && battleutils::GetScaledItemModifier(PChar, PMain, Mod::AMMO_SWING_TYPE) == 1 && - xirand::GetRandomNumber(100) < m_attacker->getMod(Mod::AMMO_SWING) && PAmmo != nullptr && ammoCount < PAmmo->getQuantity()) + if (direction == RIGHTATTACK && battleutils::GetScaledItemModifier(PChar, PMain, Mod::AMMO_SWING_TYPE) == 1 && xirand::GetRandomNumber(100) < m_attacker->getMod(Mod::AMMO_SWING) && PAmmo != nullptr && ammoCount < PAmmo->getQuantity()) { AddAttackSwing(PHYSICAL_ATTACK_TYPE::NORMAL, RIGHTATTACK, 1); ammoCount += 1; } - if (direction == LEFTATTACK && PSub != nullptr && battleutils::GetScaledItemModifier(PChar, PSub, Mod::AMMO_SWING_TYPE) == 1 && - xirand::GetRandomNumber(100) < m_attacker->getMod(Mod::AMMO_SWING) && PAmmo != nullptr && ammoCount < PAmmo->getQuantity()) + if (direction == LEFTATTACK && PSub != nullptr && battleutils::GetScaledItemModifier(PChar, PSub, Mod::AMMO_SWING_TYPE) == 1 && xirand::GetRandomNumber(100) < m_attacker->getMod(Mod::AMMO_SWING) && PAmmo != nullptr && ammoCount < PAmmo->getQuantity()) { AddAttackSwing(PHYSICAL_ATTACK_TYPE::NORMAL, LEFTATTACK, 1); ammoCount += 1; diff --git a/src/map/autotranslate.cpp b/src/map/autotranslate.cpp index 703371895bb..e8cd9cb59e0 100644 --- a/src/map/autotranslate.cpp +++ b/src/map/autotranslate.cpp @@ -2766,7 +2766,7 @@ const std::map values = { { 220791298, "Rhapsodies of Vana'diel" }, }; -std::string doLookup(std::string const& str, std::vector& data) +std::string doLookup(const std::string& str, std::vector& data) { if (data.size() != 4) { @@ -2821,7 +2821,7 @@ std::string doLookup(std::string const& str, std::vector& data) return values.at(key); } -std::string autotranslate::replaceBytes(std::string const& str) +std::string autotranslate::replaceBytes(const std::string& str) { bool inATBlock = false; std::string outStr = ""; diff --git a/src/map/autotranslate.h b/src/map/autotranslate.h index 9a063352e0b..53b46ed2486 100644 --- a/src/map/autotranslate.h +++ b/src/map/autotranslate.h @@ -6,6 +6,6 @@ namespace autotranslate { // Returns a string where the autotranslate raw bytes have been replaced with a sane string value. - std::string replaceBytes(std::string const& str); + std::string replaceBytes(const std::string& str); } // namespace autotranslate #endif // _AUTOTRANSLATE_H diff --git a/src/map/battlefield.cpp b/src/map/battlefield.cpp index 396d5b46fee..4da9cd3854a 100644 --- a/src/map/battlefield.cpp +++ b/src/map/battlefield.cpp @@ -93,7 +93,7 @@ uint16 CBattlefield::GetZoneID() const return m_Zone->GetID(); } -std::string const& CBattlefield::GetName() const +const std::string& CBattlefield::GetName() const { return m_Name; } @@ -163,7 +163,7 @@ duration CBattlefield::GetLastTimeUpdate() const return m_LastPromptTime; } -uint64_t CBattlefield::GetLocalVar(std::string const& name) const +uint64_t CBattlefield::GetLocalVar(const std::string& name) const { auto var = m_LocalVars.find(name); return var != m_LocalVars.end() ? var->second : 0; @@ -189,12 +189,12 @@ uint32 CBattlefield::GetArmouryCrate() const return m_armouryCrate; } -void CBattlefield::SetName(std::string const& name) +void CBattlefield::SetName(const std::string& name) { m_Name = name; } -void CBattlefield::SetInitiator(std::string const& name) +void CBattlefield::SetInitiator(const std::string& name) { m_Initiator.name = name; } @@ -215,7 +215,7 @@ void CBattlefield::SetArea(uint8 area) m_Area = area; } -void CBattlefield::SetRecord(std::string const& name, duration time, size_t partySize) +void CBattlefield::SetRecord(const std::string& name, duration time, size_t partySize) { m_Record.name = !name.empty() ? name : m_Initiator.name; m_Record.time = time; @@ -243,7 +243,7 @@ void CBattlefield::SetLevelCap(uint8 cap) m_LevelCap = cap; } -void CBattlefield::SetLocalVar(std::string const& name, uint64_t value) +void CBattlefield::SetLocalVar(const std::string& name, uint64_t value) { m_LocalVars[name] = value; } diff --git a/src/map/battlefield.h b/src/map/battlefield.h index ae648c11016..c0181df834b 100644 --- a/src/map/battlefield.h +++ b/src/map/battlefield.h @@ -135,7 +135,7 @@ class CBattlefield : public std::enable_shared_from_this uint16 GetID() const; CZone* GetZone() const; uint16 GetZoneID() const; - std::string const& GetName() const; + const std::string& GetName() const; const BattlefieldInitiator_t& GetInitiator() const; uint8 GetArea() const; const BattlefieldRecord_t& GetRecord() const; @@ -152,7 +152,7 @@ class CBattlefield : public std::enable_shared_from_this duration GetFinishTime() const; duration GetRemainingTime() const; duration GetLastTimeUpdate() const; - uint64_t GetLocalVar(std::string const& name) const; + uint64_t GetLocalVar(const std::string& name) const; uint32 GetArmouryCrate() const; bool CheckInProgress(); @@ -166,17 +166,17 @@ class CBattlefield : public std::enable_shared_from_this void ForEachNpc(const std::function& func); void ForEachAlly(const std::function& func); - void SetName(std::string const& name); - void SetInitiator(std::string const& name); + void SetName(const std::string& name); + void SetInitiator(const std::string& name); void SetArea(uint8 area); - void SetRecord(std::string const& name, duration time, size_t partySize); + void SetRecord(const std::string& name, duration time, size_t partySize); void SetStatus(uint8 status); void SetRuleMask(uint16 rulemask); void SetTimeLimit(duration time); void SetWipeTime(time_point time); void SetMaxParticipants(uint8 max); void SetLevelCap(uint8 cap); - void SetLocalVar(std::string const& name, uint64_t value); + void SetLocalVar(const std::string& name, uint64_t value); void SetLastTimeUpdate(duration time); void setArmouryCrate(uint32 entityId); diff --git a/src/map/char_recast_container.cpp b/src/map/char_recast_container.cpp index e892bb4a1f4..6efcdd51293 100644 --- a/src/map/char_recast_container.cpp +++ b/src/map/char_recast_container.cpp @@ -54,7 +54,7 @@ void CCharRecastContainer::Add(RECASTTYPE type, uint16 id, uint32 duration, uint if (type == RECAST_ABILITY) { _sql->Query("REPLACE INTO char_recast VALUES (%u, %u, %u, %u)", m_PChar->id, recast->ID, static_cast(recast->TimeStamp), - recast->RecastTime); + recast->RecastTime); } } @@ -128,8 +128,10 @@ void CCharRecastContainer::ChangeJob() RecastList_t* PRecastList = GetRecastList(RECAST_ABILITY); PRecastList->erase(std::remove_if(PRecastList->begin(), PRecastList->end(), [](auto& recast) - { return recast.ID != 0; }), - PRecastList->end()); + { + return recast.ID != 0; + }), + PRecastList->end()); _sql->Query("DELETE FROM char_recast WHERE charid = %u AND id != 0", m_PChar->id); } diff --git a/src/map/conquest_data.cpp b/src/map/conquest_data.cpp index f4e460d60cf..021deab5335 100644 --- a/src/map/conquest_data.cpp +++ b/src/map/conquest_data.cpp @@ -174,7 +174,7 @@ void ConquestData::addInfluencePoints(int points, NATION_TYPE nation, REGION_TYP } } -void ConquestData::updateInfluencePoints(std::vector const& influencePoints) +void ConquestData::updateInfluencePoints(const std::vector& influencePoints) { influences.clear(); for (const auto& influence : influencePoints) @@ -183,7 +183,7 @@ void ConquestData::updateInfluencePoints(std::vector const& influen } } -void ConquestData::updateRegionControls(std::vector const& updatedRegionControls) +void ConquestData::updateRegionControls(const std::vector& updatedRegionControls) { regionControls.clear(); for (const auto& regionControl : updatedRegionControls) diff --git a/src/map/conquest_data.h b/src/map/conquest_data.h index f704b1e2852..015f74a0830 100644 --- a/src/map/conquest_data.h +++ b/src/map/conquest_data.h @@ -75,7 +75,7 @@ class ConquestData /** * Gets the array of region controls, indexed by regionId. */ - auto getRegionControls() -> std::vector const; + auto getRegionControls() -> const std::vector; /** * Adds the given influence points to the given nation for the given @@ -85,12 +85,12 @@ class ConquestData /** * Updates the influence points to match those given. */ - void updateInfluencePoints(std::vector const& influencePoints); + void updateInfluencePoints(const std::vector& influencePoints); /** * Updates region controls to match those given. */ - void updateRegionControls(std::vector const& regionControls); + void updateRegionControls(const std::vector& regionControls); private: std::vector regionControls; diff --git a/src/map/conquest_system.cpp b/src/map/conquest_system.cpp index 052be01dee3..d0074a37223 100644 --- a/src/map/conquest_system.cpp +++ b/src/map/conquest_system.cpp @@ -441,7 +441,7 @@ namespace conquest * Called in response to world msg after actual db is updated * * This does NOT update the DB. World server is responsible for that. * ************************************************************************/ - void HandleWeeklyTallyEnd(std::vector const& regionControls) + void HandleWeeklyTallyEnd(const std::vector& regionControls) { TracyZoneScoped; @@ -492,7 +492,7 @@ namespace conquest * * ************************************************************************/ - void HandleInfluenceUpdate(std::vector const& influences, bool shouldUpdateZones) + void HandleInfluenceUpdate(const std::vector& influences, bool shouldUpdateZones) { TracyZoneScoped; @@ -609,9 +609,7 @@ namespace conquest uint8 GetAlliance(uint8 sandoria, uint8 bastok, uint8 windurst) { - if (((sandoria > (bastok + windurst) && sandoria > bastok && sandoria > windurst) && sandoria > 9) || - ((bastok > (sandoria + windurst) && bastok > sandoria && bastok > windurst) && bastok > 9) || - ((windurst > (sandoria + bastok) && windurst > bastok && windurst > sandoria) && windurst > 9)) + if (((sandoria > (bastok + windurst) && sandoria > bastok && sandoria > windurst) && sandoria > 9) || ((bastok > (sandoria + windurst) && bastok > sandoria && bastok > windurst) && bastok > 9) || ((windurst > (sandoria + bastok) && windurst > bastok && windurst > sandoria) && windurst > 9)) { return 1; } diff --git a/src/map/conquest_system.h b/src/map/conquest_system.h index a5310fef9c6..20be29132f5 100644 --- a/src/map/conquest_system.h +++ b/src/map/conquest_system.h @@ -55,19 +55,19 @@ namespace conquest uint8 GetInfluenceRanking(int32 san_inf, int32 bas_inf, int32 win_inf, int32 bst_inf); uint8 GetInfluenceRanking(int32 san_inf, int32 bas_inf, int32 win_inf); - void HandleInfluenceUpdate(std::vector const& influences, bool shouldUpdateZones); // Triggered periodically when world server sends updates of the latest influence data. + void HandleInfluenceUpdate(const std::vector& influences, bool shouldUpdateZones); // Triggered periodically when world server sends updates of the latest influence data. void HandleWeeklyTallyStart(); // Triggered on update conquest system every sunday (by world server msg) - void HandleWeeklyTallyEnd(std::vector const& regionControls); // Triggered when conquest update ends (by world server msg) + void HandleWeeklyTallyEnd(const std::vector& regionControls); // Triggered when conquest update ends (by world server msg) uint8 GetBalance(uint8 sandoria, uint8 bastok, uint8 windurst, // Ranking for 3 nations - uint8 sandoria_prev, uint8 bastok_prev, uint8 windurst_prev); + uint8 sandoria_prev, uint8 bastok_prev, uint8 windurst_prev); uint8 GetBalance(); uint8 GetAlliance(uint8 sandoria, uint8 bastok, uint8 windurst); // Determine if losing nations are allied uint8 GetAlliance(uint8 sandoria, uint8 bastok, uint8 windurst, // Determine if losing nations are allied - uint8 sandoria_prev, uint8 bastok_prev, uint8 windurst_prev); + uint8 sandoria_prev, uint8 bastok_prev, uint8 windurst_prev); bool IsAlliance(); // Determine if losing nations are allied uint8 GetNexTally(); // Next tally (weekly or every hour ?) uint8 GetRegionOwner(REGION_TYPE RegionID); // Get owner of the region uint32 AddConquestPoints(CCharEntity* PChar, uint32 exp); // Add conquest points -}; // namespace conquest +}; // namespace conquest diff --git a/src/map/entities/baseentity.h b/src/map/entities/baseentity.h index 1947dd27cf2..55d41e58505 100644 --- a/src/map/entities/baseentity.h +++ b/src/map/entities/baseentity.h @@ -299,7 +299,7 @@ class CBaseEntity void SetModelId(uint16 modelId); // Set new modelid uint16 GetModelId() const; // Get the modelid - virtual void HandleErrorMessage(std::unique_ptr&){}; + virtual void HandleErrorMessage(std::unique_ptr&) {}; bool IsDynamicEntity() const; diff --git a/src/map/entities/battleentity.cpp b/src/map/entities/battleentity.cpp index daf10150c43..0fd89a9ebeb 100644 --- a/src/map/entities/battleentity.cpp +++ b/src/map/entities/battleentity.cpp @@ -124,8 +124,7 @@ bool CBattleEntity::isInAssault() { if (loc.zone != nullptr) { - return loc.zone->GetTypeMask() & ZONE_TYPE::INSTANCED && - (loc.zone->GetRegionID() >= REGION_TYPE::WEST_AHT_URHGAN && loc.zone->GetRegionID() <= REGION_TYPE::ALZADAAL); + return loc.zone->GetTypeMask() & ZONE_TYPE::INSTANCED && (loc.zone->GetRegionID() >= REGION_TYPE::WEST_AHT_URHGAN && loc.zone->GetRegionID() <= REGION_TYPE::ALZADAAL); } return false; } @@ -197,10 +196,8 @@ void CBattleEntity::UpdateHealth() TracyZoneScoped; int32 dif = (getMod(Mod::CONVMPTOHP) - getMod(Mod::CONVHPTOMP)); - health.modmp = std::max(0, ((health.maxmp) * (100 + getMod(Mod::MPP)) / 100) + - std::min((health.maxmp * m_modStat[Mod::FOOD_MPP] / 100), m_modStat[Mod::FOOD_MP_CAP]) + getMod(Mod::MP)); - health.modhp = std::max(1, ((health.maxhp) * (100 + getMod(Mod::HPP)) / 100) + - std::min((health.maxhp * m_modStat[Mod::FOOD_HPP] / 100), m_modStat[Mod::FOOD_HP_CAP]) + getMod(Mod::HP)); + health.modmp = std::max(0, ((health.maxmp) * (100 + getMod(Mod::MPP)) / 100) + std::min((health.maxmp * m_modStat[Mod::FOOD_MPP] / 100), m_modStat[Mod::FOOD_MP_CAP]) + getMod(Mod::MP)); + health.modhp = std::max(1, ((health.maxhp) * (100 + getMod(Mod::HPP)) / 100) + std::min((health.maxhp * m_modStat[Mod::FOOD_HPP] / 100), m_modStat[Mod::FOOD_HP_CAP]) + getMod(Mod::HP)); dif = (health.modmp - 0) < dif ? (health.modmp - 0) : dif; dif = (health.modhp - 1) < -dif ? -(health.modhp - 1) : dif; @@ -374,7 +371,7 @@ int16 CBattleEntity::GetWeaponDelay(bool tp) WeaponDelay -= getMod(Mod::MARTIAL_ARTS) * 1000 / 60; } else if (auto* subweapon = dynamic_cast(m_Weapons[SLOT_SUB]); - subweapon && subweapon->getDmgType() > DAMAGE_TYPE::NONE && subweapon->getDmgType() < DAMAGE_TYPE::HTH) + subweapon && subweapon->getDmgType() > DAMAGE_TYPE::NONE && subweapon->getDmgType() < DAMAGE_TYPE::HTH) { MinimumDelay += subweapon->getDelay(); WeaponDelay += subweapon->getDelay(); @@ -693,7 +690,7 @@ int32 CBattleEntity::addMP(int32 mp) } int32 CBattleEntity::takeDamage(int32 amount, CBattleEntity* attacker /* = nullptr*/, ATTACK_TYPE attackType /* = ATTACK_NONE*/, - DAMAGE_TYPE damageType /* = DAMAGE_NONE*/, bool isSkillchainDamage /* = false */) + DAMAGE_TYPE damageType /* = DAMAGE_NONE*/, bool isSkillchainDamage /* = false */) { TracyZoneScoped; PLastAttacker = attacker; @@ -1547,8 +1544,7 @@ bool CBattleEntity::ValidTarget(CBattleEntity* PInitiator, uint16 targetFlags) } // Nation PVP - if ((allegiance >= ALLEGIANCE_TYPE::SAN_DORIA && allegiance <= ALLEGIANCE_TYPE::WINDURST) && - (PInitiator->allegiance >= ALLEGIANCE_TYPE::SAN_DORIA && PInitiator->allegiance <= ALLEGIANCE_TYPE::WINDURST)) + if ((allegiance >= ALLEGIANCE_TYPE::SAN_DORIA && allegiance <= ALLEGIANCE_TYPE::WINDURST) && (PInitiator->allegiance >= ALLEGIANCE_TYPE::SAN_DORIA && PInitiator->allegiance <= ALLEGIANCE_TYPE::WINDURST)) { return allegiance != PInitiator->allegiance; } @@ -1575,9 +1571,7 @@ bool CBattleEntity::ValidTarget(CBattleEntity* PInitiator, uint16 targetFlags) } } - return (targetFlags & TARGET_SELF) && - (this == PInitiator || - (PInitiator->objtype == TYPE_PET && static_cast(PInitiator)->getPetType() == PET_TYPE::AUTOMATON && this == PInitiator->PMaster)); + return (targetFlags & TARGET_SELF) && (this == PInitiator || (PInitiator->objtype == TYPE_PET && static_cast(PInitiator)->getPetType() == PET_TYPE::AUTOMATON && this == PInitiator->PMaster)); } bool CBattleEntity::CanUseSpell(CSpell* PSpell) @@ -1796,15 +1790,13 @@ void CBattleEntity::OnCastFinished(CMagicState& state, action_t& action) state.ApplyEnmity(PTarget, ce, ve); } - if (PTarget->objtype == TYPE_MOB && - msg != MSGBASIC_SHADOW_ABSORB) // If message isn't the shadow loss message, because I had to move this outside of the above check for it. + if (PTarget->objtype == TYPE_MOB && msg != MSGBASIC_SHADOW_ABSORB) // If message isn't the shadow loss message, because I had to move this outside of the above check for it. { luautils::OnMagicHit(this, PTarget, PSpell); } if (this == PTarget || // Casting on self or ally - (this->PParty && PTarget->PParty && - ((this->PParty == PTarget->PParty) || (this->PParty->m_PAlliance && this->PParty->m_PAlliance == PTarget->PParty->m_PAlliance)))) + (this->PParty && PTarget->PParty && ((this->PParty == PTarget->PParty) || (this->PParty->m_PAlliance && this->PParty->m_PAlliance == PTarget->PParty->m_PAlliance)))) { if (PSpell->isHeal()) { @@ -2095,7 +2087,7 @@ void CBattleEntity::OnMobSkillFinished(CMobSkillState& state, action_t& action) if (first && (PSkill->getPrimarySkillchain() != 0)) { SUBEFFECT effect = battleutils::GetSkillChainEffect(PTargetFound, PSkill->getPrimarySkillchain(), PSkill->getSecondarySkillchain(), - PSkill->getTertiarySkillchain()); + PSkill->getTertiarySkillchain()); if (effect != SUBEFFECT_NONE) { int32 skillChainDamage = battleutils::TakeSkillchainDamage(this, PTargetFound, target.param, nullptr); @@ -2257,8 +2249,7 @@ bool CBattleEntity::OnAttack(CAttackState& state, action_t& action) actionTarget.reaction = REACTION::PARRY | REACTION::HIT; actionTarget.speceffect = SPECEFFECT::NONE; } - else if ((xirand::GetRandomNumber(100) < attack.GetHitRate() || attackRound.GetSATAOccured()) && - !PTarget->StatusEffectContainer->HasStatusEffect(EFFECT_ALL_MISS)) + else if ((xirand::GetRandomNumber(100) < attack.GetHitRate() || attackRound.GetSATAOccured()) && !PTarget->StatusEffectContainer->HasStatusEffect(EFFECT_ALL_MISS)) { // Check parry. if (attack.CheckParried()) @@ -2338,15 +2329,13 @@ bool CBattleEntity::OnAttack(CAttackState& state, action_t& action) float DamageRatio = battleutils::GetDamageRatio(PTarget, this, attack.IsCritical(), attBonus, skilltype, SLOT_MAIN); auto damage = (int32)((PTarget->GetMainWeaponDmg() + naturalh2hDMG + battleutils::GetFSTR(PTarget, this, SLOT_MAIN)) * DamageRatio); - actionTarget.spikesParam = - battleutils::TakePhysicalDamage(PTarget, this, attack.GetAttackType(), damage, false, SLOT_MAIN, 1, nullptr, true, false, true); + actionTarget.spikesParam = battleutils::TakePhysicalDamage(PTarget, this, attack.GetAttackType(), damage, false, SLOT_MAIN, 1, nullptr, true, false, true); actionTarget.spikesMessage = 33; if (PTarget->objtype == TYPE_PC) { charutils::TrySkillUP((CCharEntity*)PTarget, skilltype, GetMLevel()); } // In case the Automaton can counter - else if (PTarget->objtype == TYPE_PET && PTarget->PMaster && PTarget->PMaster->objtype == TYPE_PC && - static_cast(PTarget)->getPetType() == PET_TYPE::AUTOMATON) + else if (PTarget->objtype == TYPE_PET && PTarget->PMaster && PTarget->PMaster->objtype == TYPE_PC && static_cast(PTarget)->getPetType() == PET_TYPE::AUTOMATON) { puppetutils::TrySkillUP((CAutomatonEntity*)PTarget, SKILL_AUTOMATON_MELEE, GetMLevel()); } @@ -2409,9 +2398,8 @@ bool CBattleEntity::OnAttack(CAttackState& state, action_t& action) actionTarget.reaction |= REACTION::BLOCK; } - actionTarget.param = - battleutils::TakePhysicalDamage(this, PTarget, attack.GetAttackType(), attack.GetDamage(), attack.IsBlocked(), attack.GetWeaponSlot(), 1, - attackRound.GetTAEntity(), true, true, attack.IsCountered(), attack.IsCovered(), POriginalTarget); + actionTarget.param = battleutils::TakePhysicalDamage(this, PTarget, attack.GetAttackType(), attack.GetDamage(), attack.IsBlocked(), attack.GetWeaponSlot(), 1, + attackRound.GetTAEntity(), true, true, attack.IsCountered(), attack.IsCovered(), POriginalTarget); if (actionTarget.param < 0) { actionTarget.param = -(actionTarget.param); @@ -2478,7 +2466,7 @@ bool CBattleEntity::OnAttack(CAttackState& state, action_t& action) if ((actionTarget.reaction & REACTION::MISS) == REACTION::NONE && attack.GetAttackType() != PHYSICAL_ATTACK_TYPE::DAKEN) { battleutils::HandleEnspell(this, PTarget, &actionTarget, attack.IsFirstSwing(), (CItemWeapon*)this->m_Weapons[attack.GetWeaponSlot()], - attack.GetDamage()); + attack.GetDamage()); battleutils::HandleSpikesDamage(this, PTarget, &actionTarget, attack.GetDamage()); } @@ -2501,9 +2489,7 @@ bool CBattleEntity::OnAttack(CAttackState& state, action_t& action) uint16 zanshinChance = this->getMod(Mod::ZANSHIN) + battleutils::GetMeritValue(this, MERIT_ZASHIN_ATTACK_RATE); zanshinChance = std::clamp(zanshinChance, 0, 100); // zanshin may only proc on a missed/guarded/countered swing or as SAM main with hasso up (at 25% of the base zanshin rate) - if ((((actionTarget.reaction & REACTION::MISS) != REACTION::NONE || (actionTarget.reaction & REACTION::GUARDED) != REACTION::NONE || actionTarget.spikesEffect == SUBEFFECT_COUNTER) && - xirand::GetRandomNumber(100) < zanshinChance) || - (GetMJob() == JOB_SAM && this->StatusEffectContainer->HasStatusEffect(EFFECT_HASSO) && xirand::GetRandomNumber(100) < (zanshinChance / 4))) + if ((((actionTarget.reaction & REACTION::MISS) != REACTION::NONE || (actionTarget.reaction & REACTION::GUARDED) != REACTION::NONE || actionTarget.spikesEffect == SUBEFFECT_COUNTER) && xirand::GetRandomNumber(100) < zanshinChance) || (GetMJob() == JOB_SAM && this->StatusEffectContainer->HasStatusEffect(EFFECT_HASSO) && xirand::GetRandomNumber(100) < (zanshinChance / 4))) { attackRound.AddAttackSwing(PHYSICAL_ATTACK_TYPE::ZANSHIN, PHYSICAL_ATTACK_DIRECTION::RIGHTATTACK, 1); } @@ -2604,8 +2590,7 @@ void CBattleEntity::Tick(time_point /*unused*/) void CBattleEntity::PostTick() { TracyZoneScoped; - if (health.hp == 0 && PAI->IsSpawned() && !PAI->IsCurrentState() && !PAI->IsCurrentState() && - !PAI->IsCurrentState()) + if (health.hp == 0 && PAI->IsSpawned() && !PAI->IsCurrentState() && !PAI->IsCurrentState() && !PAI->IsCurrentState()) { Die(); } diff --git a/src/map/entities/battleentity.h b/src/map/entities/battleentity.h index fa05d11f99f..7713e7865e9 100644 --- a/src/map/entities/battleentity.h +++ b/src/map/entities/battleentity.h @@ -614,7 +614,7 @@ class CBattleEntity : public CBaseEntity // Deals damage and updates the last attacker which is used when sending a player death message virtual int32 takeDamage(int32 amount, CBattleEntity* attacker = nullptr, ATTACK_TYPE attackType = ATTACK_TYPE::NONE, - DAMAGE_TYPE damageType = DAMAGE_TYPE::NONE, bool isSkillchainDamage = false); + DAMAGE_TYPE damageType = DAMAGE_TYPE::NONE, bool isSkillchainDamage = false); int16 getMod(Mod modID); int16 getMaxGearMod(Mod modID); diff --git a/src/map/entities/charentity.cpp b/src/map/entities/charentity.cpp index 3c9cfdca407..f138d34c9f3 100644 --- a/src/map/entities/charentity.cpp +++ b/src/map/entities/charentity.cpp @@ -617,10 +617,7 @@ bool CCharEntity::shouldPetPersistThroughZoning() petType = petZoningInfo.petType; } - return petType == PET_TYPE::WYVERN || - petType == PET_TYPE::AVATAR || - petType == PET_TYPE::AUTOMATON || - (petType == PET_TYPE::JUG_PET && settings::get("map.KEEP_JUGPET_THROUGH_ZONING")); + return petType == PET_TYPE::WYVERN || petType == PET_TYPE::AVATAR || petType == PET_TYPE::AUTOMATON || (petType == PET_TYPE::JUG_PET && settings::get("map.KEEP_JUGPET_THROUGH_ZONING")); } /************************************************************************ @@ -1070,17 +1067,13 @@ bool CCharEntity::ValidTarget(CBattleEntity* PInitiator, uint16 targetFlags) bool isTrust = PInitiator->objtype == TYPE_TRUST; // Alliance member valid target. - if (targetsAlliance && - isSameAlliance && - isDifferentChar) + if (targetsAlliance && isSameAlliance && isDifferentChar) { return true; } // Party member valid targeting. - if ((targetsParty || hasPianissimo) && - (isSameParty || isPartyPetMaster || isSoloPetMaster) && - isDifferentChar) + if ((targetsParty || hasPianissimo) && (isSameParty || isPartyPetMaster || isSoloPetMaster) && isDifferentChar) { return true; } @@ -1185,9 +1178,7 @@ void CCharEntity::OnCastFinished(CMagicState& state, action_t& action) // Only blue spells that act as a physical WS can TA. CBattleEntity* taChar = nullptr; - if (StatusEffectContainer->HasStatusEffect(EFFECT_TRICK_ATTACK) && - PSpell->getSpellGroup() == SPELLGROUP_BLUE && - PSpell->dealsDamage()) + if (StatusEffectContainer->HasStatusEffect(EFFECT_TRICK_ATTACK) && PSpell->getSpellGroup() == SPELLGROUP_BLUE && PSpell->dealsDamage()) { taChar = battleutils::getAvailableTrickAttackChar(this, PTarget); } @@ -1198,11 +1189,7 @@ void CCharEntity::OnCastFinished(CMagicState& state, action_t& action) { for (auto&& actionTarget : actionList.actionTargets) { - if (actionTarget.param > 0 && - PSpell->dealsDamage() && - PSpell->getSpellGroup() == SPELLGROUP_BLUE && - (StatusEffectContainer->HasStatusEffect(EFFECT_CHAIN_AFFINITY) || StatusEffectContainer->HasStatusEffect(EFFECT_AZURE_LORE)) && - static_cast(PSpell)->getPrimarySkillchain() != 0) + if (actionTarget.param > 0 && PSpell->dealsDamage() && PSpell->getSpellGroup() == SPELLGROUP_BLUE && (StatusEffectContainer->HasStatusEffect(EFFECT_CHAIN_AFFINITY) || StatusEffectContainer->HasStatusEffect(EFFECT_AZURE_LORE)) && static_cast(PSpell)->getPrimarySkillchain() != 0) { auto* PBlueSpell = static_cast(PSpell); SUBEFFECT effect = battleutils::GetSkillChainEffect(PTarget, PBlueSpell->getPrimarySkillchain(), PBlueSpell->getSecondarySkillchain(), 0); @@ -1227,10 +1214,7 @@ void CCharEntity::OnCastFinished(CMagicState& state, action_t& action) } // Immanence will create or extend a skillchain for elemental spells - if (actionTarget.param >= 0 && - PSpell->dealsDamage() && - PSpell->getSpellGroup() == SPELLGROUP_BLACK && - (StatusEffectContainer->HasStatusEffect(EFFECT_IMMANENCE))) + if (actionTarget.param >= 0 && PSpell->dealsDamage() && PSpell->getSpellGroup() == SPELLGROUP_BLACK && (StatusEffectContainer->HasStatusEffect(EFFECT_IMMANENCE))) { auto immanenceApplies = true; auto isHelix = false; @@ -1481,7 +1465,7 @@ void CCharEntity::OnWeaponSkillFinished(CWeaponSkillState& state, action_t& acti // NOTE: GetSkillChainEffect is INSIDE this if statement because it // ALTERS the state of the resonance, which misses and non-elemental skills should NOT do. SUBEFFECT effect = battleutils::GetSkillChainEffect(PBattleTarget, PWeaponSkill->getPrimarySkillchain(), - PWeaponSkill->getSecondarySkillchain(), PWeaponSkill->getTertiarySkillchain()); + PWeaponSkill->getSecondarySkillchain(), PWeaponSkill->getTertiarySkillchain()); // See SUBEFFECT enum in battleentity.h if (effect != SUBEFFECT_NONE) { @@ -2102,8 +2086,7 @@ void CCharEntity::OnRangedAttack(CRangeState& state, action_t& action) auto attackType = (state.IsRapidShot()) ? PHYSICAL_ATTACK_TYPE::RAPID_SHOT : PHYSICAL_ATTACK_TYPE::RANGED; totalDamage = attackutils::CheckForDamageMultiplier(this, PItem, totalDamage, attackType, slot, true); } - actionTarget.param = - battleutils::TakePhysicalDamage(this, PTarget, PHYSICAL_ATTACK_TYPE::RANGED, totalDamage, false, slot, realHits, nullptr, true, true); + actionTarget.param = battleutils::TakePhysicalDamage(this, PTarget, PHYSICAL_ATTACK_TYPE::RANGED, totalDamage, false, slot, realHits, nullptr, true, true); // absorb message if (actionTarget.param < 0) @@ -2117,8 +2100,7 @@ void CCharEntity::OnRangedAttack(CRangeState& state, action_t& action) // or else sleep effect won't work // battleutils::HandleRangedAdditionalEffect(this,PTarget,&Action); // TODO: move all hard coded additional effect ammo to scripts - if ((PAmmo != nullptr && battleutils::GetScaledItemModifier(this, PAmmo, Mod::ITEM_ADDEFFECT_TYPE) > 0) || - (PItem != nullptr && battleutils::GetScaledItemModifier(this, PItem, Mod::ITEM_ADDEFFECT_TYPE) > 0)) + if ((PAmmo != nullptr && battleutils::GetScaledItemModifier(this, PAmmo, Mod::ITEM_ADDEFFECT_TYPE) > 0) || (PItem != nullptr && battleutils::GetScaledItemModifier(this, PItem, Mod::ITEM_ADDEFFECT_TYPE) > 0)) { // TODO } @@ -2440,7 +2422,7 @@ void CCharEntity::OnItemFinish(CItemState& state, action_t& action) if (PItem->getCurrentCharges() != 0) { this->PRecastContainer->Add(RECAST_ITEM, PItem->getSlotID() << 8 | PItem->getLocationID(), - PItem->getReuseTime() / 1000); // add recast timer to Recast List from any bag + PItem->getReuseTime() / 1000); // add recast timer to Recast List from any bag } } else // unlock all items except equipment @@ -2514,9 +2496,7 @@ void CCharEntity::Die() // influence for conquest system conquest::LoseInfluencePoints(this); - if (GetLocalVar("MijinGakure") == 0 && - (PBattlefield == nullptr || (PBattlefield->GetRuleMask() & RULES_LOSE_EXP) == RULES_LOSE_EXP) && - GetMLevel() >= settings::get("map.EXP_LOSS_LEVEL")) + if (GetLocalVar("MijinGakure") == 0 && (PBattlefield == nullptr || (PBattlefield->GetRuleMask() & RULES_LOSE_EXP) == RULES_LOSE_EXP) && GetMLevel() >= settings::get("map.EXP_LOSS_LEVEL")) { float retainPercent = std::clamp(settings::get("map.EXP_RETAIN") + getMod(Mod::EXPERIENCE_RETAINED) / 100.0f, 0.0f, 1.0f); charutils::DelExperiencePoints(this, retainPercent, 0); @@ -2695,8 +2675,7 @@ void CCharEntity::UpdateMoghancement() { CItemFurnishing* PFurniture = static_cast(PItem); // If aura is tied then use whichever furniture was placed most recently - if (PFurniture->isInstalled() && !PFurniture->getOn2ndFloor() && PFurniture->getElement() == dominantElement && - (PFurniture->getAura() > bestAura || (PFurniture->getAura() == bestAura && PFurniture->getOrder() < bestOrder))) + if (PFurniture->isInstalled() && !PFurniture->getOn2ndFloor() && PFurniture->getElement() == dominantElement && (PFurniture->getAura() > bestAura || (PFurniture->getAura() == bestAura && PFurniture->getOrder() < bestOrder))) { bestAura = PFurniture->getAura(); bestOrder = PFurniture->getOrder(); @@ -3134,7 +3113,7 @@ void CCharEntity::setLocked(bool locked) } } -int32 CCharEntity::getCharVar(std::string const& charVarName) +int32 CCharEntity::getCharVar(const std::string& charVarName) { if (auto charVar = charVarCache.find(charVarName); charVar != charVarCache.end()) { @@ -3155,29 +3134,29 @@ int32 CCharEntity::getCharVar(std::string const& charVarName) return value.first; } -void CCharEntity::setCharVar(std::string const& charVarName, int32 value, uint32 expiry /* = 0 */) +void CCharEntity::setCharVar(const std::string& charVarName, int32 value, uint32 expiry /* = 0 */) { charVarCache[charVarName] = { value, expiry }; charutils::PersistCharVar(this->id, charVarName, value, expiry); } -void CCharEntity::setVolatileCharVar(std::string const& charVarName, int32 value, uint32 expiry /* = 0 */) +void CCharEntity::setVolatileCharVar(const std::string& charVarName, int32 value, uint32 expiry /* = 0 */) { charVarCache[charVarName] = { value, expiry }; charVarChanges.insert(charVarName); } -void CCharEntity::updateCharVarCache(std::string const& charVarName, int32 value, uint32 expiry /* = 0 */) +void CCharEntity::updateCharVarCache(const std::string& charVarName, int32 value, uint32 expiry /* = 0 */) { charVarCache[charVarName] = { value, expiry }; } -void CCharEntity::removeFromCharVarCache(std::string const& varName) +void CCharEntity::removeFromCharVarCache(const std::string& varName) { charVarCache.erase(varName); } -void CCharEntity::clearCharVarsWithPrefix(std::string const& prefix) +void CCharEntity::clearCharVarsWithPrefix(const std::string& prefix) { if (prefix.size() < 5) { diff --git a/src/map/entities/charentity.h b/src/map/entities/charentity.h index 3e4ca029b66..6d132009700 100644 --- a/src/map/entities/charentity.h +++ b/src/map/entities/charentity.h @@ -367,7 +367,7 @@ class CCharEntity : public CBattleEntity std::vector PTrusts; // Active trusts template - void ForPartyWithTrusts(F const& func, Args&&... args) + void ForPartyWithTrusts(const F& func, Args&&... args) { if (PParty) { @@ -605,13 +605,13 @@ class CCharEntity : public CBattleEntity virtual void OnItemFinish(CItemState&, action_t&); - int32 getCharVar(std::string const& varName); - void setCharVar(std::string const& varName, int32 value, uint32 expiry = 0); - void setVolatileCharVar(std::string const& varName, int32 value, uint32 expiry = 0); - void updateCharVarCache(std::string const& varName, int32 value, uint32 expiry = 0); - void removeFromCharVarCache(std::string const& varName); + int32 getCharVar(const std::string& varName); + void setCharVar(const std::string& varName, int32 value, uint32 expiry = 0); + void setVolatileCharVar(const std::string& varName, int32 value, uint32 expiry = 0); + void updateCharVarCache(const std::string& varName, int32 value, uint32 expiry = 0); + void removeFromCharVarCache(const std::string& varName); - void clearCharVarsWithPrefix(std::string const& prefix); + void clearCharVarsWithPrefix(const std::string& prefix); bool m_Locked; // Is the player locked in a cutscene diff --git a/src/map/entities/mobentity.cpp b/src/map/entities/mobentity.cpp index 92a3ce22e8d..bcae3b81d2b 100644 --- a/src/map/entities/mobentity.cpp +++ b/src/map/entities/mobentity.cpp @@ -666,9 +666,7 @@ void CMobEntity::DistributeRewards() } // check for gil (beastmen drop gil, some NMs drop gil) - if ((settings::get("map.MOB_GIL_MULTIPLIER") > 0.0f && CanDropGil()) || - (settings::get("map.ALL_MOBS_GIL_BONUS") > 0 && - getMobMod(MOBMOD_GIL_MAX) >= 0)) // Negative value of MOBMOD_GIL_MAX is used to prevent gil drops in Dynamis/Limbus. + if ((settings::get("map.MOB_GIL_MULTIPLIER") > 0.0f && CanDropGil()) || (settings::get("map.ALL_MOBS_GIL_BONUS") > 0 && getMobMod(MOBMOD_GIL_MAX) >= 0)) // Negative value of MOBMOD_GIL_MAX is used to prevent gil drops in Dynamis/Limbus. { charutils::DistributeGil(PChar, this); // TODO: REALISATION MUST BE IN TREASUREPOOL } diff --git a/src/map/entities/petentity.cpp b/src/map/entities/petentity.cpp index bf7b9d5c176..8a7d7401ef3 100644 --- a/src/map/entities/petentity.cpp +++ b/src/map/entities/petentity.cpp @@ -573,7 +573,7 @@ void CPetEntity::OnPetSkillFinished(CPetSkillState& state, action_t& action) if (first && (PSkill->getPrimarySkillchain() != 0)) { SUBEFFECT effect = battleutils::GetSkillChainEffect(PTargetFound, PSkill->getPrimarySkillchain(), PSkill->getSecondarySkillchain(), - PSkill->getTertiarySkillchain()); + PSkill->getTertiarySkillchain()); if (effect != SUBEFFECT_NONE) { int32 skillChainDamage = battleutils::TakeSkillchainDamage(this, PTargetFound, target.param, nullptr); diff --git a/src/map/entities/trustentity.cpp b/src/map/entities/trustentity.cpp index 47f78b0be62..75d6a90d2b0 100644 --- a/src/map/entities/trustentity.cpp +++ b/src/map/entities/trustentity.cpp @@ -55,9 +55,9 @@ CTrustEntity::CTrustEntity(CCharEntity* PChar) spawnAnimation = SPAWN_ANIMATION::SPECIAL; // Initial spawn has the special spawn-in animation PAI = std::make_unique(this, - std::make_unique(this), - std::make_unique(PChar, this), - std::make_unique(this)); + std::make_unique(this), + std::make_unique(PChar, this), + std::make_unique(this)); } CTrustEntity::~CTrustEntity() @@ -382,8 +382,7 @@ void CTrustEntity::OnRangedAttack(CRangeState& state, action_t& action) actionTarget.speceffect = SPECEFFECT::CRITICAL_HIT; } - actionTarget.param = - battleutils::TakePhysicalDamage(this, PTarget, PHYSICAL_ATTACK_TYPE::RANGED, totalDamage, false, slot, realHits, nullptr, true, true); + actionTarget.param = battleutils::TakePhysicalDamage(this, PTarget, PHYSICAL_ATTACK_TYPE::RANGED, totalDamage, false, slot, realHits, nullptr, true, true); // lower damage based on shadows taken if (shadowsTaken) @@ -578,7 +577,7 @@ void CTrustEntity::OnWeaponSkillFinished(CWeaponSkillState& state, action_t& act // NOTE: GetSkillChainEffect is INSIDE this if statement because it // ALTERS the state of the resonance, which misses and non-elemental skills should NOT do. SUBEFFECT effect = battleutils::GetSkillChainEffect(PBattleTarget, PWeaponSkill->getPrimarySkillchain(), - PWeaponSkill->getSecondarySkillchain(), PWeaponSkill->getTertiarySkillchain()); + PWeaponSkill->getSecondarySkillchain(), PWeaponSkill->getTertiarySkillchain()); if (effect != SUBEFFECT_NONE) { actionTarget.addEffectParam = battleutils::TakeSkillchainDamage(this, PBattleTarget, damage, taChar); diff --git a/src/map/guild.h b/src/map/guild.h index 4b101481be0..b1d2ce8051d 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -42,7 +42,7 @@ struct GPItem_t GPItem_t(CItem* _item, uint16 _maxpoints, uint16 _points) : item(_item) , maxpoints(_maxpoints) - , points(_points){}; + , points(_points) {}; }; class CGuild diff --git a/src/map/instance.cpp b/src/map/instance.cpp index 819bcdb1381..7747d24607e 100644 --- a/src/map/instance.cpp +++ b/src/map/instance.cpp @@ -171,7 +171,7 @@ duration CInstance::GetElapsedTime(time_point tick) return tick - m_startTime; } -uint64_t CInstance::GetLocalVar(std::string const& name) const +uint64_t CInstance::GetLocalVar(const std::string& name) const { auto var = m_LocalVars.find(name); return var != m_LocalVars.end() ? var->second : 0; @@ -211,7 +211,7 @@ void CInstance::SetWipeTime(duration time) m_wipeTimer = time + m_startTime; } -void CInstance::SetLocalVar(std::string const& name, uint64_t value) +void CInstance::SetLocalVar(const std::string& name, uint64_t value) { m_LocalVars[name] = value; } diff --git a/src/map/instance.h b/src/map/instance.h index 983397afb95..169fb62f13d 100644 --- a/src/map/instance.h +++ b/src/map/instance.h @@ -52,7 +52,7 @@ class CInstance : public CZoneEntities uint32 GetStage() const; // Tracks the progress through the instance (eg. floor #) duration GetWipeTime(); // Get time wipe happened (elapsed since start) duration GetElapsedTime(time_point tick); // Get elapsed time so far - uint64_t GetLocalVar(std::string const& name) const; + uint64_t GetLocalVar(const std::string& name) const; void SetLevelCap(uint8 cap); void SetEntryLoc(float x, float y, float z, float rot); // Set entry location @@ -61,7 +61,7 @@ class CInstance : public CZoneEntities void SetProgress(uint32 progress); // Set progress through current stage void SetStage(uint32 stage); // Set current stage (eg. floor #) void SetWipeTime(duration time); // Set elapsed time when a wipe is detected - void SetLocalVar(std::string const& name, uint64_t value); + void SetLocalVar(const std::string& name, uint64_t value); void CheckTime(time_point tick); // Check time limit (run instance time script) bool CharRegistered(CCharEntity* PChar); // Check if PChar is registered to this instance diff --git a/src/map/instance_loader.cpp b/src/map/instance_loader.cpp index 4017cfc211d..c39b353e086 100644 --- a/src/map/instance_loader.cpp +++ b/src/map/instance_loader.cpp @@ -291,8 +291,8 @@ CInstance* CInstanceLoader::LoadInstance() // Add to cache luautils::CacheLuaObjectFromFile( fmt::format("./scripts/zones/{}/mobs/{}.lua", - PMob.second->loc.zone->getName(), - PMob.second->getName())); + PMob.second->loc.zone->getName(), + PMob.second->getName())); } // Finish setting up NPCs @@ -303,8 +303,8 @@ CInstance* CInstanceLoader::LoadInstance() // Add to cache luautils::CacheLuaObjectFromFile( fmt::format("./scripts/zones/{}/npcs/{}.lua", - PNpc.second->loc.zone->getName(), - PNpc.second->getName())); + PNpc.second->loc.zone->getName(), + PNpc.second->getName())); } // Cache Instance script (TODO: This will be done multiple times, don't do that) diff --git a/src/map/item_container.cpp b/src/map/item_container.cpp index ad8f3c0bcbe..572ef1e1864 100644 --- a/src/map/item_container.cpp +++ b/src/map/item_container.cpp @@ -207,8 +207,7 @@ uint8 CItemContainer::SearchItemWithSpace(uint16 ItemID, uint32 quantity) { for (uint8 SlotID = 0; SlotID <= m_size; ++SlotID) { - if ((m_ItemList[SlotID] != nullptr) && (m_ItemList[SlotID]->getID() == ItemID) && - (m_ItemList[SlotID]->getQuantity() <= m_ItemList[SlotID]->getStackSize() - quantity)) + if ((m_ItemList[SlotID] != nullptr) && (m_ItemList[SlotID]->getID() == ItemID) && (m_ItemList[SlotID]->getQuantity() <= m_ItemList[SlotID]->getStackSize() - quantity)) { return SlotID; } diff --git a/src/map/items/item.cpp b/src/map/items/item.cpp index 1bda60b9be6..735b4c9ae1f 100644 --- a/src/map/items/item.cpp +++ b/src/map/items/item.cpp @@ -257,7 +257,7 @@ const std::string& CItem::getName() return m_name; } -void CItem::setName(std::string const& name) +void CItem::setName(const std::string& name) { m_name = name; } @@ -273,7 +273,7 @@ const std::string& CItem::getSender() return m_send; } -void CItem::setSender(std::string const& sender) +void CItem::setSender(const std::string& sender) { m_send = sender; } @@ -289,7 +289,7 @@ const std::string& CItem::getReceiver() return m_recv; } -void CItem::setReceiver(std::string const& receiver) +void CItem::setReceiver(const std::string& receiver) { m_recv = receiver; } @@ -308,7 +308,7 @@ const std::string CItem::getSignature() return signature; // return string copy } -void CItem::setSignature(std::string const& signature) +void CItem::setSignature(const std::string& signature) { memset(m_extra + 0x0C, 0, sizeof(m_extra) - 0x0C); memcpy(m_extra + 0x0C, signature.c_str(), signature.size()); @@ -378,7 +378,7 @@ bool CItem::isSoultrapper() const return m_id == 18721 || m_id == 18724; } -void CItem::setSoulPlateData(std::string const& name, uint16 mobFamily, uint8 zeni, uint16 skillIndex, uint8 fp) +void CItem::setSoulPlateData(const std::string& name, uint16 mobFamily, uint8 zeni, uint16 skillIndex, uint8 fp) { PackSoultrapperName(name, m_extra); diff --git a/src/map/items/item.h b/src/map/items/item.h index 376e08e3312..2001e4a427b 100644 --- a/src/map/items/item.h +++ b/src/map/items/item.h @@ -110,19 +110,19 @@ class CItem void setSent(bool sent); const std::string& getName(); - void setName(std::string const& name); + void setName(const std::string& name); const std::string& getSender(); - void setSender(std::string const& sender); + void setSender(const std::string& sender); const std::string& getReceiver(); - void setReceiver(std::string const& receiver); + void setReceiver(const std::string& receiver); virtual const std::string getSignature(); - virtual void setSignature(std::string const& signature); + virtual void setSignature(const std::string& signature); bool isSoultrapper() const; - void setSoulPlateData(std::string const& name, uint16 mobFamily, uint8 zeni, uint16 skillIndex, uint8 fp); + void setSoulPlateData(const std::string& name, uint16 mobFamily, uint8 zeni, uint16 skillIndex, uint8 fp); auto getSoulPlateData() -> std::tuple; bool isMannequin() const; diff --git a/src/map/items/item_furnishing.cpp b/src/map/items/item_furnishing.cpp index 7c37c209028..c948058f196 100644 --- a/src/map/items/item_furnishing.cpp +++ b/src/map/items/item_furnishing.cpp @@ -181,14 +181,14 @@ bool CItemFurnishing::getOn2ndFloor() bool CItemFurnishing::isGardeningPot() { auto id = CItem::getID(); - return id == 216 || // porcelain_flowerpot - id == 217 || // brass_flowerpot - id == 218 || // earthen_flowerpot - id == 219 || // ceramic_flowerpot - id == 220 || // wooden_flowerpot - id == 221 || // arcane_flowerpot - id == 3744 || // mandragora_pot - id == 3745 || // korrigan_pot - id == 3746 || // adenium_pot - id == 3747; // citrullus_pot + return id == 216 || // porcelain_flowerpot + id == 217 || // brass_flowerpot + id == 218 || // earthen_flowerpot + id == 219 || // ceramic_flowerpot + id == 220 || // wooden_flowerpot + id == 221 || // arcane_flowerpot + id == 3744 || // mandragora_pot + id == 3745 || // korrigan_pot + id == 3746 || // adenium_pot + id == 3747; // citrullus_pot } diff --git a/src/map/items/item_linkshell.cpp b/src/map/items/item_linkshell.cpp index 0bca481dc7a..928e4f39461 100644 --- a/src/map/items/item_linkshell.cpp +++ b/src/map/items/item_linkshell.cpp @@ -72,7 +72,7 @@ const std::string CItemLinkshell::getSignature() return signature; // return string copy } -void CItemLinkshell::setSignature(std::string const& signature) +void CItemLinkshell::setSignature(const std::string& signature) { memset(m_extra + 0x09, 0, sizeof(m_extra) - 0x09); memcpy(m_extra + 0x09, signature.c_str(), signature.size()); diff --git a/src/map/items/item_linkshell.h b/src/map/items/item_linkshell.h index 1a8995af91c..39f234e5382 100644 --- a/src/map/items/item_linkshell.h +++ b/src/map/items/item_linkshell.h @@ -56,7 +56,7 @@ class CItemLinkshell : public CItem void SetLSID(uint32 lsid); void SetLSColor(uint16 color); const std::string getSignature() override; - void setSignature(std::string const& signature) override; + void setSignature(const std::string& signature) override; void SetLSType(LSTYPE value); private: diff --git a/src/map/job_points.cpp b/src/map/job_points.cpp index 6f75911bfb9..c7dabc94c09 100644 --- a/src/map/job_points.cpp +++ b/src/map/job_points.cpp @@ -35,7 +35,8 @@ void CJobPoints::LoadJobPoints() _sql->Query("SELECT charid, jobid, capacity_points, job_points, job_points_spent, " "jptype0, jptype1, jptype2, jptype3, jptype4, jptype5, jptype6, jptype7, jptype8, jptype9 " "FROM char_job_points WHERE charid = %u ORDER BY jobid ASC", - m_PChar->id) != SQL_ERROR) + m_PChar->id) + != SQL_ERROR) { for (uint64 i = 0; i < _sql->NumRows(); i++) { @@ -67,9 +68,7 @@ void CJobPoints::LoadJobPoints() bool CJobPoints::IsJobPointExist(JOBPOINT_TYPE jpType) { - if ((static_cast(jpType) < JOBPOINTS_CATEGORY_START) || - (JobPointsCategoryIndexByJpType(jpType) - 1 > JOBPOINTS_CATEGORY_COUNT) || - (JobPointTypeIndex(jpType) > JOBPOINTS_JPTYPE_PER_CATEGORY)) + if ((static_cast(jpType) < JOBPOINTS_CATEGORY_START) || (JobPointsCategoryIndexByJpType(jpType) - 1 > JOBPOINTS_CATEGORY_COUNT) || (JobPointTypeIndex(jpType) > JOBPOINTS_JPTYPE_PER_CATEGORY)) { return false; } @@ -111,7 +110,7 @@ void CJobPoints::RaiseJobPoint(JOBPOINT_TYPE jpType) jobPoint->value++; _sql->Query("UPDATE char_job_points SET jptype%u='%u', job_points='%u', job_points_spent='%u' WHERE charid='%u' AND jobid='%u'", - JobPointTypeIndex(jobPoint->id), jobPoint->value, job->currentJp, job->totalJpSpent, m_PChar->id, job->jobId); + JobPointTypeIndex(jobPoint->id), jobPoint->value, job->currentJp, job->totalJpSpent, m_PChar->id, job->jobId); jobpointutils::RefreshGiftMods(m_PChar); } @@ -128,7 +127,7 @@ void CJobPoints::SetJobPoints(int16 amount) amount = std::clamp(amount, 0, 500); _sql->Query("INSERT INTO char_job_points SET charid='%u', jobid='%u', job_points='%u' ON DUPLICATE KEY UPDATE job_points='%u'", - m_PChar->id, currentJob, amount, amount); + m_PChar->id, currentJob, amount, amount); LoadJobPoints(); } @@ -187,7 +186,7 @@ void CJobPoints::SetCapacityPoints(uint16 amount) m_jobPoints[currentJob].capacityPoints = amount; _sql->Query("INSERT INTO char_job_points SET charid='%u', jobid='%u', capacity_points='%u' ON DUPLICATE KEY UPDATE capacity_points='%u'", - m_PChar->id, currentJob, amount, amount); + m_PChar->id, currentJob, amount, amount); } uint8 CJobPoints::GetJobPointValue(JOBPOINT_TYPE jpType) @@ -254,11 +253,11 @@ namespace jobpointutils if (totalJpSpent >= 100 && !charutils::hasSpell(PChar, (uint16)SpellID::Fire_VI)) { for (const SpellID elementalSpell : { SpellID::Fire_VI, - SpellID::Blizzard_VI, - SpellID::Aero_VI, - SpellID::Stone_VI, - SpellID::Thunder_VI, - SpellID::Water_VI }) + SpellID::Blizzard_VI, + SpellID::Aero_VI, + SpellID::Stone_VI, + SpellID::Thunder_VI, + SpellID::Water_VI }) { charutils::addSpell(PChar, (uint16)elementalSpell); charutils::SaveSpell(PChar, (uint16)elementalSpell); @@ -288,13 +287,13 @@ namespace jobpointutils if (totalJpSpent >= 100 && !charutils::hasSpell(PChar, (uint16)SpellID::Fire_Threnody_II)) { for (const SpellID threnodySpell : { SpellID::Fire_Threnody_II, - SpellID::Ice_Threnody_II, - SpellID::Wind_Threnody_II, - SpellID::Earth_Threnody_II, - SpellID::Lightning_Threnody_II, - SpellID::Water_Threnody_II, - SpellID::Light_Threnody_II, - SpellID::Dark_Threnody_II }) + SpellID::Ice_Threnody_II, + SpellID::Wind_Threnody_II, + SpellID::Earth_Threnody_II, + SpellID::Lightning_Threnody_II, + SpellID::Water_Threnody_II, + SpellID::Light_Threnody_II, + SpellID::Dark_Threnody_II }) { charutils::addSpell(PChar, (uint16)threnodySpell); charutils::SaveSpell(PChar, (uint16)threnodySpell); @@ -326,11 +325,11 @@ namespace jobpointutils if (totalJpSpent >= 100) { for (const SpellID elementalSpell : { SpellID::Fire_V, - SpellID::Blizzard_V, - SpellID::Aero_V, - SpellID::Stone_V, - SpellID::Thunder_V, - SpellID::Water_V }) + SpellID::Blizzard_V, + SpellID::Aero_V, + SpellID::Stone_V, + SpellID::Thunder_V, + SpellID::Water_V }) { uint16 spellIdNum = static_cast(elementalSpell); @@ -355,11 +354,11 @@ namespace jobpointutils if (totalJpSpent >= 1200 && !charutils::hasSpell(PChar, (uint16)SpellID::Fira_III)) { for (const SpellID elementalSpell : { SpellID::Fira_III, - SpellID::Blizzara_III, - SpellID::Aera_III, - SpellID::Stonera_III, - SpellID::Thundara_III, - SpellID::Watera_III }) + SpellID::Blizzara_III, + SpellID::Aera_III, + SpellID::Stonera_III, + SpellID::Thundara_III, + SpellID::Watera_III }) { charutils::addSpell(PChar, (uint16)elementalSpell); charutils::SaveSpell(PChar, (uint16)elementalSpell); @@ -393,11 +392,11 @@ namespace jobpointutils if (totalJpSpent >= 100) { for (const SpellID elementalSpell : { SpellID::Fire_V, - SpellID::Blizzard_V, - SpellID::Aero_V, - SpellID::Stone_V, - SpellID::Thunder_V, - SpellID::Water_V }) + SpellID::Blizzard_V, + SpellID::Aero_V, + SpellID::Stone_V, + SpellID::Thunder_V, + SpellID::Water_V }) { uint16 spellIdNum = static_cast(elementalSpell); @@ -414,8 +413,8 @@ namespace jobpointutils if (totalJpSpent >= 550 && !charutils::hasSpell(PChar, (uint16)SpellID::Addle_II)) { for (const SpellID enfeeblingSpell : { SpellID::Addle_II, - SpellID::Distract_III, - SpellID::Frazzle_III }) + SpellID::Distract_III, + SpellID::Frazzle_III }) { charutils::addSpell(PChar, (uint16)enfeeblingSpell); charutils::SaveSpell(PChar, (uint16)enfeeblingSpell); @@ -427,7 +426,7 @@ namespace jobpointutils if (totalJpSpent >= 1200 && !charutils::hasSpell(PChar, (uint16)SpellID::Refresh_III)) { for (const SpellID enfeeblingSpell : { SpellID::Refresh_III, - SpellID::Temper_II }) + SpellID::Temper_II }) { charutils::addSpell(PChar, (uint16)enfeeblingSpell); charutils::SaveSpell(PChar, (uint16)enfeeblingSpell); diff --git a/src/map/latent_effect.cpp b/src/map/latent_effect.cpp index 5c5e6f99e31..6d04d052670 100644 --- a/src/map/latent_effect.cpp +++ b/src/map/latent_effect.cpp @@ -106,16 +106,7 @@ void CLatentEffect::SetModPower(int16 power) bool CLatentEffect::ModOnItemOnly(Mod modID) { - if (modID == Mod::DMG_RATING || - modID == Mod::ITEM_ADDEFFECT_TYPE || - modID == Mod::ITEM_SUBEFFECT || - modID == Mod::ITEM_ADDEFFECT_DMG || - modID == Mod::ITEM_ADDEFFECT_CHANCE || - modID == Mod::ITEM_ADDEFFECT_ELEMENT || - modID == Mod::ITEM_ADDEFFECT_STATUS || - modID == Mod::ITEM_ADDEFFECT_POWER || - modID == Mod::ITEM_ADDEFFECT_DURATION || - modID == Mod::MOVE_SPEED_GEAR_BONUS) + if (modID == Mod::DMG_RATING || modID == Mod::ITEM_ADDEFFECT_TYPE || modID == Mod::ITEM_SUBEFFECT || modID == Mod::ITEM_ADDEFFECT_DMG || modID == Mod::ITEM_ADDEFFECT_CHANCE || modID == Mod::ITEM_ADDEFFECT_ELEMENT || modID == Mod::ITEM_ADDEFFECT_STATUS || modID == Mod::ITEM_ADDEFFECT_POWER || modID == Mod::ITEM_ADDEFFECT_DURATION || modID == Mod::MOVE_SPEED_GEAR_BONUS) { return true; } diff --git a/src/map/linkshell.cpp b/src/map/linkshell.cpp index adfdb910e89..54cf45077e3 100644 --- a/src/map/linkshell.cpp +++ b/src/map/linkshell.cpp @@ -87,7 +87,7 @@ void CLinkshell::setMessage(const std::string& message, const std::string& poste char sqlMessage[256]; _sql->EscapeString(sqlMessage, message.c_str()); _sql->Query("UPDATE linkshells SET poster = '%s', message = '%s', messagetime = %u WHERE linkshellid = %d", poster, sqlMessage, - static_cast(time(nullptr)), m_id); + static_cast(time(nullptr)), m_id); int8 packetData[8]{}; ref(packetData, 0) = m_id; @@ -95,7 +95,7 @@ void CLinkshell::setMessage(const std::string& message, const std::string& poste if (message.size() != 0) { message::send(MSG_CHAT_LINKSHELL, packetData, sizeof packetData, - new CLinkshellMessagePacket(poster, message, m_name, std::numeric_limits::min(), true)); + new CLinkshellMessagePacket(poster, message, m_name, std::numeric_limits::min(), true)); } } @@ -201,12 +201,12 @@ void CLinkshell::ChangeMemberRank(const std::string& MemberName, uint8 toSack) if (lsID == 1) { _sql->Query("UPDATE accounts_sessions SET linkshellid1 = %u , linkshellrank1 = %u WHERE charid = %u", m_id, - static_cast(PItemLinkshell->GetLSType()), PMember->id); + static_cast(PItemLinkshell->GetLSType()), PMember->id); } else if (lsID == 2) { _sql->Query("UPDATE accounts_sessions SET linkshellid2 = %u , linkshellrank2 = %u WHERE charid = %u", m_id, - static_cast(PItemLinkshell->GetLSType()), PMember->id); + static_cast(PItemLinkshell->GetLSType()), PMember->id); } PMember->pushPacket(new CInventoryAssignPacket(PItemLinkshell, INV_NORMAL)); @@ -464,7 +464,8 @@ namespace linkshell if (IsValidLinkshellName(name)) { if (_sql->Query("INSERT INTO linkshells (name, color, postrights) VALUES ('%s', %u, %u)", name, color, - static_cast(LSTYPE_PEARLSACK)) != SQL_ERROR) + static_cast(LSTYPE_PEARLSACK)) + != SQL_ERROR) { return LoadLinkshell((uint32)_sql->LastInsertId())->getID(); } diff --git a/src/map/los/common.h b/src/map/los/common.h index 5e25772e70a..c6929a33ec1 100644 --- a/src/map/los/common.h +++ b/src/map/los/common.h @@ -60,7 +60,7 @@ struct BoundingBox return (getAxisMax(axis) - axisMin) / 2 + axisMin; } - void expandTo(BoundingBox const& other) + void expandTo(const BoundingBox& other) { if (other.coords[0] < coords[0]) { @@ -98,12 +98,12 @@ struct Vector3D float z; // Addition - Vector3D operator+(Vector3D const& vec) + Vector3D operator+(const Vector3D& vec) { return Vector3D{ x + vec.x, y + vec.y, z + vec.z }; } - Vector3D& operator+=(Vector3D const& vec) + Vector3D& operator+=(const Vector3D& vec) { x += vec.x; y += vec.y; @@ -112,12 +112,12 @@ struct Vector3D } // Subtraction - Vector3D operator-(Vector3D const& vec) + Vector3D operator-(const Vector3D& vec) { return Vector3D{ x - vec.x, y - vec.y, z - vec.z }; } - Vector3D& operator-=(Vector3D const& vec) + Vector3D& operator-=(const Vector3D& vec) { x -= vec.x; y -= vec.y; @@ -154,7 +154,7 @@ struct Vector3D } // Misc other - Vector3D crossProduct(Vector3D const& other) const + Vector3D crossProduct(const Vector3D& other) const { float ni = y * other.z - z * other.y; float nj = z * other.x - x * other.z; @@ -162,7 +162,7 @@ struct Vector3D return Vector3D{ ni, nj, nk }; } - float dotProduct(Vector3D const& other) const + float dotProduct(const Vector3D& other) const { return x * other.x + y * other.y + z * other.z; } diff --git a/src/map/los/zone_los.cpp b/src/map/los/zone_los.cpp index 7ac1902cad1..c6866c7b6cc 100644 --- a/src/map/los/zone_los.cpp +++ b/src/map/los/zone_los.cpp @@ -44,7 +44,7 @@ ZoneLos::ZoneLos(Triangle* elements, int elementCount) { } -ZoneLos* ZoneLos::Load(uint16 zoneId, std::string const& pathToObj) +ZoneLos* ZoneLos::Load(uint16 zoneId, const std::string& pathToObj) { TracyZoneScoped; // Check if file exists before loading the OBJ model. @@ -122,7 +122,7 @@ bool ZoneLos::CanEntitySee(CBaseEntity* source, CBaseEntity* target) const return CanEntitySee(source, target->loc.p); } -bool ZoneLos::CanEntitySee(CBaseEntity* source, position_t const& targetPointBase) const +bool ZoneLos::CanEntitySee(CBaseEntity* source, const position_t& targetPointBase) const { TracyZoneScoped; return !DoesRayCollide({ source->loc.p.x, source->loc.p.y - ENTITY_HEIGHT, source->loc.p.z }, { targetPointBase.x, targetPointBase.y - ENTITY_HEIGHT, targetPointBase.z }); @@ -134,7 +134,7 @@ std::optional ZoneLos::Raycast(CBaseEntity* source, CBaseEntity* targe return Raycast(source->loc.p, target->loc.p); } -std::optional ZoneLos::Raycast(position_t const& source, position_t const& target) const +std::optional ZoneLos::Raycast(const position_t& source, const position_t& target) const { TracyZoneScoped; return DoesRayCollide({ source.x, source.y, source.z }, { target.x, target.y, target.z }); diff --git a/src/map/los/zone_los.h b/src/map/los/zone_los.h index 8b4b73a8448..78c83a8691d 100644 --- a/src/map/los/zone_los.h +++ b/src/map/los/zone_los.h @@ -30,13 +30,13 @@ class CBaseEntity; class ZoneLos { public: - static ZoneLos* Load(uint16 zoneId, std::string const& pathToObj); + static ZoneLos* Load(uint16 zoneId, const std::string& pathToObj); bool CanEntitySee(CBaseEntity* source, CBaseEntity* target) const; - bool CanEntitySee(CBaseEntity* source, position_t const& targetPointBase) const; + bool CanEntitySee(CBaseEntity* source, const position_t& targetPointBase) const; std::optional Raycast(CBaseEntity* source, CBaseEntity* target) const; - std::optional Raycast(position_t const& source, position_t const& target) const; + std::optional Raycast(const position_t& source, const position_t& target) const; private: ZoneLos(Triangle* elements, int elementCount); diff --git a/src/map/lua/lua_baseentity.cpp b/src/map/lua/lua_baseentity.cpp index cf82b95587a..1ac861de1b7 100644 --- a/src/map/lua/lua_baseentity.cpp +++ b/src/map/lua/lua_baseentity.cpp @@ -186,7 +186,7 @@ CLuaBaseEntity::CLuaBaseEntity(CBaseEntity* PEntity) * Notes : Mainly used for showing retail text specific to an NPC ************************************************************************/ -void CLuaBaseEntity::showText(CLuaBaseEntity* mob, uint16 messageID, sol::object const& p0, sol::object const& p1, sol::object const& p2, sol::object const& p3) +void CLuaBaseEntity::showText(CLuaBaseEntity* mob, uint16 messageID, const sol::object& p0, const sol::object& p1, const sol::object& p2, const sol::object& p3) { CBaseEntity* PBaseEntity = mob->GetBaseEntity(); @@ -220,7 +220,7 @@ void CLuaBaseEntity::showText(CLuaBaseEntity* mob, uint16 messageID, sol::object * Notes : Mainly used for sending retail text messages ************************************************************************/ -void CLuaBaseEntity::messageText(CLuaBaseEntity* PLuaBaseEntity, uint16 messageID, sol::object const& arg2, sol::object const& arg3) +void CLuaBaseEntity::messageText(CLuaBaseEntity* PLuaBaseEntity, uint16 messageID, const sol::object& arg2, const sol::object& arg3) { if (PLuaBaseEntity == nullptr) { @@ -302,7 +302,7 @@ void CLuaBaseEntity::messageText(CLuaBaseEntity* PLuaBaseEntity, uint16 messageI * : Can modify the name shown through explicit declaration ************************************************************************/ -void CLuaBaseEntity::printToPlayer(std::string const& message, sol::object const& messageTypeObj, sol::object const& nameObj) +void CLuaBaseEntity::printToPlayer(const std::string& message, const sol::object& messageTypeObj, const sol::object& nameObj) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -326,7 +326,7 @@ void CLuaBaseEntity::printToPlayer(std::string const& message, sol::object const * : would print a shout type message from Pinocchio to the entire server ************************************************************************/ -void CLuaBaseEntity::printToArea(std::string const& message, sol::object const& arg1, sol::object const& arg2, sol::object const& arg3) +void CLuaBaseEntity::printToArea(const std::string& message, const sol::object& arg1, const sol::object& arg2, const sol::object& arg3) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -397,7 +397,7 @@ void CLuaBaseEntity::printToArea(std::string const& message, sol::object const& * Notes : Mainly used when effects are applied ************************************************************************/ -void CLuaBaseEntity::messageBasic(uint16 messageID, sol::object const& p0, sol::object const& p1, sol::object const& target) +void CLuaBaseEntity::messageBasic(uint16 messageID, const sol::object& p0, const sol::object& p1, const sol::object& target) { uint32 param0 = (p0 != sol::lua_nil) ? p0.as() : 0; uint32 param1 = (p1 != sol::lua_nil) ? p1.as() : 0; @@ -422,8 +422,8 @@ void CLuaBaseEntity::messageBasic(uint16 messageID, sol::object const& p0, sol:: * Notes : Used in Doom countdown messages, as an example ************************************************************************/ -void CLuaBaseEntity::messageName(uint16 messageID, sol::object const& entity, sol::object const& p0, sol::object const& p1, - sol::object const& p2, sol::object const& p3, sol::object const& chat) +void CLuaBaseEntity::messageName(uint16 messageID, const sol::object& entity, const sol::object& p0, const sol::object& p1, + const sol::object& p2, const sol::object& p3, const sol::object& chat) { CLuaBaseEntity* PLuaEntity = (entity != sol::lua_nil) ? entity.as() : nullptr; CBaseEntity* PNameEntity = PLuaEntity ? PLuaEntity->m_PBaseEntity : nullptr; @@ -442,7 +442,7 @@ void CLuaBaseEntity::messageName(uint16 messageID, sol::object const& entity, so else { m_PBaseEntity->loc.zone->PushPacket(m_PBaseEntity, CHAR_INRANGE, - new CMessageNamePacket(m_PBaseEntity, messageID, PNameEntity, param0, param1, param2, param3, chatType)); + new CMessageNamePacket(m_PBaseEntity, messageID, PNameEntity, param0, param1, param2, param3, chatType)); } } @@ -453,7 +453,7 @@ void CLuaBaseEntity::messageName(uint16 messageID, sol::object const& entity, so * Notes : Used in Doom countdown messages, as an example ************************************************************************/ -void CLuaBaseEntity::messagePublic(uint16 messageID, CLuaBaseEntity const* PEntity, sol::object const& arg2, sol::object const& arg3) +void CLuaBaseEntity::messagePublic(uint16 messageID, const CLuaBaseEntity* PEntity, const sol::object& arg2, const sol::object& arg3) { uint32 param0 = (arg2 != sol::lua_nil) ? arg2.as() : 0; uint32 param1 = (arg3 != sol::lua_nil) ? arg3.as() : 0; @@ -461,7 +461,7 @@ void CLuaBaseEntity::messagePublic(uint16 messageID, CLuaBaseEntity const* PEnti if (PEntity != nullptr) { m_PBaseEntity->loc.zone->PushPacket(m_PBaseEntity, CHAR_INRANGE_SELF, - new CMessageBasicPacket(m_PBaseEntity, PEntity->GetBaseEntity(), param0, param1, messageID)); + new CMessageBasicPacket(m_PBaseEntity, PEntity->GetBaseEntity(), param0, param1, messageID)); } } @@ -496,7 +496,7 @@ void CLuaBaseEntity::messageSpecial(uint16 messageID, sol::variadic_args va) * Notes : ************************************************************************/ -void CLuaBaseEntity::messageSystem(MsgStd messageID, sol::object const& p0, sol::object const& p1) +void CLuaBaseEntity::messageSystem(MsgStd messageID, const sol::object& p0, const sol::object& p1) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -516,7 +516,7 @@ void CLuaBaseEntity::messageSystem(MsgStd messageID, sol::object const& p0, sol: * Example : master:messageCombat(mob, offset + id, 0, 711) * Notes : ************************************************************************/ -void CLuaBaseEntity::messageCombat(sol::object const& speaker, int32 p0, int32 p1, int16 message) +void CLuaBaseEntity::messageCombat(const sol::object& speaker, int32 p0, int32 p1, int16 message) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -555,7 +555,7 @@ void CLuaBaseEntity::messageStandard(uint16 messageID) } } -void CLuaBaseEntity::customMenu(sol::object const& obj) +void CLuaBaseEntity::customMenu(const sol::object& obj) { if (auto* PChar = dynamic_cast(m_PBaseEntity); PChar && obj.get_type() == sol::type::table) @@ -572,7 +572,7 @@ void CLuaBaseEntity::customMenu(sol::object const& obj) * Notes : ************************************************************************/ -int32 CLuaBaseEntity::getCharVar(std::string const& varName) +int32 CLuaBaseEntity::getCharVar(const std::string& varName) { if (auto* PChar = dynamic_cast(m_PBaseEntity)) { @@ -588,7 +588,7 @@ int32 CLuaBaseEntity::getCharVar(std::string const& varName) * Notes : Passing a '0' value will delete the variable. ************************************************************************/ -void CLuaBaseEntity::setCharVar(std::string const& varName, int32 value, sol::object const& expiry) +void CLuaBaseEntity::setCharVar(const std::string& varName, int32 value, const sol::object& expiry) { if (auto* PChar = dynamic_cast(m_PBaseEntity)) { @@ -611,7 +611,7 @@ void CLuaBaseEntity::setCharVar(std::string const& varName, int32 value, sol::ob * Notes : Passing a '0' value will set the variable to not expire. ************************************************************************/ -void CLuaBaseEntity::setCharVarExpiration(std::string const& varName, uint32 expiry) +void CLuaBaseEntity::setCharVarExpiration(const std::string& varName, uint32 expiry) { if (auto* PChar = dynamic_cast(m_PBaseEntity)) { @@ -633,7 +633,7 @@ void CLuaBaseEntity::setCharVarExpiration(std::string const& varName, uint32 exp * not handle expiration times. ************************************************************************/ -void CLuaBaseEntity::incrementCharVar(std::string const& varName, int32 value) +void CLuaBaseEntity::incrementCharVar(const std::string& varName, int32 value) { if (auto* PChar = dynamic_cast(m_PBaseEntity)) { @@ -649,7 +649,7 @@ void CLuaBaseEntity::incrementCharVar(std::string const& varName, int32 value) * Notes : Passing a '0' value will delete the variable ************************************************************************/ -void CLuaBaseEntity::setVolatileCharVar(std::string const& varName, int32 value, sol::object const& expiry) +void CLuaBaseEntity::setVolatileCharVar(const std::string& varName, int32 value, const sol::object& expiry) { if (auto* PChar = dynamic_cast(m_PBaseEntity)) { @@ -677,7 +677,7 @@ auto CLuaBaseEntity::getLocalVars() -> sol::table auto table = lua.create_table(); auto& localVars = m_PBaseEntity->GetLocalVars(); - for (auto const& [varName, value] : localVars) + for (const auto& [varName, value] : localVars) { auto subtable = lua.create_table(); subtable["varname"] = varName; @@ -694,7 +694,7 @@ auto CLuaBaseEntity::getLocalVars() -> sol::table * Notes : ************************************************************************/ -uint32 CLuaBaseEntity::getLocalVar(std::string const& var) +uint32 CLuaBaseEntity::getLocalVar(const std::string& var) { return m_PBaseEntity->GetLocalVar(var.c_str()); } @@ -706,7 +706,7 @@ uint32 CLuaBaseEntity::getLocalVar(std::string const& var) * Notes : ************************************************************************/ -void CLuaBaseEntity::setLocalVar(std::string const& var, uint32 val) +void CLuaBaseEntity::setLocalVar(const std::string& var, uint32 val) { m_PBaseEntity->SetLocalVar(var.c_str(), val); } @@ -730,7 +730,7 @@ void CLuaBaseEntity::resetLocalVars() * Notes : Prefix has to be a certain length, to avoid deleting unrelated variables. ************************************************************************/ -void CLuaBaseEntity::clearVarsWithPrefix(std::string const& prefix) +void CLuaBaseEntity::clearVarsWithPrefix(const std::string& prefix) { if (auto player = dynamic_cast(m_PBaseEntity)) { @@ -772,7 +772,7 @@ uint32 CLuaBaseEntity::getLastOnline() * Notes : Used only for testing through inject.lua command ************************************************************************/ -void CLuaBaseEntity::injectPacket(std::string const& filename) +void CLuaBaseEntity::injectPacket(const std::string& filename) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -851,7 +851,7 @@ void CLuaBaseEntity::injectActionPacket(uint32 inTargetID, uint16 inCategory, ui * Notes : ************************************************************************/ -void CLuaBaseEntity::entityVisualPacket(std::string const& command, sol::object const& entity) +void CLuaBaseEntity::entityVisualPacket(const std::string& command, const sol::object& entity) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -876,7 +876,7 @@ void CLuaBaseEntity::entityVisualPacket(std::string const& command, sol::object * Notes : ************************************************************************/ -void CLuaBaseEntity::entityAnimationPacket(const char* command, sol::object const& target) +void CLuaBaseEntity::entityAnimationPacket(const char* command, const sol::object& target) { CBaseEntity* PTarget = nullptr; if (target != sol::lua_nil) @@ -907,7 +907,7 @@ void CLuaBaseEntity::entityAnimationPacket(const char* command, sol::object cons * Example : mob:sendDebugPacket({ table }) * Notes : For debugging and development only! ************************************************************************/ -void CLuaBaseEntity::sendDebugPacket(sol::table const& packetData) +void CLuaBaseEntity::sendDebugPacket(const sol::table& packetData) { if (auto* PChar = dynamic_cast(m_PBaseEntity)) { @@ -1363,7 +1363,7 @@ void CLuaBaseEntity::setMoghouseFlag(uint16 flag) * TODO : Separate this into get/set functions ************************************************************************/ -bool CLuaBaseEntity::needToZone(sol::object const& arg0) +bool CLuaBaseEntity::needToZone(const sol::object& arg0) { if (arg0 != sol::lua_nil) { @@ -1654,15 +1654,7 @@ bool CLuaBaseEntity::canUseAbilities() { if (auto* PEntity = static_cast(m_PBaseEntity)) { - return !(PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_SLEEP) || - PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_IMPAIRMENT) || - PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_SLEEP_II) || - PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_STUN) || - PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_AMNESIA) || - PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_LULLABY) || - PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_PETRIFICATION) || - PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_TERROR) || - !(m_PBaseEntity->PAI->CanChangeState())); + return !(PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_SLEEP) || PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_IMPAIRMENT) || PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_SLEEP_II) || PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_STUN) || PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_AMNESIA) || PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_LULLABY) || PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_PETRIFICATION) || PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_TERROR) || !(m_PBaseEntity->PAI->CanChangeState())); } ShowError("canUseAbilities() : Wrong Entity Type"); @@ -1676,7 +1668,7 @@ bool CLuaBaseEntity::canUseAbilities() * Notes : Expects x, y, and z and does not confirm missing! ************************************************************************/ -void CLuaBaseEntity::lookAt(sol::object const& arg0, sol::object const& arg1, sol::object const& arg2) +void CLuaBaseEntity::lookAt(const sol::object& arg0, const sol::object& arg1, const sol::object& arg2) { position_t point; @@ -1711,7 +1703,7 @@ void CLuaBaseEntity::lookAt(sol::object const& arg0, sol::object const& arg1, so * Bool set "false" changes the facing for everyone. ************************************************************************/ -void CLuaBaseEntity::facePlayer(CLuaBaseEntity* PLuaBaseEntity, sol::object const& nonGlobal) +void CLuaBaseEntity::facePlayer(CLuaBaseEntity* PLuaBaseEntity, const sol::object& nonGlobal) { CCharEntity* PChar = static_cast(PLuaBaseEntity->GetBaseEntity()); @@ -1791,7 +1783,7 @@ bool CLuaBaseEntity::atPoint(sol::variadic_args va) * Notes : Currently only used by Selh'Teus during final CoP fight ************************************************************************/ -void CLuaBaseEntity::pathTo(float x, float y, float z, sol::object const& flags) +void CLuaBaseEntity::pathTo(float x, float y, float z, const sol::object& flags) { if (m_PBaseEntity->objtype == TYPE_PC) { @@ -1819,7 +1811,7 @@ void CLuaBaseEntity::pathTo(float x, float y, float z, sol::object const& flags) * Notes : Ex: Gets Zipacna back on his specified path ************************************************************************/ -bool CLuaBaseEntity::pathThrough(sol::table const& pointsTable, sol::object const& flagsObj) +bool CLuaBaseEntity::pathThrough(const sol::table& pointsTable, const sol::object& flagsObj) { uint8 flags = 0; @@ -1892,7 +1884,7 @@ bool CLuaBaseEntity::isFollowingPath() * Notes : Optional argument to stop AI onPath ticks for an NPC ************************************************************************/ -void CLuaBaseEntity::clearPath(sol::object const& pauseObj) +void CLuaBaseEntity::clearPath(const sol::object& pauseObj) { auto* PBattle = static_cast(m_PBaseEntity); bool pause = pauseObj.is() ? pauseObj.as() : false; @@ -1956,9 +1948,7 @@ float CLuaBaseEntity::checkDistance(sol::variadic_args va) posY = table.get("y"); posZ = table.get("z"); } - else if (va.get_type(0) == sol::type::number && - va.get_type(1) == sol::type::number && - va.get_type(2) == sol::type::number) + else if (va.get_type(0) == sol::type::number && va.get_type(1) == sol::type::number && va.get_type(2) == sol::type::number) { posX = va.get(0); posY = va.get(1); @@ -1986,7 +1976,7 @@ float CLuaBaseEntity::checkDistance(sol::variadic_args va) * Notes : Default is 4 seconds unless specified in ms ************************************************************************/ -void CLuaBaseEntity::wait(sol::object const& milliseconds) +void CLuaBaseEntity::wait(const sol::object& milliseconds) { if (m_PBaseEntity->objtype == TYPE_PC) { @@ -2059,7 +2049,7 @@ void CLuaBaseEntity::setCarefulPathing(bool careful) * Example : npc:openDoor(30) -- Open for 30 sec; npc:openDoor() -- 7 sec ************************************************************************/ -void CLuaBaseEntity::openDoor(sol::object const& seconds) +void CLuaBaseEntity::openDoor(const sol::object& seconds) { if (m_PBaseEntity->objtype != TYPE_NPC) { @@ -2091,7 +2081,7 @@ void CLuaBaseEntity::openDoor(sol::object const& seconds) * Example : npc:closeDoor(); GetNPCByID(ID.npc.LANTERN):closeDoor(1) ************************************************************************/ -void CLuaBaseEntity::closeDoor(sol::object const& seconds) +void CLuaBaseEntity::closeDoor(const sol::object& seconds) { if (m_PBaseEntity->objtype != TYPE_NPC) { @@ -2204,7 +2194,7 @@ void CLuaBaseEntity::addPeriodicTrigger(uint8 id, uint16 period, uint16 minOffse * Notes : Default is 15 seconds ************************************************************************/ -void CLuaBaseEntity::showNPC(sol::object const& seconds) +void CLuaBaseEntity::showNPC(const sol::object& seconds) { if (m_PBaseEntity->objtype != TYPE_NPC) { @@ -2233,7 +2223,7 @@ void CLuaBaseEntity::showNPC(sol::object const& seconds) * Notes : Default is 15 seconds ************************************************************************/ -void CLuaBaseEntity::hideNPC(sol::object const& seconds) +void CLuaBaseEntity::hideNPC(const sol::object& seconds) { if (m_PBaseEntity->objtype != TYPE_NPC) { @@ -2265,7 +2255,7 @@ void CLuaBaseEntity::hideNPC(sol::object const& seconds) * Notes : Default is 15 seconds ************************************************************************/ -void CLuaBaseEntity::updateNPCHideTime(sol::object const& seconds) +void CLuaBaseEntity::updateNPCHideTime(const sol::object& seconds) { if (m_PBaseEntity->objtype != TYPE_NPC) { @@ -2293,7 +2283,7 @@ void CLuaBaseEntity::updateNPCHideTime(sol::object const& seconds) * Example : if player:getWeather() == xi.weather.WIND then ************************************************************************/ -uint8 CLuaBaseEntity::getWeather(sol::object const& ignoreScholar) +uint8 CLuaBaseEntity::getWeather(const sol::object& ignoreScholar) { WEATHER weather = WEATHER_NONE; @@ -2494,7 +2484,7 @@ void CLuaBaseEntity::sendEmote(CLuaBaseEntity* target, uint8 emID, uint8 emMode) const auto emoteMode = static_cast(emMode); PChar->loc.zone->PushPacket(PChar, CHAR_INRANGE, - new CCharEmotionPacket(PChar, PTarget->id, PTarget->targid, emoteID, emoteMode, 0)); + new CCharEmotionPacket(PChar, PTarget->id, PTarget->targid, emoteID, emoteMode, 0)); } } } @@ -2557,7 +2547,7 @@ int16 CLuaBaseEntity::getWorldAngle(sol::variadic_args va) * CAREFUL! If the entities are too close, this can return unexpected results. ************************************************************************/ -int16 CLuaBaseEntity::getFacingAngle(CLuaBaseEntity const* target) +int16 CLuaBaseEntity::getFacingAngle(const CLuaBaseEntity* target) { return facingAngle(m_PBaseEntity->loc.p, target->GetBaseEntity()->loc.p); } @@ -2569,7 +2559,7 @@ int16 CLuaBaseEntity::getFacingAngle(CLuaBaseEntity const* target) * Notes : Can specify angle for wider/narrower ranges ************************************************************************/ -bool CLuaBaseEntity::isFacing(CLuaBaseEntity const* target, sol::object const& angleArg) +bool CLuaBaseEntity::isFacing(const CLuaBaseEntity* target, const sol::object& angleArg) { uint8 angle = (angleArg != sol::lua_nil) ? angleArg.as() : 64; @@ -2583,7 +2573,7 @@ bool CLuaBaseEntity::isFacing(CLuaBaseEntity const* target, sol::object const& a * Notes : Can specify angle for wider/narrower ranges ************************************************************************/ -bool CLuaBaseEntity::isInfront(CLuaBaseEntity const* target, sol::object const& angleArg) +bool CLuaBaseEntity::isInfront(const CLuaBaseEntity* target, const sol::object& angleArg) { uint8 angle = (angleArg != sol::lua_nil) ? angleArg.as() : 64; @@ -2597,7 +2587,7 @@ bool CLuaBaseEntity::isInfront(CLuaBaseEntity const* target, sol::object const& * Notes : Can specify angle for wider/narrower ranges ************************************************************************/ -bool CLuaBaseEntity::isBehind(CLuaBaseEntity const* target, sol::object const& angleArg) +bool CLuaBaseEntity::isBehind(const CLuaBaseEntity* target, const sol::object& angleArg) { uint8 angle = (angleArg != sol::lua_nil) ? angleArg.as() : 64; @@ -2611,7 +2601,7 @@ bool CLuaBaseEntity::isBehind(CLuaBaseEntity const* target, sol::object const& a * Notes : Can specify angle for wider/narrower ranges ************************************************************************/ -bool CLuaBaseEntity::isBeside(CLuaBaseEntity const* target, sol::object const& angleArg) +bool CLuaBaseEntity::isBeside(const CLuaBaseEntity* target, const sol::object& angleArg) { uint8 angle = (angleArg != sol::lua_nil) ? angleArg.as() : 64; @@ -2627,7 +2617,7 @@ bool CLuaBaseEntity::isBeside(CLuaBaseEntity const* target, sol::object const& a * they are in the process of zoning (for use in onZoneIn) ************************************************************************/ -std::optional CLuaBaseEntity::getZone(sol::object const& arg0) +std::optional CLuaBaseEntity::getZone(const sol::object& arg0) { if (m_PBaseEntity->loc.zone) { @@ -2770,7 +2760,7 @@ uint32 CLuaBaseEntity::getPlayerTriggerAreaInZone() * Notes : Currently only used for port bastok drawbridge as setAnimation() only updates for chars in range. ************************************************************************/ -void CLuaBaseEntity::updateToEntireZone(uint8 statusID, uint8 animation, sol::object const& matchTime) +void CLuaBaseEntity::updateToEntireZone(uint8 statusID, uint8 animation, const sol::object& matchTime) { if (m_PBaseEntity->objtype != TYPE_NPC) { @@ -2873,7 +2863,7 @@ void CLuaBaseEntity::showPosition() // TODO: Fix c-style cast static_cast(m_PBaseEntity) ->pushPacket(new CMessageStandardPacket((int32)m_PBaseEntity->loc.p.x, (int32)m_PBaseEntity->loc.p.y, (int32)m_PBaseEntity->loc.p.z, - m_PBaseEntity->loc.p.rotation, MsgStd::Compass)); + m_PBaseEntity->loc.p.rotation, MsgStd::Compass)); } /************************************************************************ @@ -3064,7 +3054,7 @@ void CLuaBaseEntity::warp() * Notes : scripts/globals/mobskills/tarutaru_warp_ii.lua ************************************************************************/ -void CLuaBaseEntity::teleport(std::map pos, sol::object const& arg1) +void CLuaBaseEntity::teleport(std::map pos, const sol::object& arg1) { m_PBaseEntity->loc.p.x = pos["x"]; m_PBaseEntity->loc.p.y = pos["y"]; @@ -3091,7 +3081,7 @@ void CLuaBaseEntity::teleport(std::map pos, sol::object cons * Notes : Param 2 is bits to shift, not exponentiated value ************************************************************************/ -void CLuaBaseEntity::addTeleport(uint8 teleType, uint32 bitval, sol::object const& setval) +void CLuaBaseEntity::addTeleport(uint8 teleType, uint32 bitval, const sol::object& setval) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -3175,7 +3165,7 @@ void CLuaBaseEntity::addTeleport(uint8 teleType, uint32 bitval, sol::object cons * Notes : ************************************************************************/ -uint32 CLuaBaseEntity::getTeleport(uint8 type, sol::object const& abysseaRegionObj) +uint32 CLuaBaseEntity::getTeleport(uint8 type, const sol::object& abysseaRegionObj) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -3282,7 +3272,7 @@ sol::table CLuaBaseEntity::getTeleportTable(uint8 type) * Notes : Refactor this to reduce the amount of returns ************************************************************************/ -bool CLuaBaseEntity::hasTeleport(uint8 tType, uint8 bit, sol::object const& arg2) +bool CLuaBaseEntity::hasTeleport(uint8 tType, uint8 bit, const sol::object& arg2) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -3369,7 +3359,7 @@ bool CLuaBaseEntity::hasTeleport(uint8 tType, uint8 bit, sol::object const& arg2 * Notes : ************************************************************************/ -void CLuaBaseEntity::setTeleportMenu(uint16 type, sol::object const& teleportObj) +void CLuaBaseEntity::setTeleportMenu(uint16 type, const sol::object& teleportObj) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -3512,7 +3502,7 @@ void CLuaBaseEntity::setHomePoint() WHERE charid = %u"; _sql->Query(fmtQuery, PChar->profile.home_point.destination, PChar->profile.home_point.p.rotation, PChar->profile.home_point.p.x, - PChar->profile.home_point.p.y, PChar->profile.home_point.p.z, PChar->id); + PChar->profile.home_point.p.y, PChar->profile.home_point.p.z, PChar->id); } /************************************************************************ @@ -3562,15 +3552,15 @@ void CLuaBaseEntity::resetPlayer(const char* charName) "WHERE charid = %u"; _sql->Query(Query, - 245, // lower jeuno - 122, // prev zone - 86, // rotation - 33.464f, // x - -5.000f, // y - 69.162f, // z - 0, // boundary, - 0, // moghouse, - id); + 245, // lower jeuno + 122, // prev zone + 86, // rotation + 33.464f, // x + -5.000f, // y + 69.162f, // z + 0, // boundary, + 0, // moghouse, + id); ShowDebug("Player reset was successful."); } @@ -3582,7 +3572,7 @@ void CLuaBaseEntity::resetPlayer(const char* charName) * Notes : Option 0: Spawned/Unspawned | Option 1: Spawned only ************************************************************************/ -void CLuaBaseEntity::goToEntity(uint32 targetID, sol::object const& option) +void CLuaBaseEntity::goToEntity(uint32 targetID, const sol::object& option) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -3617,7 +3607,7 @@ void CLuaBaseEntity::goToEntity(uint32 targetID, sol::object const& option) * Example : player:gotoPlayer(playername) ************************************************************************/ -bool CLuaBaseEntity::gotoPlayer(std::string const& playerName) +bool CLuaBaseEntity::gotoPlayer(const std::string& playerName) { bool found = false; @@ -3649,7 +3639,7 @@ bool CLuaBaseEntity::gotoPlayer(std::string const& playerName) * Notes : ************************************************************************/ -bool CLuaBaseEntity::bringPlayer(std::string const& playerName) +bool CLuaBaseEntity::bringPlayer(const std::string& playerName) { bool found = false; @@ -3749,7 +3739,7 @@ std::optional CLuaBaseEntity::getEquippedItem(uint8 slot) * Notes : Send with an L2 value to specify container ************************************************************************/ -bool CLuaBaseEntity::hasItem(uint16 itemID, sol::object const& location) +bool CLuaBaseEntity::hasItem(uint16 itemID, const sol::object& location) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -3874,7 +3864,7 @@ bool CLuaBaseEntity::addItem(sol::variadic_args va) if (augmentsObj.is()) { auto augmentsTable = augmentsObj.as(); - for (auto const& entryPair : augmentsTable) + for (const auto& entryPair : augmentsTable) { auto pair = entryPair.second.as(); uint16 augid = pair[0]; @@ -3888,7 +3878,7 @@ bool CLuaBaseEntity::addItem(sol::variadic_args va) if (exdataObj.is()) { auto exdataTable = exdataObj.as(); - for (auto const& entryPair : exdataTable) + for (const auto& entryPair : exdataTable) { uint8 index = entryPair.first.as(); uint8 value = entryPair.second.as(); @@ -4010,7 +4000,7 @@ bool CLuaBaseEntity::addItem(sol::variadic_args va) * Notes : Can specify container using third variable ************************************************************************/ -bool CLuaBaseEntity::delItem(uint16 itemID, int32 quantity, sol::object const& containerID) +bool CLuaBaseEntity::delItem(uint16 itemID, int32 quantity, const sol::object& containerID) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -4046,7 +4036,7 @@ bool CLuaBaseEntity::delItem(uint16 itemID, int32 quantity, sol::object const& c * Notes : Used in delinventory command ************************************************************************/ -bool CLuaBaseEntity::delContainerItems(sol::object const& containerID) +bool CLuaBaseEntity::delContainerItems(const sol::object& containerID) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -4201,7 +4191,7 @@ uint8 CLuaBaseEntity::incrementItemWear(uint16 itemID) * Notes : Used almost exclusively for instances ************************************************************************/ -bool CLuaBaseEntity::addTempItem(uint16 itemID, sol::object const& arg1) +bool CLuaBaseEntity::addTempItem(uint16 itemID, const sol::object& arg1) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -4239,7 +4229,7 @@ bool CLuaBaseEntity::addTempItem(uint16 itemID, sol::object const& arg1) * Example : local item = player:findItem(426) -- Orchestrion * Notes : ************************************************************************/ -std::optional CLuaBaseEntity::findItem(uint16 itemID, sol::object const& location) +std::optional CLuaBaseEntity::findItem(uint16 itemID, const sol::object& location) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -4288,7 +4278,7 @@ std::optional CLuaBaseEntity::findItem(uint16 itemID, sol::object cons * Notes : Used solely in scripts/globals/shop.lua ************************************************************************/ -void CLuaBaseEntity::createShop(uint8 size, sol::object const& arg1) +void CLuaBaseEntity::createShop(uint8 size, const sol::object& arg1) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -4316,7 +4306,7 @@ void CLuaBaseEntity::createShop(uint8 size, sol::object const& arg1) * Notes : Use with createShop() - 16 Max Items in Shop ************************************************************************/ -void CLuaBaseEntity::addShopItem(uint16 itemID, double rawPrice, sol::object const& arg2, sol::object const& arg3) +void CLuaBaseEntity::addShopItem(uint16 itemID, double rawPrice, const sol::object& arg2, const sol::object& arg3) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -4374,7 +4364,7 @@ auto CLuaBaseEntity::getCurrentGPItem(uint8 guildID) -> std::tupleobjtype != TYPE_PC) { @@ -4460,7 +4450,7 @@ bool CLuaBaseEntity::addLinkpearl(std::string const& lsname, bool equip) return false; } -auto CLuaBaseEntity::addSoulPlate(std::string const& name, uint16 mobFamily, uint8 zeni, uint16 skillIndex, uint8 fp) -> std::optional +auto CLuaBaseEntity::addSoulPlate(const std::string& name, uint16 mobFamily, uint8 zeni, uint16 skillIndex, uint8 fp) -> std::optional { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -4551,7 +4541,7 @@ void CLuaBaseEntity::changeContainerSize(uint8 locationID, int8 newSize) * Notes : Default slot is inventory; add value to specify containers ************************************************************************/ -uint8 CLuaBaseEntity::getFreeSlotsCount(sol::object const& locID) +uint8 CLuaBaseEntity::getFreeSlotsCount(const sol::object& locID) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -4656,7 +4646,7 @@ std::optional CLuaBaseEntity::getTrade() * Notes : CItemEquipment* is a pointer to weapons or armor ************************************************************************/ -bool CLuaBaseEntity::canEquipItem(uint16 itemID, sol::object const& chkLevel) +bool CLuaBaseEntity::canEquipItem(uint16 itemID, const sol::object& chkLevel) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -4708,7 +4698,7 @@ bool CLuaBaseEntity::canEquipItem(uint16 itemID, sol::object const& chkLevel) * Notes : ************************************************************************/ -void CLuaBaseEntity::equipItem(uint16 itemID, sol::object const& container) +void CLuaBaseEntity::equipItem(uint16 itemID, const sol::object& container) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -4982,7 +4972,7 @@ std::optional CLuaBaseEntity::getStorageItem(uint8 container, uint8 sl * Notes : Sets an 'extra' value so item doesn't appear in inventory ************************************************************************/ -uint8 CLuaBaseEntity::storeWithPorterMoogle(uint16 slipId, sol::table const& extraTable, sol::table const& storableItemIdsTable) +uint8 CLuaBaseEntity::storeWithPorterMoogle(uint16 slipId, const sol::table& extraTable, const sol::table& storableItemIdsTable) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -5035,7 +5025,7 @@ uint8 CLuaBaseEntity::storeWithPorterMoogle(uint16 slipId, sol::table const& ext } } - for (auto const& itemId : storedItemIds) + for (const auto& itemId : storedItemIds) { if (itemId != 0) { @@ -5227,7 +5217,7 @@ std::string CLuaBaseEntity::getPacketName() * : your choosing. ************************************************************************/ -void CLuaBaseEntity::renameEntity(std::string const& newName, sol::object const& arg2) +void CLuaBaseEntity::renameEntity(const std::string& newName, const sol::object& arg2) { if (m_PBaseEntity->objtype == TYPE_PC) { @@ -5279,7 +5269,7 @@ uint16 CLuaBaseEntity::getModelId() * npc:setModelId(47, 5) -- Vermillion cloak ************************************************************************/ -void CLuaBaseEntity::setModelId(uint16 modelId, sol::object const& slotObj) +void CLuaBaseEntity::setModelId(uint16 modelId, const sol::object& slotObj) { if (m_PBaseEntity->objtype == TYPE_PC || slotObj.is()) { @@ -6013,7 +6003,7 @@ void CLuaBaseEntity::setSpeed(uint8 speedVal) * Notes : See scripts/zones/Port_Bastok/Zone.lua for no playtime example ************************************************************************/ -uint32 CLuaBaseEntity::getPlaytime(sol::object const& shouldUpdate) +uint32 CLuaBaseEntity::getPlaytime(const sol::object& shouldUpdate) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -6536,7 +6526,7 @@ void CLuaBaseEntity::setLevelCap(uint8 cap) * Notes : ************************************************************************/ -uint8 CLuaBaseEntity::levelRestriction(sol::object const& level) +uint8 CLuaBaseEntity::levelRestriction(const sol::object& level) { if (m_PBaseEntity == nullptr || m_PBaseEntity->objtype != TYPE_PC) { @@ -6927,7 +6917,7 @@ void CLuaBaseEntity::delTitle(uint16 titleID) * Notes : ************************************************************************/ -uint16 CLuaBaseEntity::getFame(sol::object const& areaObj) +uint16 CLuaBaseEntity::getFame(const sol::object& areaObj) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -6991,7 +6981,7 @@ uint16 CLuaBaseEntity::getFame(sol::object const& areaObj) * Notes : ************************************************************************/ -void CLuaBaseEntity::addFame(sol::object const& areaObj, uint16 fame) +void CLuaBaseEntity::addFame(const sol::object& areaObj, uint16 fame) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -7053,7 +7043,7 @@ void CLuaBaseEntity::addFame(sol::object const& areaObj, uint16 fame) * Notes : ************************************************************************/ -void CLuaBaseEntity::setFame(sol::object const& areaObj, uint16 fame) +void CLuaBaseEntity::setFame(const sol::object& areaObj, uint16 fame) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -7116,7 +7106,7 @@ void CLuaBaseEntity::setFame(sol::object const& areaObj, uint16 fame) * Notes : ************************************************************************/ -uint8 CLuaBaseEntity::getFameLevel(sol::object const& areaObj) +uint8 CLuaBaseEntity::getFameLevel(const sol::object& areaObj) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -7562,7 +7552,7 @@ void CLuaBaseEntity::delMission(uint8 missionLogID, uint16 missionID) * Notes : Specify the area to pass a Lua table object ************************************************************************/ -uint16 CLuaBaseEntity::getCurrentMission(sol::object const& missionLogObj) +uint16 CLuaBaseEntity::getCurrentMission(const sol::object& missionLogObj) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -7682,7 +7672,7 @@ void CLuaBaseEntity::completeMission(uint8 missionLogID, uint16 missionID) * If optional index is used, value must be between 0-15. ************************************************************************/ -void CLuaBaseEntity::setMissionStatus(uint8 missionLogID, sol::object const& arg2Obj, sol::object const& arg3Obj) +void CLuaBaseEntity::setMissionStatus(uint8 missionLogID, const sol::object& arg2Obj, const sol::object& arg3Obj) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -7738,7 +7728,7 @@ void CLuaBaseEntity::setMissionStatus(uint8 missionLogID, sol::object const& arg * Notes : getMissionStatus(log id[,index 0-7]) ************************************************************************/ -uint32 CLuaBaseEntity::getMissionStatus(uint8 missionLogID, sol::object const& missionStatusPosObj) +uint32 CLuaBaseEntity::getMissionStatus(uint8 missionLogID, const sol::object& missionStatusPosObj) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -7778,7 +7768,7 @@ uint32 CLuaBaseEntity::getMissionStatus(uint8 missionLogID, sol::object const& m * optional arg 2 can set completion state explicitly (1/0) ************************************************************************/ -void CLuaBaseEntity::setEminenceCompleted(uint16 recordID, sol::object const& arg1, sol::object const& arg2) +void CLuaBaseEntity::setEminenceCompleted(uint16 recordID, const sol::object& arg1, const sol::object& arg2) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -7843,7 +7833,7 @@ uint16 CLuaBaseEntity::getNumEminenceCompleted() * Notes : The 3rd param is optional. However, no message will be shown if not given. ************************************************************************/ -bool CLuaBaseEntity::setEminenceProgress(uint16 recordID, uint32 progress, sol::object const& arg2) +bool CLuaBaseEntity::setEminenceProgress(uint16 recordID, uint32 progress, const sol::object& arg2) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -7925,7 +7915,7 @@ bool CLuaBaseEntity::hasEminenceRecord(uint16 recordID) * Note : This only supports int/string datagram events at the moment! ************************************************************************/ -void CLuaBaseEntity::triggerRoeEvent(uint8 eventNum, sol::object const& reqTable) +void CLuaBaseEntity::triggerRoeEvent(uint8 eventNum, const sol::object& reqTable) { RoeDatagramList roeEventData({}); ROE_EVENT eventID = static_cast(eventNum); @@ -8010,7 +8000,7 @@ uint8 CLuaBaseEntity::getUnityLeader() * Example : player:getUnityRank() ************************************************************************/ -std::optional CLuaBaseEntity::getUnityRank(sol::object const& unityObj) +std::optional CLuaBaseEntity::getUnityRank(const sol::object& unityObj) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -8843,7 +8833,7 @@ bool CLuaBaseEntity::delGil(int32 gil) * Notes : See char_points.sql for all currency types ************************************************************************/ -int32 CLuaBaseEntity::getCurrency(std::string const& currencyType) +int32 CLuaBaseEntity::getCurrency(const std::string& currencyType) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -8862,7 +8852,7 @@ int32 CLuaBaseEntity::getCurrency(std::string const& currencyType) * Notes : ************************************************************************/ -void CLuaBaseEntity::addCurrency(std::string const& currencyType, int32 amount, sol::object const& maxObj) +void CLuaBaseEntity::addCurrency(const std::string& currencyType, int32 amount, const sol::object& maxObj) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -8883,7 +8873,7 @@ void CLuaBaseEntity::addCurrency(std::string const& currencyType, int32 amount, * Notes : ************************************************************************/ -void CLuaBaseEntity::setCurrency(std::string const& currencyType, int32 amount) +void CLuaBaseEntity::setCurrency(const std::string& currencyType, int32 amount) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -8902,7 +8892,7 @@ void CLuaBaseEntity::setCurrency(std::string const& currencyType, int32 amount) * Notes : ************************************************************************/ -void CLuaBaseEntity::delCurrency(std::string const& currencyType, int32 amount) +void CLuaBaseEntity::delCurrency(const std::string& currencyType, int32 amount) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -9457,7 +9447,7 @@ void CLuaBaseEntity::delHP(int32 delAmt) * Example : target:takeDamage(500, attacker=nil, attackType=ATTACK_NONE, damageType=DAMAGE_NONE, flags={wakeUp=true}) ************************************************************************/ -void CLuaBaseEntity::takeDamage(int32 damage, sol::object const& attacker, sol::object const& atkType, sol::object const& dmgType, sol::object const& flags) +void CLuaBaseEntity::takeDamage(int32 damage, const sol::object& attacker, const sol::object& atkType, const sol::object& dmgType, const sol::object& flags) { if (m_PBaseEntity->objtype == TYPE_NPC) { @@ -9507,8 +9497,7 @@ void CLuaBaseEntity::takeDamage(int32 damage, sol::object const& attacker, sol:: // Check to see if the target has a nightmare effect active, reset wakeUp accordingly // see mobskills/nightmare.lua for full explanation if ( - PDefender->StatusEffectContainer->GetStatusEffect(EFFECT_SLEEP) && - PDefender->StatusEffectContainer->GetStatusEffect(EFFECT_SLEEP)->GetTier() > 0) + PDefender->StatusEffectContainer->GetStatusEffect(EFFECT_SLEEP) && PDefender->StatusEffectContainer->GetStatusEffect(EFFECT_SLEEP)->GetTier() > 0) { // Don't break nightmare sleep from any dmg that doesn't break bind (DoT damage) if (breakBind == false) @@ -9519,8 +9508,7 @@ void CLuaBaseEntity::takeDamage(int32 damage, sol::object const& attacker, sol:: // Diabolos NM/mob ability // "Damage will not wake you up from Nightmare, only Cure and Benediction (Benediction will also remove the Bio effect)." if ( - wakeUp == true && - PDefender->StatusEffectContainer->GetStatusEffect(EFFECT_SLEEP)->GetTier() > 1) + wakeUp == true && PDefender->StatusEffectContainer->GetStatusEffect(EFFECT_SLEEP)->GetTier() > 1) { wakeUp = false; } @@ -10108,7 +10096,7 @@ void CLuaBaseEntity::delLearnedWeaponskill(uint8 wsUnlockId) * Notes : ************************************************************************/ -void CLuaBaseEntity::trySkillUp(uint8 skill, uint8 level, sol::object const& forceSkillUpObj, sol::object const& useSubSkillObj) +void CLuaBaseEntity::trySkillUp(uint8 skill, uint8 level, const sol::object& forceSkillUpObj, const sol::object& useSubSkillObj) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -10562,7 +10550,7 @@ sol::table CLuaBaseEntity::getPartyWithTrusts() * Notes : ************************************************************************/ -uint8 CLuaBaseEntity::getPartySize(sol::object const& arg0) +uint8 CLuaBaseEntity::getPartySize(const sol::object& arg0) { if (m_PBaseEntity->objtype == TYPE_NPC) { @@ -10601,7 +10589,7 @@ bool CLuaBaseEntity::hasPartyJob(uint8 job) { if (static_cast(m_PBaseEntity)->PParty != nullptr) { - for (auto const& member : static_cast(m_PBaseEntity)->PParty->members) + for (const auto& member : static_cast(m_PBaseEntity)->PParty->members) { CCharEntity* PTarget = static_cast(member); @@ -10651,8 +10639,7 @@ std::optional CLuaBaseEntity::getPartyMember(uint8 member, uint8 { PTargetChar = PBattle->PParty->members[member]; } - else if (PBattle->PParty->m_PAlliance != nullptr && - member <= PBattle->PParty->m_PAlliance->partyList.at(allianceparty)->members.size()) + else if (PBattle->PParty->m_PAlliance != nullptr && member <= PBattle->PParty->m_PAlliance->partyList.at(allianceparty)->members.size()) { PTargetChar = PBattle->PParty->m_PAlliance->partyList.at(allianceparty)->members[member]; } @@ -10735,13 +10722,12 @@ void CLuaBaseEntity::addPartyEffect(sol::variadic_args va) std::vector args(7, 0); uint8 idx = 0; - for (auto const& v : va) + for (const auto& v : va) { args[idx++] = v.get(); } - CStatusEffect* PEffect = - new CStatusEffect(static_cast(args[0]), args[1], args[2], args[3], args[4], args[5], args[6]); + CStatusEffect* PEffect = new CStatusEffect(static_cast(args[0]), args[1], args[2], args[3], args[4], args[5], args[6]); CBattleEntity* PEntity = ((CBattleEntity*)m_PBaseEntity); @@ -11041,7 +11027,7 @@ uint8 CLuaBaseEntity::checkSoloPartyAlliance() * Notes : and the mob is able to give exp to the members ************************************************************************/ -bool CLuaBaseEntity::checkKillCredit(CLuaBaseEntity* PLuaBaseEntity, sol::object const& minRange) +bool CLuaBaseEntity::checkKillCredit(CLuaBaseEntity* PLuaBaseEntity, const sol::object& minRange) { if (m_PBaseEntity->objtype != TYPE_PC || (PLuaBaseEntity && PLuaBaseEntity->GetBaseEntity()->objtype != TYPE_MOB)) { @@ -11261,7 +11247,7 @@ int32 CLuaBaseEntity::getBattlefieldID() * Notes : Returns BATTLEFIELD_RETURNCODE (see scripts/globals/battlefield.lua or src/map/battlefield.h) ************************************************************************/ -uint8 CLuaBaseEntity::registerBattlefield(sol::object const& arg0, sol::object const& arg1, sol::object const& arg2, sol::object const& arg3) +uint8 CLuaBaseEntity::registerBattlefield(const sol::object& arg0, const sol::object& arg1, const sol::object& arg2, const sol::object& arg3) { if (m_PBaseEntity->loc.zone->m_BattlefieldHandler == nullptr) { @@ -11356,7 +11342,7 @@ bool CLuaBaseEntity::battlefieldAtCapacity(int battlefieldID) * Notes : ************************************************************************/ -bool CLuaBaseEntity::enterBattlefield(sol::object const& area) +bool CLuaBaseEntity::enterBattlefield(const sol::object& area) { if (m_PBaseEntity->objtype != TYPE_PC || m_PBaseEntity->loc.zone->m_BattlefieldHandler == nullptr) { @@ -11615,7 +11601,7 @@ void CLuaBaseEntity::allowSendRaisePrompt() * Example : player:countdown(60) * Notes : Using 0 or no argument removes the countdown bar from the player ************************************************************************/ -void CLuaBaseEntity::countdown(sol::object const& secondsObj) +void CLuaBaseEntity::countdown(const sol::object& secondsObj) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -11675,7 +11661,7 @@ void CLuaBaseEntity::countdown(sol::object const& secondsObj) Can have up to 6 bars. Many of these items are optional. Calling without arguments will clear everything. ************************************************************************/ -void CLuaBaseEntity::objectiveUtility(sol::object const& obj) +void CLuaBaseEntity::objectiveUtility(const sol::object& obj) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -11779,7 +11765,7 @@ void CLuaBaseEntity::objectiveUtility(sol::object const& obj) * Example : player:enableEntities({ 17207972, 17207973}) * Notes : Default is all off, so sending the ID enables the special entity ************************************************************************/ -void CLuaBaseEntity::enableEntities(sol::object const& obj) +void CLuaBaseEntity::enableEntities(const sol::object& obj) { if (auto* PChar = dynamic_cast(m_PBaseEntity)) { @@ -11906,7 +11892,7 @@ void CLuaBaseEntity::addRecast(uint8 recastCont, uint16 recastID, uint32 duratio * Notes : Recast parameter is optional to check charges ************************************************************************/ -bool CLuaBaseEntity::hasRecast(uint8 rType, uint16 recastID, sol::object const& arg2) +bool CLuaBaseEntity::hasRecast(uint8 rType, uint16 recastID, const sol::object& arg2) { bool hasRecast = false; auto* PBattleEntity = dynamic_cast(m_PBaseEntity); @@ -11978,7 +11964,7 @@ void CLuaBaseEntity::resetRecasts() * Notes : Function along with statements must be passed in L3 ************************************************************************/ -void CLuaBaseEntity::addListener(std::string const& eventName, std::string const& identifier, sol::function const& func) +void CLuaBaseEntity::addListener(const std::string& eventName, const std::string& identifier, const sol::function& func) { m_PBaseEntity->PAI->EventHandler.addListener(eventName, func, identifier); } @@ -11990,7 +11976,7 @@ void CLuaBaseEntity::addListener(std::string const& eventName, std::string const * Notes : Used heavily in PUP Ability scripts ************************************************************************/ -void CLuaBaseEntity::removeListener(std::string const& identifier) +void CLuaBaseEntity::removeListener(const std::string& identifier) { m_PBaseEntity->PAI->EventHandler.removeListener(identifier); } @@ -12003,7 +11989,7 @@ void CLuaBaseEntity::removeListener(std::string const& identifier) * Notes : Manually triggered through Aern scripts for some reason ************************************************************************/ -void CLuaBaseEntity::triggerListener(std::string const& eventName, sol::variadic_args args) +void CLuaBaseEntity::triggerListener(const std::string& eventName, sol::variadic_args args) { m_PBaseEntity->PAI->EventHandler.triggerListener(eventName, sol::as_args(args)); } @@ -12017,7 +12003,7 @@ void CLuaBaseEntity::triggerListener(std::string const& eventName, sol::variadic * : This is just for the presence of an event in general, not a specific one ************************************************************************/ -bool CLuaBaseEntity::hasListener(std::string const& eventName) +bool CLuaBaseEntity::hasListener(const std::string& eventName) { return m_PBaseEntity->PAI->EventHandler.hasListener(eventName); } @@ -12392,7 +12378,7 @@ float CLuaBaseEntity::checkLiementAbsorb(uint16 damageType) * Notes : See Ventriloquy and Atonement ************************************************************************/ -int32 CLuaBaseEntity::getCE(CLuaBaseEntity const* target) +int32 CLuaBaseEntity::getCE(const CLuaBaseEntity* target) { if (m_PBaseEntity->objtype != TYPE_MOB) { @@ -12410,7 +12396,7 @@ int32 CLuaBaseEntity::getCE(CLuaBaseEntity const* target) * Notes : See Ventriloquy and Atonement ************************************************************************/ -int32 CLuaBaseEntity::getVE(CLuaBaseEntity const* target) +int32 CLuaBaseEntity::getVE(const CLuaBaseEntity* target) { if (m_PBaseEntity->objtype != TYPE_MOB) { @@ -12573,7 +12559,7 @@ void CLuaBaseEntity::transferEnmity(CLuaBaseEntity* entity, uint8 percent, float if (distanceSquared(mob_pair.second->loc.p, PEntity->loc.p) < (range * range)) { battleutils::TransferEnmity(static_cast(PEntity), static_cast(m_PBaseEntity), - static_cast(mob_pair.second), percent); + static_cast(mob_pair.second), percent); } } } @@ -12615,7 +12601,7 @@ void CLuaBaseEntity::updateEnmityFromDamage(CLuaBaseEntity* PEntity, int32 damag * Notes : Used in nearly all Cure scripts and abilities which heal ************************************************************************/ -void CLuaBaseEntity::updateEnmityFromCure(CLuaBaseEntity* PEntity, int32 amount, sol::object const& optionalFixedCE, sol::object const& optionalFixedVE) +void CLuaBaseEntity::updateEnmityFromCure(CLuaBaseEntity* PEntity, int32 amount, const sol::object& optionalFixedCE, const sol::object& optionalFixedVE) { int32 fixedCE = optionalFixedCE.is() ? optionalFixedCE.as() : 0; int32 fixedVE = optionalFixedVE.is() ? optionalFixedVE.as() : 0; @@ -12679,7 +12665,7 @@ void CLuaBaseEntity::resetEnmity(CLuaBaseEntity* PEntity) * Notes : Used mostly in QM (???) scripts ************************************************************************/ -void CLuaBaseEntity::updateClaim(sol::object const& entity) +void CLuaBaseEntity::updateClaim(const sol::object& entity) { if (m_PBaseEntity->objtype != TYPE_MOB) { @@ -12836,13 +12822,13 @@ bool CLuaBaseEntity::addStatusEffect(sol::variadic_args va) auto tier = va[6].is() ? va[6].as() : 0; CStatusEffect* PEffect = new CStatusEffect(effectID, - effectIcon, - power, - tick, - duration, - subType, - subPower, - tier); + effectIcon, + power, + tick, + duration, + subType, + subPower, + tier); if (PEffect->GetStatusID() == EFFECT_FOOD) { @@ -12896,16 +12882,15 @@ bool CLuaBaseEntity::addStatusEffectEx(sol::variadic_args va) auto tier = va[7].is() ? va[7].as() : 0; auto effectFlag = va[8].is() ? va[8].as() : 0; - CStatusEffect* PEffect = - new CStatusEffect(effectID, - effectIcon, - power, - tick, - duration, - subType, - subPower, - tier, - effectFlag); // Effect Flag (i.e in lua xi.effectFlag.AURA will make this an aura effect) + CStatusEffect* PEffect = new CStatusEffect(effectID, + effectIcon, + power, + tick, + duration, + subType, + subPower, + tier, + effectFlag); // Effect Flag (i.e in lua xi.effectFlag.AURA will make this an aura effect) return ((CBattleEntity*)m_PBaseEntity)->StatusEffectContainer->AddStatusEffect(PEffect, silent); } @@ -12917,7 +12902,7 @@ bool CLuaBaseEntity::addStatusEffectEx(sol::variadic_args va) * Notes : ************************************************************************/ -std::optional CLuaBaseEntity::getStatusEffect(uint16 StatusID, sol::object const& SubType) +std::optional CLuaBaseEntity::getStatusEffect(uint16 StatusID, const sol::object& SubType) { if (m_PBaseEntity->objtype == TYPE_NPC) { @@ -13010,7 +12995,7 @@ int16 CLuaBaseEntity::getStatusEffectElement(uint16 statusId) * Notes : ************************************************************************/ -bool CLuaBaseEntity::canGainStatusEffect(uint16 effect, sol::object const& powerObj) +bool CLuaBaseEntity::canGainStatusEffect(uint16 effect, const sol::object& powerObj) { if (m_PBaseEntity->objtype == TYPE_NPC) { @@ -13038,7 +13023,7 @@ bool CLuaBaseEntity::canGainStatusEffect(uint16 effect, sol::object const& power * Notes : More specific in scope than hasStatusEffectByFlag() ************************************************************************/ -bool CLuaBaseEntity::hasStatusEffect(uint16 StatusID, sol::object const& SubType) +bool CLuaBaseEntity::hasStatusEffect(uint16 StatusID, const sol::object& SubType) { if (m_PBaseEntity->objtype == TYPE_NPC) { @@ -13150,7 +13135,7 @@ uint8 CLuaBaseEntity::countEffectWithFlag(uint32 flag) * Notes : Can specify Power of the Effect as an option ************************************************************************/ -bool CLuaBaseEntity::delStatusEffect(uint16 StatusID, sol::object const& SubType) +bool CLuaBaseEntity::delStatusEffect(uint16 StatusID, const sol::object& SubType) { if (m_PBaseEntity->objtype == TYPE_NPC) { @@ -13188,7 +13173,7 @@ bool CLuaBaseEntity::delStatusEffect(uint16 StatusID, sol::object const& SubType * Notes : Used for removal of multiple effects with matching flag ************************************************************************/ -void CLuaBaseEntity::delStatusEffectsByFlag(uint32 flag, sol::object const& silent) +void CLuaBaseEntity::delStatusEffectsByFlag(uint32 flag, const sol::object& silent) { if (m_PBaseEntity->objtype == TYPE_NPC) { @@ -13288,7 +13273,7 @@ uint8 CLuaBaseEntity::eraseAllStatusEffect() * Notes : Can specify which type to remove, if Dispelable ************************************************************************/ -int32 CLuaBaseEntity::dispelStatusEffect(sol::object const& flagObj) +int32 CLuaBaseEntity::dispelStatusEffect(const sol::object& flagObj) { if (m_PBaseEntity->objtype == TYPE_NPC) { @@ -13314,7 +13299,7 @@ int32 CLuaBaseEntity::dispelStatusEffect(sol::object const& flagObj) * Notes : Can specify which types to remove, if Dispelable ************************************************************************/ -uint8 CLuaBaseEntity::dispelAllStatusEffect(sol::object const& flagObj) +uint8 CLuaBaseEntity::dispelAllStatusEffect(const sol::object& flagObj) { if (m_PBaseEntity->objtype == TYPE_NPC) { @@ -13340,7 +13325,7 @@ uint8 CLuaBaseEntity::dispelAllStatusEffect(sol::object const& flagObj) * Notes : ************************************************************************/ -uint16 CLuaBaseEntity::stealStatusEffect(CLuaBaseEntity* PTargetEntity, sol::object const& flagObj) +uint16 CLuaBaseEntity::stealStatusEffect(CLuaBaseEntity* PTargetEntity, const sol::object& flagObj) { if (m_PBaseEntity->objtype == TYPE_NPC) { @@ -13595,7 +13580,7 @@ bool CLuaBaseEntity::doRandomDeal(CLuaBaseEntity* PTarget) *total, MOD_ATTP) Notes : Returns true if success (Is range a factor?) ************************************************************************/ -bool CLuaBaseEntity::addCorsairRoll(uint8 casterJob, uint8 bustDuration, uint16 effectID, uint16 power, uint32 tick, uint32 duration, sol::object const& arg6, sol::object const& arg7, sol::object const& arg8) +bool CLuaBaseEntity::addCorsairRoll(uint8 casterJob, uint8 bustDuration, uint16 effectID, uint16 power, uint32 tick, uint32 duration, const sol::object& arg6, const sol::object& arg7, const sol::object& arg8) { if (m_PBaseEntity->objtype == TYPE_NPC) { @@ -13603,14 +13588,14 @@ bool CLuaBaseEntity::addCorsairRoll(uint8 casterJob, uint8 bustDuration, uint16 return false; } - CStatusEffect* PEffect = new CStatusEffect(static_cast(effectID), // Effect ID - effectID, // Effect Icon (Associated with ID) - power, // Power - tick, // Tick - duration, // Duration - (arg6 != sol::lua_nil) ? arg6.as() : 0, // SubType or 0 - (arg7 != sol::lua_nil) ? arg7.as() : 0, // SubPower or 0 - (arg8 != sol::lua_nil) ? arg8.as() : 0 // Tier or 0 + CStatusEffect* PEffect = new CStatusEffect(static_cast(effectID), // Effect ID + effectID, // Effect Icon (Associated with ID) + power, // Power + tick, // Tick + duration, // Duration + (arg6 != sol::lua_nil) ? arg6.as() : 0, // SubType or 0 + (arg7 != sol::lua_nil) ? arg7.as() : 0, // SubPower or 0 + (arg8 != sol::lua_nil) ? arg8.as() : 0 // Tier or 0 ); uint8 maxRolls = 2; @@ -13704,13 +13689,13 @@ uint16 CLuaBaseEntity::healingWaltz() bool CLuaBaseEntity::addBardSong(CLuaBaseEntity* PEntity, uint16 effectID, uint16 power, uint16 tick, uint16 duration, uint16 subType, uint16 subPower, uint16 tier) { CStatusEffect* PEffect = new CStatusEffect(static_cast(effectID), // Effect ID - effectID, // Effect Icon (Associated with ID) - power, // Power - tick, // Tick - duration, // Duration - subType, // SubType - subPower, // SubPower - tier // Tier + effectID, // Effect Icon (Associated with ID) + power, // Power + tick, // Tick + duration, // Duration + subType, // SubType + subPower, // SubPower + tier // Tier ); uint8 maxSongs = 2; @@ -13720,8 +13705,7 @@ bool CLuaBaseEntity::addBardSong(CLuaBaseEntity* PEntity, uint16 effectID, uint1 CCharEntity* PCaster = static_cast(PEntity->m_PBaseEntity); CItemWeapon* PItem = static_cast(PCaster->getEquip(SLOT_RANGED)); - if (PItem == nullptr || PItem->getID() == 65535 || - !(PItem->getSkillType() == SKILL_STRING_INSTRUMENT || PItem->getSkillType() == SKILL_WIND_INSTRUMENT)) + if (PItem == nullptr || PItem->getID() == 65535 || !(PItem->getSkillType() == SKILL_STRING_INSTRUMENT || PItem->getSkillType() == SKILL_WIND_INSTRUMENT)) { maxSongs = 1; } @@ -13741,7 +13725,7 @@ bool CLuaBaseEntity::addBardSong(CLuaBaseEntity* PEntity, uint16 effectID, uint1 * by the status effect charm, which is the case for charmed players) ************************************************************************/ -void CLuaBaseEntity::charm(CLuaBaseEntity const* target, sol::object const& p0) +void CLuaBaseEntity::charm(const CLuaBaseEntity* target, const sol::object& p0) { auto charmDuration = std::chrono::seconds(p0 != sol::lua_nil ? p0.as() : 0); battleutils::applyCharm(static_cast(m_PBaseEntity), static_cast(target->GetBaseEntity()), charmDuration); @@ -14514,14 +14498,14 @@ auto CLuaBaseEntity::getWSSkillchainProp() -> std::tuple ************************************************************************/ int32 CLuaBaseEntity::takeWeaponskillDamage(CLuaBaseEntity* attacker, int32 damage, uint8 atkType, uint8 dmgType, uint8 slot, bool primary, - float tpMultiplier, uint16 bonusTP, float targetTPMultiplier) + float tpMultiplier, uint16 bonusTP, float targetTPMultiplier) { auto* PChar = static_cast(attacker->m_PBaseEntity); ATTACK_TYPE attackType = static_cast(atkType); DAMAGE_TYPE damageType = static_cast(dmgType); return battleutils::TakeWeaponskillDamage(PChar, static_cast(m_PBaseEntity), damage, attackType, damageType, slot, - primary, tpMultiplier, bonusTP, targetTPMultiplier); + primary, tpMultiplier, bonusTP, targetTPMultiplier); } /************************************************************************ @@ -14576,7 +14560,7 @@ int32 CLuaBaseEntity::checkDamageCap(int32 damage) * Notes : ************************************************************************/ -void CLuaBaseEntity::spawnPet(sol::object const& arg0) +void CLuaBaseEntity::spawnPet(const sol::object& arg0) { if (m_PBaseEntity->objtype == TYPE_NPC) { @@ -14721,7 +14705,7 @@ void CLuaBaseEntity::trustPartyMessage(uint32 message_id) * Notes : Adds a behaviour to the gambit system ************************************************************************/ -std::string CLuaBaseEntity::addSimpleGambit(uint16 targ, uint16 cond, uint32 condition_arg, uint16 react, uint16 select, uint32 selector_arg, sol::object const& retry) +std::string CLuaBaseEntity::addSimpleGambit(uint16 targ, uint16 cond, uint32 condition_arg, uint16 react, uint16 select, uint32 selector_arg, const sol::object& retry) { if (m_PBaseEntity->objtype != TYPE_TRUST) { @@ -14760,7 +14744,7 @@ std::string CLuaBaseEntity::addSimpleGambit(uint16 targ, uint16 cond, uint32 con * : from addSimpleGambit ************************************************************************/ -void CLuaBaseEntity::removeSimpleGambit(std::string const& id) +void CLuaBaseEntity::removeSimpleGambit(const std::string& id) { if (m_PBaseEntity->objtype != TYPE_TRUST) { @@ -14802,7 +14786,7 @@ void CLuaBaseEntity::removeAllSimpleGambits() * Notes : value is optional TP Value ************************************************************************/ -void CLuaBaseEntity::setTrustTPSkillSettings(uint16 trigger, uint16 select, sol::object const& value) +void CLuaBaseEntity::setTrustTPSkillSettings(uint16 trigger, uint16 select, const sol::object& value) { if (m_PBaseEntity->objtype != TYPE_TRUST) { @@ -15025,7 +15009,7 @@ uint8 CLuaBaseEntity::getPetElement() * Example : mob:setPet(mobObject) ************************************************************************/ -void CLuaBaseEntity::setPet(sol::object const& petObj) +void CLuaBaseEntity::setPet(const sol::object& petObj) { if (m_PBaseEntity->objtype == TYPE_NPC) { @@ -15135,7 +15119,7 @@ auto CLuaBaseEntity::getPetName() -> const std::string * Notes : Updates char_pet.sql ************************************************************************/ -void CLuaBaseEntity::setPetName(uint8 pType, uint16 value, sol::object const& arg2) +void CLuaBaseEntity::setPetName(uint8 pType, uint16 value, const sol::object& arg2) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -15154,7 +15138,7 @@ void CLuaBaseEntity::setPetName(uint8 pType, uint16 value, sol::object const& ar else if (petType == PET_TYPE::AUTOMATON) { _sql->Query("INSERT INTO char_pet SET charid = %u, automatonid = %u ON DUPLICATE KEY UPDATE automatonid = %u", m_PBaseEntity->id, value, - value); + value); if (static_cast(m_PBaseEntity)->PAutomaton != nullptr) { puppetutils::LoadAutomaton(static_cast(m_PBaseEntity)); @@ -15171,7 +15155,7 @@ void CLuaBaseEntity::setPetName(uint8 pType, uint16 value, sol::object const& ar uint32 nameValue = chocoboname1 + chocoboname2; _sql->Query("INSERT INTO char_pet SET charid = %u, chocoboid = %u ON DUPLICATE KEY UPDATE chocoboid = %u", m_PBaseEntity->id, nameValue, - nameValue); + nameValue); } } } @@ -15545,7 +15529,7 @@ void CLuaBaseEntity::updateAttachments() * after percentage is applied. ************************************************************************/ -void CLuaBaseEntity::reduceBurden(float percentReduction, sol::object const& intReductionObj) +void CLuaBaseEntity::reduceBurden(float percentReduction, const sol::object& intReductionObj) { if (m_PBaseEntity->objtype == TYPE_NPC) { @@ -15907,7 +15891,7 @@ void CLuaBaseEntity::setMeleeRange(float range) * Notes : Used for changing Ul'xzomit babies' size and through !setmobflags command ************************************************************************/ -void CLuaBaseEntity::setMobFlags(uint32 flags, sol::object const& mobId) +void CLuaBaseEntity::setMobFlags(uint32 flags, const sol::object& mobId) { if (m_PBaseEntity->objtype != TYPE_MOB && m_PBaseEntity->objtype != TYPE_PC) { @@ -16000,7 +15984,7 @@ void CLuaBaseEntity::setNpcFlags(uint32 flags) * Notes : ************************************************************************/ -void CLuaBaseEntity::spawn(sol::object const& despawnSec, sol::object const& respawnSec) +void CLuaBaseEntity::spawn(const sol::object& despawnSec, const sol::object& respawnSec) { if (m_PBaseEntity->objtype != TYPE_MOB) { @@ -16088,7 +16072,7 @@ auto CLuaBaseEntity::getSpawnPos() -> std::map * Notes : Removed table support. Unpack! ************************************************************************/ -void CLuaBaseEntity::setSpawn(float x, float y, float z, sol::object const& rot) +void CLuaBaseEntity::setSpawn(float x, float y, float z, const sol::object& rot) { if (m_PBaseEntity->objtype != TYPE_MOB) { @@ -16796,7 +16780,7 @@ sol::table CLuaBaseEntity::getEnmityList() if (enmityList) { auto table = lua.create_table(); - for (auto const& member : *enmityList) + for (const auto& member : *enmityList) { if (member.second.PEnmityOwner) { @@ -16858,7 +16842,7 @@ bool CLuaBaseEntity::actionQueueEmpty() * Notes : Currently only used by a few select mobs ************************************************************************/ -void CLuaBaseEntity::castSpell(sol::object const& spell, sol::object const& entity) +void CLuaBaseEntity::castSpell(const sol::object& spell, const sol::object& entity) { if (spell != sol::lua_nil) { @@ -16920,7 +16904,7 @@ void CLuaBaseEntity::castSpell(sol::object const& spell, sol::object const& enti * and checks queue for immediate use. ************************************************************************/ -void CLuaBaseEntity::useJobAbility(uint16 skillID, sol::object const& pet) +void CLuaBaseEntity::useJobAbility(uint16 skillID, const sol::object& pet) { CBattleEntity* PTarget{ nullptr }; @@ -17322,7 +17306,7 @@ void CLuaBaseEntity::setDropID(uint32 dropID) * Example : targ:addTreasure(itemId, dropper) ************************************************************************/ -void CLuaBaseEntity::addTreasure(uint16 itemID, sol::object const& arg1, sol::object const& arg2) +void CLuaBaseEntity::addTreasure(uint16 itemID, const sol::object& arg1, const sol::object& arg2) { if (m_PBaseEntity->objtype != TYPE_PC) { @@ -17384,7 +17368,7 @@ uint16 CLuaBaseEntity::getStealItem() // Steal item randomly selected from steal drop table std::vector items; - for (DropItem_t const& drop : PDropList->Items) + for (const DropItem_t& drop : PDropList->Items) { if (drop.DropType == DROP_STEAL) { @@ -17425,7 +17409,7 @@ uint16 CLuaBaseEntity::getDespoilItem() if (PDropList && !PMob->m_ItemStolen) { - for (DropItem_t const& drop : PDropList->Items) + for (const DropItem_t& drop : PDropList->Items) { if (drop.DropType == DROP_DESPOIL) { @@ -17743,7 +17727,7 @@ auto CLuaBaseEntity::getChocoboRaisingInfo() -> sol::table return sol::lua_nil; } -bool CLuaBaseEntity::setChocoboRaisingInfo(sol::table const& table) +bool CLuaBaseEntity::setChocoboRaisingInfo(const sol::table& table) { ShowDebug("Setting Raising Chocobo Info (%s)", m_PBaseEntity->name); @@ -17782,32 +17766,32 @@ bool CLuaBaseEntity::setChocoboRaisingInfo(sol::table const& table) held_item = %u"; int32 ret = _sql->Query(Query, - m_PBaseEntity->id, - table.get_or("first_name", "Chocobo"), - table.get_or("last_name", "Chocobo"), - table.get_or("sex", 0), - table.get_or("created", 0), - table.get_or("last_update_age", 0), - table.get_or("stage", 1), - table.get_or("location", 0), - table.get_or("colour", 0), - table.get_or("dominant_gene", 0), - table.get_or("recessive_gene", 0), - table.get_or("strength", 0), - table.get_or("endurance", 0), - table.get_or("discernment", 0), - table.get_or("receptivity", 0), - table.get_or("affection", 0), - table.get_or("energy", 0), - table.get_or("satisfaction", 0), - table.get_or("conditions", 0), - table.get_or("ability1", 0), - table.get_or("ability2", 0), - table.get_or("personality", 0), - table.get_or("weather_preference", 0), - table.get_or("hunger", 0), - table.get_or("care_plan", 0), - table.get_or("held_item", 0)); + m_PBaseEntity->id, + table.get_or("first_name", "Chocobo"), + table.get_or("last_name", "Chocobo"), + table.get_or("sex", 0), + table.get_or("created", 0), + table.get_or("last_update_age", 0), + table.get_or("stage", 1), + table.get_or("location", 0), + table.get_or("colour", 0), + table.get_or("dominant_gene", 0), + table.get_or("recessive_gene", 0), + table.get_or("strength", 0), + table.get_or("endurance", 0), + table.get_or("discernment", 0), + table.get_or("receptivity", 0), + table.get_or("affection", 0), + table.get_or("energy", 0), + table.get_or("satisfaction", 0), + table.get_or("conditions", 0), + table.get_or("ability1", 0), + table.get_or("ability2", 0), + table.get_or("personality", 0), + table.get_or("weather_preference", 0), + table.get_or("hunger", 0), + table.get_or("care_plan", 0), + table.get_or("held_item", 0)); if (ret == SQL_ERROR) { @@ -18026,7 +18010,7 @@ void CLuaBaseEntity::addPacketMod(uint16 packetId, uint16 offset, uint8 value) if (auto* PChar = dynamic_cast(m_PBaseEntity)) { ShowInfo(fmt::format("Adding Packet Mod ({}): 0x{:04X}: 0x{:04X}: 0x{:02X}", - PChar->name, packetId, offset, value)); + PChar->name, packetId, offset, value)); PacketMods[PChar->id][packetId].emplace_back(std::make_pair(offset, value)); } } diff --git a/src/map/lua/lua_baseentity.h b/src/map/lua/lua_baseentity.h index 63e8f4cc212..0cdfc145244 100644 --- a/src/map/lua/lua_baseentity.h +++ b/src/map/lua/lua_baseentity.h @@ -51,40 +51,40 @@ class CLuaBaseEntity friend std::ostream& operator<<(std::ostream& out, const CLuaBaseEntity& entity); // Messaging System - void showText(CLuaBaseEntity* mob, uint16 messageID, sol::object const& p0, sol::object const& p1, sol::object const& p2, sol::object const& p3); - void messageText(CLuaBaseEntity* PLuaBaseEntity, uint16 messageID, sol::object const& arg2, sol::object const& arg3); - void printToPlayer(std::string const& message, sol::object const& messageTypeObj, sol::object const& nameObj); - void printToArea(std::string const& message, sol::object const& arg1, sol::object const& arg2, sol::object const& arg3); - void messageBasic(uint16 messageID, sol::object const& p0, sol::object const& p1, sol::object const& target); - void messageName(uint16 messageID, sol::object const& entity, sol::object const& p0, sol::object const& p1, - sol::object const& p2, sol::object const& p3, sol::object const& chat); - void messagePublic(uint16 messageID, CLuaBaseEntity const* PEntity, sol::object const& arg2, sol::object const& arg3); + void showText(CLuaBaseEntity* mob, uint16 messageID, const sol::object& p0, const sol::object& p1, const sol::object& p2, const sol::object& p3); + void messageText(CLuaBaseEntity* PLuaBaseEntity, uint16 messageID, const sol::object& arg2, const sol::object& arg3); + void printToPlayer(const std::string& message, const sol::object& messageTypeObj, const sol::object& nameObj); + void printToArea(const std::string& message, const sol::object& arg1, const sol::object& arg2, const sol::object& arg3); + void messageBasic(uint16 messageID, const sol::object& p0, const sol::object& p1, const sol::object& target); + void messageName(uint16 messageID, const sol::object& entity, const sol::object& p0, const sol::object& p1, + const sol::object& p2, const sol::object& p3, const sol::object& chat); + void messagePublic(uint16 messageID, const CLuaBaseEntity* PEntity, const sol::object& arg2, const sol::object& arg3); void messageSpecial(uint16 messageID, sol::variadic_args va); - void messageSystem(MsgStd messageID, sol::object const& p0, sol::object const& p1); - void messageCombat(sol::object const& speaker, int32 p0, int32 p1, int16 message); + void messageSystem(MsgStd messageID, const sol::object& p0, const sol::object& p1); + void messageCombat(const sol::object& speaker, int32 p0, int32 p1, int16 message); void messageStandard(uint16 messageID); - void customMenu(sol::object const& obj); + void customMenu(const sol::object& obj); // Variables - int32 getCharVar(std::string const& varName); - void setCharVar(std::string const& varname, int32 value, sol::object const& expiry); - void setCharVarExpiration(std::string const& varName, uint32 expiry); // Sets character variable expiration timestamp - void incrementCharVar(std::string const& varname, int32 value); // Increments/decrements/sets a character variable - void setVolatileCharVar(std::string const& varName, int32 value, sol::object const& expiry); + int32 getCharVar(const std::string& varName); + void setCharVar(const std::string& varname, int32 value, const sol::object& expiry); + void setCharVarExpiration(const std::string& varName, uint32 expiry); // Sets character variable expiration timestamp + void incrementCharVar(const std::string& varname, int32 value); // Increments/decrements/sets a character variable + void setVolatileCharVar(const std::string& varName, int32 value, const sol::object& expiry); auto getLocalVars() -> sol::table; - uint32 getLocalVar(std::string const& var); - void setLocalVar(std::string const& var, uint32 val); + uint32 getLocalVar(const std::string& var); + void setLocalVar(const std::string& var, uint32 val); void resetLocalVars(); - void clearVarsWithPrefix(std::string const& prefix); + void clearVarsWithPrefix(const std::string& prefix); uint32 getLastOnline(); // Returns the unix timestamp of last time the player logged out or zoned // Packets, Events, and Flags - void injectPacket(std::string const& filename); // Send the character a packet kept in a file + void injectPacket(const std::string& filename); // Send the character a packet kept in a file void injectActionPacket(uint32 inTargetID, uint16 inCategory, uint16 inAnimationID, uint16 inSpecEffect, uint16 inReaction, uint16 inMessage, uint16 inActionParam, uint16 inParam); - void entityVisualPacket(std::string const& command, sol::object const& entity); - void entityAnimationPacket(const char* command, sol::object const& target); - void sendDebugPacket(sol::table const& packetData); + void entityVisualPacket(const std::string& command, const sol::object& entity); + void entityAnimationPacket(const char* command, const sol::object& target); + void sendDebugPacket(const sol::table& packetData); void StartEventHelper(int32 EventID, sol::variadic_args va, EVENT_TYPE eventType); EventInfo* ParseEvent(int32 EventID, sol::variadic_args va, EventPrep* eventPreparation, EVENT_TYPE eventType); @@ -104,7 +104,7 @@ class CLuaBaseEntity uint16 getMoghouseFlag(); void setMoghouseFlag(uint16 flag); - bool needToZone(sol::object const& arg0); + bool needToZone(const sol::object& arg0); // Object Identification uint32 getID(); @@ -127,18 +127,18 @@ class CLuaBaseEntity uint8 getCurrentAction(); bool canUseAbilities(); - void lookAt(sol::object const& arg0, sol::object const& arg1, sol::object const& arg2); - void facePlayer(CLuaBaseEntity* PLuaBaseEntity, sol::object const& nonGlobal); + void lookAt(const sol::object& arg0, const sol::object& arg1, const sol::object& arg2); + void facePlayer(CLuaBaseEntity* PLuaBaseEntity, const sol::object& nonGlobal); void clearTargID(); bool atPoint(sol::variadic_args va); // is at given point - void pathTo(float x, float y, float z, sol::object const& flags); // set new path to point without changing action - bool pathThrough(sol::table const& pointsTable, sol::object const& flagsObj); // walk at normal speed through the given points + void pathTo(float x, float y, float z, const sol::object& flags); // set new path to point without changing action + bool pathThrough(const sol::table& pointsTable, const sol::object& flagsObj); // walk at normal speed through the given points bool isFollowingPath(); // checks if the entity is following a path - void clearPath(sol::object const& pauseObj); // removes current pathfind and stops moving + void clearPath(const sol::object& pauseObj); // removes current pathfind and stops moving void continuePath(); // resumes previous pathfind if it was paused float checkDistance(sol::variadic_args va); // Check Distance and returns distance number - void wait(sol::object const& milliseconds); // make the npc wait a number of ms and then back into roam + void wait(const sol::object& milliseconds); // make the npc wait a number of ms and then back into roam void follow(CLuaBaseEntity* target, uint8 followType); // makes an npc follow or runaway from another target void unfollow(); // makes an npc stop following // int32 WarpTo(lua_Stat* L); // warp to the given point -- These don't exist, breaking them just in case someone uncomments @@ -146,16 +146,16 @@ class CLuaBaseEntity // int32 LimitDistance(lua_Stat* L); // limits the current path distance to given max distance void setCarefulPathing(bool careful); - void openDoor(sol::object const& seconds); - void closeDoor(sol::object const& seconds); + void openDoor(const sol::object& seconds); + void closeDoor(const sol::object& seconds); void setElevator(uint8 id, uint32 lowerDoor, uint32 upperDoor, uint32 elevatorId, bool reversed); void addPeriodicTrigger(uint8 id, uint16 period, uint16 minOffset); // Adds a periodic trigger to the NPC that allows time based scripting - void showNPC(sol::object const& seconds); - void hideNPC(sol::object const& seconds); - void updateNPCHideTime(sol::object const& seconds); // Updates the length of time a NPC remains hidden, if shorter than the original hide time. + void showNPC(const sol::object& seconds); + void hideNPC(const sol::object& seconds); + void updateNPCHideTime(const sol::object& seconds); // Updates the length of time a NPC remains hidden, if shorter than the original hide time. - uint8 getWeather(sol::object const& ignoreScholar); + uint8 getWeather(const sol::object& ignoreScholar); void setWeather(uint8 weatherType); // Set Weather condition (GM COMMAND) // PC Instructions @@ -168,13 +168,13 @@ class CLuaBaseEntity // Location and Positioning int16 getWorldAngle(sol::variadic_args va); // return angle (rot) between two points (vector from a to b), aligned to absolute cardinal degree - int16 getFacingAngle(CLuaBaseEntity const* target); // return angle between entity rot and target pos, aligned to number of degrees of difference - bool isFacing(CLuaBaseEntity const* target, sol::object const& angleArg); // true if you are facing the target - bool isInfront(CLuaBaseEntity const* target, sol::object const& angleArg); // true if you're infront of the input target - bool isBehind(CLuaBaseEntity const* target, sol::object const& angleArg); // true if you're behind the input target - bool isBeside(CLuaBaseEntity const* target, sol::object const& angleArg); // true if you're to the side of the input target + int16 getFacingAngle(const CLuaBaseEntity* target); // return angle between entity rot and target pos, aligned to number of degrees of difference + bool isFacing(const CLuaBaseEntity* target, const sol::object& angleArg); // true if you are facing the target + bool isInfront(const CLuaBaseEntity* target, const sol::object& angleArg); // true if you're infront of the input target + bool isBehind(const CLuaBaseEntity* target, const sol::object& angleArg); // true if you're behind the input target + bool isBeside(const CLuaBaseEntity* target, const sol::object& angleArg); // true if you're to the side of the input target - auto getZone(sol::object const& arg0) -> std::optional; + auto getZone(const sol::object& arg0) -> std::optional; uint16 getZoneID(); auto getZoneName() -> std::string; bool hasVisitedZone(uint16 zone); @@ -184,7 +184,7 @@ class CLuaBaseEntity bool isInMogHouse(); uint32 getPlayerTriggerAreaInZone(); - void updateToEntireZone(uint8 statusID, uint8 animation, sol::object const& matchTime); // Forces an update packet to update the NPC entity zone-wide + void updateToEntireZone(uint8 statusID, uint8 animation, const sol::object& matchTime); // Forces an update packet to update the NPC entity zone-wide void sendEntityUpdateToPlayer(CLuaBaseEntity* entityToUpdate, uint8 entityUpdate, uint8 updateMask); void sendEmptyEntityUpdateToPlayer(CLuaBaseEntity* entityToUpdate); @@ -202,55 +202,55 @@ class CLuaBaseEntity void setPos(sol::variadic_args va); void warp(); - void teleport(std::map pos, sol::object const& arg1); // Set Entity position (without entity despawn/spawn packets) + void teleport(std::map pos, const sol::object& arg1); // Set Entity position (without entity despawn/spawn packets) - void addTeleport(uint8 teleType, uint32 bitval, sol::object const& setval); // Add new teleport means to char unlocks - uint32 getTeleport(uint8 type, sol::object const& abysseaRegionObj); // Get unlocked teleport means + void addTeleport(uint8 teleType, uint32 bitval, const sol::object& setval); // Add new teleport means to char unlocks + uint32 getTeleport(uint8 type, const sol::object& abysseaRegionObj); // Get unlocked teleport means auto getTeleportTable(uint8 type) -> sol::table; - bool hasTeleport(uint8 tType, uint8 bit, sol::object const& arg2); - void setTeleportMenu(uint16 type, sol::object const& teleportObj); + bool hasTeleport(uint8 tType, uint8 bit, const sol::object& arg2); + void setTeleportMenu(uint16 type, const sol::object& teleportObj); auto getTeleportMenu(uint8 type) -> sol::table; void setHomePoint(); void resetPlayer(const char* charName); - void goToEntity(uint32 targetID, sol::object const& option); - bool gotoPlayer(std::string const& playerName); - bool bringPlayer(std::string const& playerName); + void goToEntity(uint32 targetID, const sol::object& option); + bool gotoPlayer(const std::string& playerName); + bool bringPlayer(const std::string& playerName); // Items uint16 getEquipID(SLOTTYPE slot); auto getEquippedItem(uint8 slot) -> std::optional; - bool hasItem(uint16 itemID, sol::object const& location); + bool hasItem(uint16 itemID, const sol::object& location); uint32 getItemCount(uint16 itemID); bool addItem(sol::variadic_args va); - bool delItem(uint16 itemID, int32 quantity, sol::object const& containerID); - bool delContainerItems(sol::object const& containerID); + bool delItem(uint16 itemID, int32 quantity, const sol::object& containerID); + bool delContainerItems(const sol::object& containerID); bool addUsedItem(uint16 itemID); - bool addTempItem(uint16 itemID, sol::object const& arg1); + bool addTempItem(uint16 itemID, const sol::object& arg1); uint8 getWornUses(uint16 itemID); // Check if the item is already worn uint8 incrementItemWear(uint16 itemID); // Increment the item's worn value and returns it - auto findItem(uint16 itemID, sol::object const& location) -> std::optional; // Like hasItem, but returns the item object (nil if not found) + auto findItem(uint16 itemID, const sol::object& location) -> std::optional; // Like hasItem, but returns the item object (nil if not found) - void createShop(uint8 size, sol::object const& arg1); - void addShopItem(uint16 itemID, double rawPrice, sol::object const& arg2, sol::object const& arg3); + void createShop(uint8 size, const sol::object& arg1); + void addShopItem(uint16 itemID, double rawPrice, const sol::object& arg2, const sol::object& arg3); auto getCurrentGPItem(uint8 guildID) -> std::tuple; - bool breakLinkshell(std::string const& lsname); - bool addLinkpearl(std::string const& lsname, bool equip); + bool breakLinkshell(const std::string& lsname); + bool addLinkpearl(const std::string& lsname, bool equip); - auto addSoulPlate(std::string const& name, uint16 mobFamily, uint8 zeni, uint16 skillIndex, uint8 fp) -> std::optional; + auto addSoulPlate(const std::string& name, uint16 mobFamily, uint8 zeni, uint16 skillIndex, uint8 fp) -> std::optional; // Trading uint8 getContainerSize(uint8 locationID); void changeContainerSize(uint8 locationID, int8 newSize); // Increase/Decreases container size - uint8 getFreeSlotsCount(sol::object const& locID); // Gets value of free slots in Entity inventory + uint8 getFreeSlotsCount(const sol::object& locID); // Gets value of free slots in Entity inventory void confirmTrade(); // Complete trade with an npc, only removing confirmed items void tradeComplete(); // Complete trade with an npc auto getTrade() -> std::optional; // Equipping - bool canEquipItem(uint16 itemID, sol::object const& chkLevel); - void equipItem(uint16 itemID, sol::object const& container); + bool canEquipItem(uint16 itemID, const sol::object& chkLevel); + void equipItem(uint16 itemID, const sol::object& container); void unequipItem(uint8 itemID); void setEquipBlock(uint16 equipBlock); @@ -266,7 +266,7 @@ class CLuaBaseEntity // Storing auto getStorageItem(uint8 container, uint8 slotID, uint8 equipID) -> std::optional; - uint8 storeWithPorterMoogle(uint16 slipId, sol::table const& extraTable, sol::table const& storableItemIdsTable); + uint8 storeWithPorterMoogle(uint16 slipId, const sol::table& extraTable, const sol::table& storableItemIdsTable); auto getRetrievableItemsForSlip(uint16 slipId) -> sol::table; void retrieveItemFromSlip(uint16 slipId, uint16 itemId, uint16 extraId, uint8 extraData); @@ -275,10 +275,10 @@ class CLuaBaseEntity uint8 getGender(); auto getName() -> std::string; auto getPacketName() -> std::string; - void renameEntity(std::string const& newName, sol::object const& arg2); + void renameEntity(const std::string& newName, const sol::object& arg2); void hideName(bool isHidden); uint16 getModelId(); - void setModelId(uint16 modelId, sol::object const& slotObj); + void setModelId(uint16 modelId, const sol::object& slotObj); uint16 getCostume(); void setCostume(uint16 costume); uint16 getCostume2(); @@ -324,7 +324,7 @@ class CLuaBaseEntity uint8 getSpeed(); void setSpeed(uint8 speedVal); - uint32 getPlaytime(sol::object const& shouldUpdate); + uint32 getPlaytime(const sol::object& shouldUpdate); int32 getTimeCreated(); // Player Jobs and Levels @@ -342,7 +342,7 @@ class CLuaBaseEntity void setsLevel(uint8 slevel); // sets the character's subjob level uint8 getLevelCap(); // genkai void setLevelCap(uint8 cap); - uint8 levelRestriction(sol::object const& level); // Establish/return current level restriction + uint8 levelRestriction(const sol::object& level); // Establish/return current level restriction void addJobTraits(uint8 jobID, uint8 level); // Monstrosity @@ -360,10 +360,10 @@ class CLuaBaseEntity void setTitle(uint16 titleID); void delTitle(uint16 titleID); - uint16 getFame(sol::object const& areaObj); - void addFame(sol::object const& areaObj, uint16 fame); - void setFame(sol::object const& areaObj, uint16 fame); - uint8 getFameLevel(sol::object const& areaObj); // Gets Fame Level for specified nation + uint16 getFame(const sol::object& areaObj); + void addFame(const sol::object& areaObj, uint16 fame); + void setFame(const sol::object& areaObj, uint16 fame); + uint8 getFameLevel(const sol::object& areaObj); // Gets Fame Level for specified nation uint8 getRank(uint8 nation); void setRank(uint8 rank); @@ -380,23 +380,23 @@ class CLuaBaseEntity void addMission(uint8 missionLogID, uint16 missionID); void delMission(uint8 missionLogID, uint16 missionID); - uint16 getCurrentMission(sol::object const& missionLogObj); + uint16 getCurrentMission(const sol::object& missionLogObj); bool hasCompletedMission(uint8 missionLogID, uint16 missionID); void completeMission(uint8 missionLogID, uint16 missionID); - void setMissionStatus(uint8 missionLogID, sol::object const& arg2Obj, sol::object const& arg3Obj); - uint32 getMissionStatus(uint8 missionLogID, sol::object const& missionStatusPosObj); + void setMissionStatus(uint8 missionLogID, const sol::object& arg2Obj, const sol::object& arg3Obj); + uint32 getMissionStatus(uint8 missionLogID, const sol::object& missionStatusPosObj); - void setEminenceCompleted(uint16 recordID, sol::object const& arg1, sol::object const& arg2); + void setEminenceCompleted(uint16 recordID, const sol::object& arg1, const sol::object& arg2); bool getEminenceCompleted(uint16 recordID); uint16 getNumEminenceCompleted(); - bool setEminenceProgress(uint16 recordID, uint32 progress, sol::object const& arg2); + bool setEminenceProgress(uint16 recordID, uint32 progress, const sol::object& arg2); auto getEminenceProgress(uint16 recordID) -> std::optional; bool hasEminenceRecord(uint16 recordID); - void triggerRoeEvent(uint8 eventNum, sol::object const& reqTable); + void triggerRoeEvent(uint8 eventNum, const sol::object& reqTable); void setUnityLeader(uint8 leaderID); uint8 getUnityLeader(); - auto getUnityRank(sol::object const& unityObj) -> std::optional; + auto getUnityRank(const sol::object& unityObj) -> std::optional; auto getClaimedDeedMask() -> sol::table; void toggleReceivedDeedRewards(); void setClaimedDeed(uint16 deedBitNum); @@ -437,10 +437,10 @@ class CLuaBaseEntity void setGil(int32 amount); bool delGil(int32 gil); - int32 getCurrency(std::string const& currencyType); - void addCurrency(std::string const& currencyType, int32 amount, sol::object const& maxObj); - void setCurrency(std::string const& currencyType, int32 amount); - void delCurrency(std::string const& currencyType, int32 amount); + int32 getCurrency(const std::string& currencyType); + void addCurrency(const std::string& currencyType, int32 amount, const sol::object& maxObj); + void setCurrency(const std::string& currencyType, int32 amount); + void delCurrency(const std::string& currencyType, int32 amount); int32 getCP(); // Conquest points, not to be confused with Capacity Points void addCP(int32 cp); @@ -467,8 +467,8 @@ class CLuaBaseEntity void setMaxHP(int32 value); // Set max hp of Entity to value int32 restoreHP(int32 restoreAmt); // Modify hp of Entity, but check if alive first void delHP(int32 delAmt); // Decrease hp of Entity - void takeDamage(int32 damage, sol::object const& attacker, sol::object const& atkType, - sol::object const& dmgType, sol::object const& flags); // Takes damage from the provided attacker + void takeDamage(int32 damage, const sol::object& attacker, const sol::object& atkType, + const sol::object& dmgType, const sol::object& flags); // Takes damage from the provided attacker void hideHP(bool value); int32 getDeathType(); // Returns Death Type (for Abyssea) void setDeathType(int32 value); // Sets Death Type (for Abyssea) @@ -505,7 +505,7 @@ class CLuaBaseEntity bool hasLearnedWeaponskill(uint8 wsUnlockId); void delLearnedWeaponskill(uint8 wsUnlockId); - void trySkillUp(uint8 skill, uint8 level, sol::object const& forceSkillUpObj, sol::object const& useSubSkillObj); + void trySkillUp(uint8 skill, uint8 level, const sol::object& forceSkillUpObj, const sol::object& useSubSkillObj); bool addWeaponSkillPoints(uint8 slotID, uint16 points); @@ -526,7 +526,7 @@ class CLuaBaseEntity // Parties and Alliances auto getParty() -> sol::table; auto getPartyWithTrusts() -> sol::table; - uint8 getPartySize(sol::object const& arg0); + uint8 getPartySize(const sol::object& arg0); bool hasPartyJob(uint8 job); auto getPartyMember(uint8 member, uint8 allianceparty) -> std::optional; auto getPartyLeader() -> std::optional; @@ -547,7 +547,7 @@ class CLuaBaseEntity uint8 checkSoloPartyAlliance(); // Check if Player is in Party or Alliance (0=Solo 1=Party 2=Alliance) - bool checkKillCredit(CLuaBaseEntity* PLuaBaseEntity, sol::object const& minRange); + bool checkKillCredit(CLuaBaseEntity* PLuaBaseEntity, const sol::object& minRange); uint8 checkDifficulty(CLuaBaseEntity* PLuaBaseEntity); @@ -564,9 +564,9 @@ class CLuaBaseEntity // Battlefields auto getBattlefield() -> std::optional; // returns CBattlefield* or nullptr if not available int32 getBattlefieldID(); // returns entity->PBattlefield->GetID() or -1 if not available - uint8 registerBattlefield(sol::object const& arg0, sol::object const& arg1, sol::object const& arg2, sol::object const& arg3); // attempt to register a battlefield, returns BATTLEFIELD_RETURNCODE + uint8 registerBattlefield(const sol::object& arg0, const sol::object& arg1, const sol::object& arg2, const sol::object& arg3); // attempt to register a battlefield, returns BATTLEFIELD_RETURNCODE bool battlefieldAtCapacity(int battlefieldID); // returns 1 if this battlefield is full - bool enterBattlefield(sol::object const& area); + bool enterBattlefield(const sol::object& area); bool leaveBattlefield(uint8 leavecode); bool isInDynamis(); void setEnteredBattlefield(bool entered); @@ -582,9 +582,9 @@ class CLuaBaseEntity void sendTractor(float xPos, float yPos, float zPos, uint8 rotation); void allowSendRaisePrompt(); - void countdown(sol::object const& secondsObj); - void objectiveUtility(sol::object const& obj); - void enableEntities(sol::object const& obj); + void countdown(const sol::object& secondsObj); + void objectiveUtility(const sol::object& obj); + void enableEntities(const sol::object& obj); void independentAnimation(CLuaBaseEntity* PTarget, uint16 animId, uint8 mode); void engage(uint16 requestedTarget); @@ -593,14 +593,14 @@ class CLuaBaseEntity void timer(int ms, sol::function func); // execute lua closure after some time void queue(int ms, sol::function func); void addRecast(uint8 recastCont, uint16 recastID, uint32 duration); - bool hasRecast(uint8 rType, uint16 recastID, sol::object const& arg2); + bool hasRecast(uint8 rType, uint16 recastID, const sol::object& arg2); void resetRecast(uint8 rType, uint16 recastID); // Reset one recast ID void resetRecasts(); // Reset recasts for the caller - void addListener(std::string const& eventName, std::string const& identifier, sol::function const& func); - void removeListener(std::string const& identifier); - void triggerListener(std::string const& eventName, sol::variadic_args args); - bool hasListener(std::string const& eventName); + void addListener(const std::string& eventName, const std::string& identifier, const sol::function& func); + void removeListener(const std::string& identifier); + void triggerListener(const std::string& eventName, sol::variadic_args args); + bool hasListener(const std::string& eventName); auto getEntity(uint16 targetID) -> std::optional; bool canChangeState(); @@ -622,8 +622,8 @@ class CLuaBaseEntity float checkLiementAbsorb(uint16 damageType); // return 1.0 if did not absorb, return >= -1.0 if did absorb // Enmity - int32 getCE(CLuaBaseEntity const* target); - int32 getVE(CLuaBaseEntity const* target); + int32 getCE(const CLuaBaseEntity* target); + int32 getVE(const CLuaBaseEntity* target); void setCE(CLuaBaseEntity* target, uint16 amount); void setVE(CLuaBaseEntity* target, uint16 amount); void addEnmity(CLuaBaseEntity* PEntity, int32 CE, int32 VE); // Add specified amount of enmity (target, CE, VE) @@ -631,9 +631,9 @@ class CLuaBaseEntity void updateEnmity(CLuaBaseEntity* PEntity); void transferEnmity(CLuaBaseEntity* entity, uint8 percent, float range); void updateEnmityFromDamage(CLuaBaseEntity* PEntity, int32 damage); // Adds Enmity to player for specified mob for the damage specified - void updateEnmityFromCure(CLuaBaseEntity* PEntity, int32 amount, sol::object const& fixedCE, sol::object const& fixedVE); + void updateEnmityFromCure(CLuaBaseEntity* PEntity, int32 amount, const sol::object& fixedCE, const sol::object& fixedVE); void resetEnmity(CLuaBaseEntity* PEntity); - void updateClaim(sol::object const& entity); + void updateClaim(const sol::object& entity); bool hasEnmity(); auto getNotorietyList() -> sol::table; void setClaimable(bool claimable); @@ -643,23 +643,23 @@ class CLuaBaseEntity // Status Effects bool addStatusEffect(sol::variadic_args va); bool addStatusEffectEx(sol::variadic_args va); - auto getStatusEffect(uint16 StatusID, sol::object const& SubType) -> std::optional; + auto getStatusEffect(uint16 StatusID, const sol::object& SubType) -> std::optional; auto getStatusEffects() -> sol::table; int16 getStatusEffectElement(uint16 statusId); - bool canGainStatusEffect(uint16 effect, sol::object const& powerObj); - bool hasStatusEffect(uint16 StatusID, sol::object const& SubType); + bool canGainStatusEffect(uint16 effect, const sol::object& powerObj); + bool hasStatusEffect(uint16 StatusID, const sol::object& SubType); bool hasStatusEffectByFlag(uint16 StatusID); uint8 countEffect(uint16 StatusID); // Gets the number of effects of a specific type on the entity uint8 countEffectWithFlag(uint32 flag); // Gets the number of effects with a flag on the entity - bool delStatusEffect(uint16 StatusID, sol::object const& SubType); - void delStatusEffectsByFlag(uint32 flag, sol::object const& silent); + bool delStatusEffect(uint16 StatusID, const sol::object& SubType); + void delStatusEffectsByFlag(uint32 flag, const sol::object& silent); bool delStatusEffectSilent(uint16 StatusID); // Removes Status Effect, suppresses message uint16 eraseStatusEffect(); uint8 eraseAllStatusEffect(); - int32 dispelStatusEffect(sol::object const& flagObj); - uint8 dispelAllStatusEffect(sol::object const& flagObj); - uint16 stealStatusEffect(CLuaBaseEntity* PTargetEntity, sol::object const& flagObj); + int32 dispelStatusEffect(const sol::object& flagObj); + uint8 dispelAllStatusEffect(const sol::object& flagObj); + uint16 stealStatusEffect(CLuaBaseEntity* PTargetEntity, const sol::object& flagObj); void addMod(uint16 type, int16 amount); int16 getMod(uint16 modID); @@ -675,15 +675,15 @@ class CLuaBaseEntity void doWildCard(CLuaBaseEntity* PEntity, uint8 total); bool doRandomDeal(CLuaBaseEntity* PTarget); bool addCorsairRoll(uint8 casterJob, uint8 bustDuration, uint16 effectID, uint16 power, uint32 tick, uint32 duration, - sol::object const& arg6, sol::object const& arg7, sol::object const& arg8); + const sol::object& arg6, const sol::object& arg7, const sol::object& arg8); bool hasCorsairEffect(); bool hasBustEffect(uint16 id); // Checks to see if a character has a specified busted corsair roll uint8 numBustEffects(); // Gets the number of bust effects on the player uint16 healingWaltz(); bool addBardSong(CLuaBaseEntity* PEntity, uint16 effectID, uint16 power, uint16 tick, - uint16 duration, uint16 SubType, uint16 subPower, uint16 tier); + uint16 duration, uint16 SubType, uint16 subPower, uint16 tier); - void charm(CLuaBaseEntity const* target, sol::object const& p0); + void charm(const CLuaBaseEntity* target, const sol::object& p0); void uncharm(); uint8 addBurden(uint8 element, uint8 burden); @@ -726,24 +726,24 @@ class CLuaBaseEntity auto getWSSkillchainProp() -> std::tuple; // returns weapon skill's skillchain properties (up to 3) int32 takeWeaponskillDamage(CLuaBaseEntity* attacker, int32 damage, uint8 atkType, uint8 dmgType, uint8 slot, bool primary, - float tpMultiplier, uint16 bonusTP, float targetTPMultiplier); + float tpMultiplier, uint16 bonusTP, float targetTPMultiplier); int32 takeSpellDamage(CLuaBaseEntity* caster, CLuaSpell* spell, int32 damage, uint8 atkType, uint8 dmgType); int32 takeSwipeLungeDamage(CLuaBaseEntity* caster, int32 damage, uint8 atkType, uint8 dmgType); int32 checkDamageCap(int32 damage); // Pets and Automations - void spawnPet(sol::object const& arg0); + void spawnPet(const sol::object& arg0); void despawnPet(); auto spawnTrust(uint16 trustId) -> std::optional; void clearTrusts(); uint32 getTrustID(); void trustPartyMessage(uint32 message_id); - auto addSimpleGambit(uint16 targ, uint16 cond, uint32 condition_arg, uint16 react, uint16 select, uint32 selector_arg, sol::object const& retry) -> std::string; - void removeSimpleGambit(std::string const& id); + auto addSimpleGambit(uint16 targ, uint16 cond, uint32 condition_arg, uint16 react, uint16 select, uint32 selector_arg, const sol::object& retry) -> std::string; + void removeSimpleGambit(const std::string& id); void removeAllSimpleGambits(); - void setTrustTPSkillSettings(uint16 trigger, uint16 select, sol::object const& value); + void setTrustTPSkillSettings(uint16 trigger, uint16 select, const sol::object& value); bool hasValidJugPetItem(); @@ -755,11 +755,11 @@ class CLuaBaseEntity bool isAvatar(); auto getMaster() -> std::optional; uint8 getPetElement(); - void setPet(sol::object const& petObj); + void setPet(const sol::object& petObj); uint8 getMinimumPetLevel(); // Returns the minimum level of the pet, such as level 23 for Courier Carrie or 0 if non applicable. auto getPetName() -> const std::string; - void setPetName(uint8 pType, uint16 value, sol::object const& arg2); + void setPetName(uint8 pType, uint16 value, const sol::object& arg2); void registerChocobo(uint32 value); void petAttack(CLuaBaseEntity* PEntity); @@ -782,7 +782,7 @@ class CLuaBaseEntity auto getAttachment(uint8 slotId) -> std::optional; auto getAttachments() -> sol::table; void updateAttachments(); - void reduceBurden(float percentReduction, sol::object const& intReductionObj); + void reduceBurden(float percentReduction, const sol::object& intReductionObj); bool isExceedingElementalCapacity(); auto getAllRuneEffects() -> sol::table; @@ -804,15 +804,15 @@ class CLuaBaseEntity uint8 getModelSize(); void setMeleeRange(float range); - void setMobFlags(uint32 flags, sol::object const& mobId); // Used to manipulate the mob's flags, such as changing size. + void setMobFlags(uint32 flags, const sol::object& mobId); // Used to manipulate the mob's flags, such as changing size. uint32 getMobFlags(); void setNpcFlags(uint32 flags); - void spawn(sol::object const& despawnSec, sol::object const& respawnSec); + void spawn(const sol::object& despawnSec, const sol::object& respawnSec); bool isSpawned(); auto getSpawnPos() -> std::map; - void setSpawn(float x, float y, float z, sol::object const& rot); + void setSpawn(float x, float y, float z, const sol::object& rot); uint32 getRespawnTime(); void setRespawnTime(uint32 seconds); @@ -861,8 +861,8 @@ class CLuaBaseEntity bool actionQueueEmpty(); - void castSpell(sol::object const& spell, sol::object const& entity); // forces a mob to cast a spell (parameter = spell ID, otherwise picks a spell from its list) - void useJobAbility(uint16 skillID, sol::object const& pet); // forces a job ability use (players/pets only) + void castSpell(const sol::object& spell, const sol::object& entity); // forces a mob to cast a spell (parameter = spell ID, otherwise picks a spell from its list) + void useJobAbility(uint16 skillID, const sol::object& pet); // forces a job ability use (players/pets only) void useMobAbility(sol::variadic_args va); // forces a mob to use a mobability (parameter = skill ID) auto getAbilityDistance(uint16 skillID) -> float; // Returns the specified distance for mob skill bool hasTPMoves(); @@ -878,7 +878,7 @@ class CLuaBaseEntity uint32 getPool(); // Returns a mobs pool ID. If entity is not a mob, returns nil. uint32 getDropID(); void setDropID(uint32 dropID); - void addTreasure(uint16 itemID, sol::object const& arg1, sol::object const& arg2); + void addTreasure(uint16 itemID, const sol::object& arg1, const sol::object& arg2); uint16 getStealItem(); uint16 getDespoilItem(); // gets ItemID of droplist despoil item from mob (steal item if no despoil item) uint16 getDespoilDebuff(uint16 itemID); // gets the status effect id to apply to the mob on successful despoil @@ -895,7 +895,7 @@ class CLuaBaseEntity uint32 getHistory(uint8 index); auto getChocoboRaisingInfo() -> sol::table; - bool setChocoboRaisingInfo(sol::table const& table); + bool setChocoboRaisingInfo(const sol::table& table); bool deleteRaisedChocobo(); void clearActionQueue(); diff --git a/src/map/lua/lua_battlefield.cpp b/src/map/lua/lua_battlefield.cpp index 5f70b1660d2..949359e9309 100644 --- a/src/map/lua/lua_battlefield.cpp +++ b/src/map/lua/lua_battlefield.cpp @@ -204,7 +204,7 @@ uint8 CLuaBattlefield::getStatus() return m_PLuaBattlefield->GetStatus(); } -uint64_t CLuaBattlefield::getLocalVar(std::string const& name) +uint64_t CLuaBattlefield::getLocalVar(const std::string& name) { return m_PLuaBattlefield->GetLocalVar(name); } @@ -226,7 +226,7 @@ uint32 CLuaBattlefield::getArmouryCrate() return m_PLuaBattlefield->GetArmouryCrate(); } -void CLuaBattlefield::setLocalVar(std::string const& name, uint64_t value) +void CLuaBattlefield::setLocalVar(const std::string& name, uint64_t value) { m_PLuaBattlefield->SetLocalVar(name, value); } @@ -246,7 +246,7 @@ void CLuaBattlefield::setWipeTime(uint32 seconds) m_PLuaBattlefield->SetWipeTime(get_server_start_time() + std::chrono::seconds(seconds)); } -void CLuaBattlefield::setRecord(std::string const& name, uint32 seconds) +void CLuaBattlefield::setRecord(const std::string& name, uint32 seconds) { m_PLuaBattlefield->SetRecord(name, std::chrono::seconds(seconds), m_PLuaBattlefield->GetPlayerCount()); } @@ -261,8 +261,7 @@ std::optional CLuaBattlefield::insertEntity(uint16 targid, bool BATTLEFIELDMOBCONDITION conditions = static_cast(0); ENTITYTYPE filter = static_cast(0x1F); - auto* PEntity = - ally ? mobutils::InstantiateAlly(targid, m_PLuaBattlefield->GetZoneID()) : m_PLuaBattlefield->GetZone()->GetEntity(targid, filter); + auto* PEntity = ally ? mobutils::InstantiateAlly(targid, m_PLuaBattlefield->GetZoneID()) : m_PLuaBattlefield->GetZone()->GetEntity(targid, filter); if (PEntity) { @@ -291,7 +290,7 @@ void CLuaBattlefield::lose() m_PLuaBattlefield->CanCleanup(true); } -void CLuaBattlefield::addGroups(sol::table const& groups, bool hasMultipleArenas) +void CLuaBattlefield::addGroups(const sol::table& groups, bool hasMultipleArenas) { // get the global function "applyMixins" sol::function applyMixins = lua["applyMixins"]; @@ -307,7 +306,7 @@ void CLuaBattlefield::addGroups(sol::table const& groups, bool hasMultipleArenas if (hasMultipleArenas) { std::set entityIds; - for (auto const& entry : groups) + for (const auto& entry : groups) { QueryByNameResult_t groupEntities; sol::table groupData = entry.second.as(); @@ -316,7 +315,7 @@ void CLuaBattlefield::addGroups(sol::table const& groups, bool hasMultipleArenas if (groupMobs.valid()) { auto mobNames = groupMobs.get>(); - for (std::string const& name : mobNames) + for (const std::string& name : mobNames) { const QueryByNameResult_t& result = m_PLuaBattlefield->GetZone()->queryEntitiesByName(name); for (CBaseEntity* entity : result) @@ -371,7 +370,7 @@ void CLuaBattlefield::addGroups(sol::table const& groups, bool hasMultipleArenas std::set spawnedEntities; std::vector battlefieldGroups; - for (auto const& entry : groups) + for (const auto& entry : groups) { sol::table groupData = entry.second.as(); @@ -382,7 +381,7 @@ void CLuaBattlefield::addGroups(sol::table const& groups, bool hasMultipleArenas if (groupMobs.valid()) { auto mobNames = groupMobs.get>(); - for (std::string const& name : mobNames) + for (const std::string& name : mobNames) { const QueryByNameResult_t& result = m_PLuaBattlefield->GetZone()->queryEntitiesByName(name); for (CBaseEntity* entity : result) @@ -565,7 +564,7 @@ void CLuaBattlefield::addGroups(sol::table const& groups, bool hasMultipleArenas return; } - for (auto const& modifier : mods.get()) + for (const auto& modifier : mods.get()) { PMob->setModifier(modifier.first.as(), modifier.second.as()); } @@ -585,7 +584,7 @@ void CLuaBattlefield::addGroups(sol::table const& groups, bool hasMultipleArenas return; } - for (auto const& modifier : mobMods.get()) + for (const auto& modifier : mobMods.get()) { PMob->setMobMod(modifier.first.as(), modifier.second.as()); } diff --git a/src/map/lua/lua_battlefield.h b/src/map/lua/lua_battlefield.h index 23fd2d7f806..b5d36adce9d 100644 --- a/src/map/lua/lua_battlefield.h +++ b/src/map/lua/lua_battlefield.h @@ -60,7 +60,7 @@ class CLuaBattlefield auto getAllies() -> sol::table; auto getRecord() -> std::tuple; uint8 getStatus(); - uint64_t getLocalVar(std::string const& name); + uint64_t getLocalVar(const std::string& name); uint32 getLastTimeUpdate(); auto getInitiator() -> std::pair; uint32 getArmouryCrate(); @@ -68,14 +68,14 @@ class CLuaBattlefield void setLastTimeUpdate(uint32 seconds); void setTimeLimit(uint32 seconds); void setWipeTime(uint32 seconds); - void setRecord(std::string const& name, uint32 seconds); + void setRecord(const std::string& name, uint32 seconds); void setStatus(uint8 status); - void setLocalVar(std::string const& name, uint64_t value); + void setLocalVar(const std::string& name, uint64_t value); auto insertEntity(uint16 targid, bool ally, bool inBattlefield) -> std::optional; bool cleanup(bool cleanup); void win(); void lose(); - void addGroups(sol::table const& groups, bool hasMultipleArenas); + void addGroups(const sol::table& groups, bool hasMultipleArenas); bool operator==(const CLuaBattlefield& other) const { diff --git a/src/map/lua/lua_instance.cpp b/src/map/lua/lua_instance.cpp index 660a8b02f22..4819fe313b1 100644 --- a/src/map/lua/lua_instance.cpp +++ b/src/map/lua/lua_instance.cpp @@ -154,7 +154,7 @@ uint32 CLuaInstance::getWipeTime() return static_cast(time_ms); } -std::optional CLuaInstance::getEntity(uint16 targid, sol::object const& filterObj) +std::optional CLuaInstance::getEntity(uint16 targid, const sol::object& filterObj) { uint8 filter = -1; if (filterObj.is()) @@ -177,7 +177,7 @@ uint32 CLuaInstance::getStage() return m_PLuaInstance->GetStage(); } -uint64_t CLuaInstance::getLocalVar(std::string const& name) +uint64_t CLuaInstance::getLocalVar(const std::string& name) { return m_PLuaInstance->GetLocalVar(name); } @@ -212,7 +212,7 @@ void CLuaInstance::setStage(uint32 stage) m_PLuaInstance->SetStage(stage); } -void CLuaInstance::setLocalVar(std::string const& name, uint64_t value) +void CLuaInstance::setLocalVar(const std::string& name, uint64_t value) { m_PLuaInstance->SetLocalVar(name, value); } diff --git a/src/map/lua/lua_instance.h b/src/map/lua/lua_instance.h index bbca9d334a3..4dca12d3212 100644 --- a/src/map/lua/lua_instance.h +++ b/src/map/lua/lua_instance.h @@ -58,9 +58,9 @@ class CLuaInstance uint32 getLastTimeUpdate(); uint32 getProgress(); uint32 getWipeTime(); - auto getEntity(uint16 targid, sol::object const& filterObj) -> std::optional; + auto getEntity(uint16 targid, const sol::object& filterObj) -> std::optional; uint32 getStage(); - auto getLocalVar(std::string const& name) -> uint64_t; + auto getLocalVar(const std::string& name) -> uint64_t; void setLevelCap(uint8 cap); void setLastTimeUpdate(uint32 ms); @@ -68,7 +68,7 @@ class CLuaInstance void setProgress(uint32 progress); void setWipeTime(uint32 ms); void setStage(uint32 stage); - void setLocalVar(std::string const& name, uint64_t value); + void setLocalVar(const std::string& name, uint64_t value); void fail(); bool failed(); diff --git a/src/map/lua/lua_item.cpp b/src/map/lua/lua_item.cpp index c6b58eee349..009a1061ef0 100644 --- a/src/map/lua/lua_item.cpp +++ b/src/map/lua/lua_item.cpp @@ -324,7 +324,7 @@ bool CLuaItem::isInstalled() return PFurnishing->isInstalled(); } -void CLuaItem::setSoulPlateData(std::string const& name, uint16 mobFamily, uint8 zeni, uint16 skillIndex, uint8 fp) +void CLuaItem::setSoulPlateData(const std::string& name, uint16 mobFamily, uint8 zeni, uint16 skillIndex, uint8 fp) { m_PLuaItem->setSoulPlateData(name, mobFamily, zeni, skillIndex, fp); } @@ -353,9 +353,9 @@ auto CLuaItem::getExData() -> sol::table return table; } -void CLuaItem::setExData(sol::table const& newData) +void CLuaItem::setExData(const sol::table& newData) { - for (auto const& [keyObj, valObj] : newData) + for (const auto& [keyObj, valObj] : newData) { uint8 key = keyObj.as(); uint8 val = valObj.as(); diff --git a/src/map/lua/lua_item.h b/src/map/lua/lua_item.h index 410b98c1721..afa3ade8371 100644 --- a/src/map/lua/lua_item.h +++ b/src/map/lua/lua_item.h @@ -90,11 +90,11 @@ class CLuaItem bool isInstalled(); - void setSoulPlateData(std::string const& name, uint16 mobFamily, uint8 zeni, uint16 skillIndex, uint8 fp); + void setSoulPlateData(const std::string& name, uint16 mobFamily, uint8 zeni, uint16 skillIndex, uint8 fp); auto getSoulPlateData() -> sol::table; auto getExData() -> sol::table; // NOTE: This is 0-indexed, to be in line with the underlying C++ data - void setExData(sol::table const& newData); // NOTE: This is 0-indexed, to be in line with the underlying C++ data + void setExData(const sol::table& newData); // NOTE: This is 0-indexed, to be in line with the underlying C++ data bool operator==(const CLuaItem& other) const { diff --git a/src/map/lua/lua_loot.cpp b/src/map/lua/lua_loot.cpp index 592bed326d5..27dba2c8e9e 100644 --- a/src/map/lua/lua_loot.cpp +++ b/src/map/lua/lua_loot.cpp @@ -63,7 +63,7 @@ void CLuaLootContainer::addItem(uint16 item, uint16 rate, sol::variadic_args va) * Notes : Item table is a list of tables with "item" key and an optional "weight" which defaults to 1 ************************************************************************/ -void CLuaLootContainer::addGroup(uint16 groupRate, sol::table const& items) +void CLuaLootContainer::addGroup(uint16 groupRate, const sol::table& items) { addGroupToContainer(RATE_PERCENTAGES[groupRate], items, false); } @@ -89,7 +89,7 @@ void CLuaLootContainer::addItemFixed(uint16 item, uint16 rate, sol::variadic_arg * Fixed drop rate is 0-1000. ************************************************************************/ -void CLuaLootContainer::addGroupFixed(uint16 groupRate, sol::table const& items) +void CLuaLootContainer::addGroupFixed(uint16 groupRate, const sol::table& items) { addGroupToContainer(groupRate, items, true); } @@ -103,7 +103,7 @@ void CLuaLootContainer::addItemToContainer(uint16 item, uint16 rate, sol::variad } } -void CLuaLootContainer::addGroupToContainer(uint16 groupRate, sol::table const& items, bool hasFixedRate) +void CLuaLootContainer::addGroupToContainer(uint16 groupRate, const sol::table& items, bool hasFixedRate) { DropGroup_t group(groupRate, hasFixedRate); diff --git a/src/map/lua/lua_loot.h b/src/map/lua/lua_loot.h index c3562745469..e03ec073da3 100644 --- a/src/map/lua/lua_loot.h +++ b/src/map/lua/lua_loot.h @@ -37,10 +37,10 @@ class CLuaLootContainer friend std::ostream& operator<<(std::ostream& out, const CLuaLootContainer& action); void addItem(uint16 item, uint16 rate, sol::variadic_args va); - void addGroup(uint16 groupRate, sol::table const& items); + void addGroup(uint16 groupRate, const sol::table& items); void addItemFixed(uint16 item, uint16 rate, sol::variadic_args va); - void addGroupFixed(uint16 groupRate, sol::table const& items); + void addGroupFixed(uint16 groupRate, const sol::table& items); bool operator==(const CLuaLootContainer& other) const { @@ -51,7 +51,7 @@ class CLuaLootContainer private: void addItemToContainer(uint16 item, uint16 rate, sol::variadic_args va, bool hasFixedRate); - void addGroupToContainer(uint16 groupRate, sol::table const& items, bool hasFixedRate); + void addGroupToContainer(uint16 groupRate, const sol::table& items, bool hasFixedRate); }; #endif diff --git a/src/map/lua/lua_trade_container.cpp b/src/map/lua/lua_trade_container.cpp index 8d9a1ed2708..f92fea326e0 100644 --- a/src/map/lua/lua_trade_container.cpp +++ b/src/map/lua/lua_trade_container.cpp @@ -45,7 +45,7 @@ uint32 CLuaTradeContainer::getGil() return itemID == 0xFFFF ? m_pMyTradeContainer->getQuantity(0) : 0; } -std::optional CLuaTradeContainer::getItem(sol::object const& SlotIDObj) +std::optional CLuaTradeContainer::getItem(const sol::object& SlotIDObj) { uint8 SlotID = 0; if (SlotIDObj.is()) @@ -63,7 +63,7 @@ std::optional CLuaTradeContainer::getItem(sol::object const& SlotIDObj //======================================================// -uint16 CLuaTradeContainer::getItemId(sol::object const& SlotIDObj) +uint16 CLuaTradeContainer::getItemId(const sol::object& SlotIDObj) { uint8 SlotID = 0; if (SlotIDObj.is()) @@ -83,7 +83,7 @@ uint16 CLuaTradeContainer::getItemId(sol::object const& SlotIDObj) //======================================================// -uint16 CLuaTradeContainer::getItemSubId(sol::object const& SlotIDObj) +uint16 CLuaTradeContainer::getItemSubId(const sol::object& SlotIDObj) { uint8 SlotID = 0; if (SlotIDObj.is()) @@ -139,7 +139,7 @@ bool CLuaTradeContainer::hasItemQty(uint16 itemID, uint32 quantity) //======================================================// -bool CLuaTradeContainer::confirmItem(uint16 itemID, sol::object const& amountObj) +bool CLuaTradeContainer::confirmItem(uint16 itemID, const sol::object& amountObj) { uint32 amount = amountObj.is() ? amountObj.as() : 1; @@ -164,7 +164,7 @@ bool CLuaTradeContainer::confirmItem(uint16 itemID, sol::object const& amountObj //======================================================// -bool CLuaTradeContainer::confirmSlot(uint8 slotID, sol::object const& amountObj) +bool CLuaTradeContainer::confirmSlot(uint8 slotID, const sol::object& amountObj) { uint32 amount = amountObj.is() ? amountObj.as() : 1; return m_pMyTradeContainer->setConfirmedStatus(slotID, amount); diff --git a/src/map/lua/lua_trade_container.h b/src/map/lua/lua_trade_container.h index 99741fe0c13..cdb0e4831a0 100644 --- a/src/map/lua/lua_trade_container.h +++ b/src/map/lua/lua_trade_container.h @@ -41,16 +41,16 @@ class CLuaTradeContainer friend std::ostream& operator<<(std::ostream& out, const CTradeContainer& trade); uint32 getGil(); - auto getItem(sol::object const& SlotIDObj) -> std::optional; - uint16 getItemId(sol::object const& SlotIDObj); - uint16 getItemSubId(sol::object const& SlotIDObj); + auto getItem(const sol::object& SlotIDObj) -> std::optional; + uint16 getItemId(const sol::object& SlotIDObj); + uint16 getItemSubId(const sol::object& SlotIDObj); uint32 getItemQty(uint16 itemID); bool hasItemQty(uint16 itemID, uint32 quantity); uint32 getSlotQty(uint8 slotID); // number of items in the specified slot uint32 getItemCount(); // total number of items uint8 getSlotCount(); - bool confirmItem(uint16 itemID, sol::object const& amountObj); - bool confirmSlot(uint8 slotID, sol::object const& amountObj); + bool confirmItem(uint16 itemID, const sol::object& amountObj); + bool confirmSlot(uint8 slotID, const sol::object& amountObj); void clean(); bool operator==(const CLuaTradeContainer& other) const diff --git a/src/map/lua/lua_zone.cpp b/src/map/lua/lua_zone.cpp index 3083d78c322..a6babcb69d1 100644 --- a/src/map/lua/lua_zone.cpp +++ b/src/map/lua/lua_zone.cpp @@ -79,9 +79,7 @@ void CLuaZone::resetLocalVars() void CLuaZone::registerTriggerArea(uint32 triggerAreaID, float x1, float y1, float z1, float x2, float y2, float z2) { bool circleRegion = false; - if (approximatelyEqual(x2, 0.0f) && - approximatelyEqual(y2, 0.0f) && - approximatelyEqual(z2, 0.0f)) + if (approximatelyEqual(x2, 0.0f) && approximatelyEqual(y2, 0.0f) && approximatelyEqual(z2, 0.0f)) { circleRegion = true; // Parameters were 0, we must be a circle. } @@ -282,7 +280,7 @@ auto CLuaZone::getBackgroundMusicNight() return m_pLuaZone->GetBackgroundMusicNight(); } -sol::table CLuaZone::queryEntitiesByName(std::string const& name) +sol::table CLuaZone::queryEntitiesByName(const std::string& name) { const QueryByNameResult_t& entities = m_pLuaZone->queryEntitiesByName(name); diff --git a/src/map/lua/lua_zone.h b/src/map/lua/lua_zone.h index e103fef0972..7705823e9f7 100644 --- a/src/map/lua/lua_zone.h +++ b/src/map/lua/lua_zone.h @@ -70,7 +70,7 @@ class CLuaZone void setBackgroundMusicDay(uint16 musicId); void setBackgroundMusicNight(uint16 musicId); - sol::table queryEntitiesByName(std::string const& name); + sol::table queryEntitiesByName(const std::string& name); bool operator==(const CLuaZone& other) const { diff --git a/src/map/lua/luautils.cpp b/src/map/lua/luautils.cpp index e3d32921bff..93afa66b212 100644 --- a/src/map/lua/luautils.cpp +++ b/src/map/lua/luautils.cpp @@ -107,7 +107,7 @@ #include "utils/synergyutils.h" #include "utils/zoneutils.h" -void ReportErrorToPlayer(CBaseEntity* PEntity, std::string const& message = "") noexcept +void ReportErrorToPlayer(CBaseEntity* PEntity, const std::string& message = "") noexcept { try { @@ -121,7 +121,7 @@ void ReportErrorToPlayer(CBaseEntity* PEntity, std::string const& message = "") std::string breaker = "================"; PChar->pushPacket(new CChatMessagePacket(PChar, channel, breaker.c_str())); PChar->pushPacket(new CChatMessagePacket(PChar, channel, "!!! Lua error !!!")); - for (auto const& part : split(message, "\n")) + for (const auto& part : split(message, "\n")) { auto str = replace(part, "\t", " "); PChar->pushPacket(new CChatMessagePacket(PChar, channel, str.c_str())); @@ -131,7 +131,7 @@ void ReportErrorToPlayer(CBaseEntity* PEntity, std::string const& message = "") } } } - catch (std::exception const& e) + catch (const std::exception& e) { ShowError(e.what()); } @@ -720,7 +720,7 @@ namespace luautils InteractionGlobal.lookup:addContainer(res) end )", - requireName)); + requireName)); if (!result.valid()) { @@ -783,7 +783,7 @@ namespace luautils moduleutils::TryApplyLuaModules(); } - sol::table GetCacheEntryFromFilename(std::string const& filename) + sol::table GetCacheEntryFromFilename(const std::string& filename) { TracyZoneScoped; TracyZoneString(filename); @@ -875,7 +875,7 @@ namespace luautils CacheLuaObjectFromFile(filename); } - void PopulateIDLookups(uint16 zoneId, std::string const& zoneName) + void PopulateIDLookups(uint16 zoneId, const std::string& zoneName) { TracyZoneScoped; @@ -894,7 +894,7 @@ namespace luautils { auto query = fmt::sprintf("SELECT mobname, mobid FROM mob_spawn_points " "WHERE ((mobid >> 12) & 0xFFF) = %i ORDER BY mobid ASC", - zoneId); + zoneId); auto ret = _sql->Query(query.c_str()); while (ret != SQL_ERROR && _sql->NumRows() != 0 && _sql->NextRow() == SQL_SUCCESS) { @@ -909,7 +909,7 @@ namespace luautils { auto query = fmt::sprintf("SELECT name, npcid FROM npc_list " "WHERE ((npcid >> 12) & 0xFFF) = %i ORDER BY npcid ASC", - zoneId); + zoneId); auto ret = _sql->Query(query.c_str()); while (ret != SQL_ERROR && _sql->NumRows() != 0 && _sql->NextRow() == SQL_SUCCESS) { @@ -1104,7 +1104,7 @@ namespace luautils return std::nullopt; } - std::optional GetNPCByID(uint32 npcid, sol::object const& instanceObj) + std::optional GetNPCByID(uint32 npcid, const sol::object& instanceObj) { TracyZoneScoped; @@ -1167,7 +1167,7 @@ namespace luautils return std::nullopt; } - std::optional GetMobByID(uint32 mobid, sol::object const& instanceObj) + std::optional GetMobByID(uint32 mobid, const sol::object& instanceObj) { TracyZoneScoped; @@ -1197,7 +1197,7 @@ namespace luautils return std::optional(PMob); } - std::optional GetEntityByID(uint32 entityid, sol::object const& instanceObj, sol::object const& arg3) + std::optional GetEntityByID(uint32 entityid, const sol::object& instanceObj, const sol::object& arg3) { TracyZoneScoped; @@ -1310,7 +1310,7 @@ namespace luautils } } - void SendLuaFuncStringToZone(uint16 zoneId, std::string const& str) + void SendLuaFuncStringToZone(uint16 zoneId, const std::string& str) { message::send(zoneId, str); } @@ -1586,7 +1586,7 @@ namespace luautils * Spawn a mob using mob ID * * * ************************************************************************/ - std::optional SpawnMob(uint32 mobid, sol::object const& arg2, sol::object const& arg3) + std::optional SpawnMob(uint32 mobid, const sol::object& arg2, const sol::object& arg3) { TracyZoneScoped; @@ -1642,7 +1642,7 @@ namespace luautils * * ************************************************************************/ - void DespawnMob(uint32 mobid, sol::object const& arg2) + void DespawnMob(uint32 mobid, const sol::object& arg2) { TracyZoneScoped; @@ -1677,7 +1677,7 @@ namespace luautils * * ************************************************************************/ - std::optional GetPlayerByName(std::string const& name) + std::optional GetPlayerByName(const std::string& name) { TracyZoneScoped; @@ -1740,7 +1740,7 @@ namespace luautils * * ************************************************************************/ - uint32 GetPlayerIDByName(std::string const& playerName) + uint32 GetPlayerIDByName(const std::string& playerName) { TracyZoneScoped; @@ -1995,8 +1995,7 @@ namespace luautils std::optional optInstance = std::nullopt; if (PChar->PInstance) { - filename = - std::string("./scripts/zones/") + PChar->loc.zone->getName() + "/instances/" + PChar->PInstance->GetName() + ".lua"; + filename = std::string("./scripts/zones/") + PChar->loc.zone->getName() + "/instances/" + PChar->PInstance->GetName() + ".lua"; optInstance = CLuaInstance(PChar->PInstance); } @@ -2043,8 +2042,7 @@ namespace luautils std::optional optInstance = std::nullopt; if (PChar->PInstance) { - filename = - std::string("scripts/zones/") + PChar->loc.zone->getName() + "/instances/" + PChar->PInstance->GetName() + ".lua"; + filename = std::string("scripts/zones/") + PChar->loc.zone->getName() + "/instances/" + PChar->PInstance->GetName() + ".lua"; optInstance = CLuaInstance(PChar->PInstance); } @@ -2136,7 +2134,7 @@ namespace luautils TracyZoneScoped; ShowTraceFmt("luautils::OnEventUpdate: {} ({}), id: {}, result: {}", - PChar->getName(), PChar->loc.zone->getName(), eventID, result); + PChar->getName(), PChar->loc.zone->getName(), eventID, result); EventPrep* previousPrep = PChar->eventPreparation; PChar->eventPreparation = PChar->currentEvent; @@ -2165,12 +2163,12 @@ namespace luautils return func_result.get_type() == sol::type::number ? func_result.get() : 1; } - int32 OnEventUpdate(CCharEntity* PChar, std::string const& updateString) + int32 OnEventUpdate(CCharEntity* PChar, const std::string& updateString) { TracyZoneScoped; ShowTrace("luautils::OnEventUpdate: {} ({}), string: {}", - PChar->getName(), PChar->loc.zone->getName(), updateString); + PChar->getName(), PChar->loc.zone->getName(), updateString); EventPrep* previousPrep = PChar->eventPreparation; PChar->eventPreparation = PChar->currentEvent; @@ -2204,7 +2202,7 @@ namespace luautils TracyZoneScoped; ShowTraceFmt("luautils::OnEventFinish: {} ({}), id: {}, result: {}", - PChar->getName(), PChar->loc.zone->getName(), eventID, result); + PChar->getName(), PChar->loc.zone->getName(), eventID, result); EventPrep* previousPrep = PChar->eventPreparation; PChar->eventPreparation = PChar->currentEvent; @@ -3674,7 +3672,7 @@ namespace luautils } std::tuple OnUseWeaponSkill(CBattleEntity* PChar, CBaseEntity* PMob, CWeaponSkill* wskill, uint16 tp, bool primary, action_t& action, - CBattleEntity* taChar) + CBattleEntity* taChar) { TracyZoneScoped; @@ -3989,7 +3987,7 @@ namespace luautils if (table["levels"].valid()) { - for (auto const& [keyObj, valObj] : table.get("levels")) + for (const auto& [keyObj, valObj] : table.get("levels")) { uint8 key = keyObj.as(); uint8 val = valObj.as(); @@ -3999,7 +3997,7 @@ namespace luautils if (table["instincts"].valid()) { - for (auto const& [keyObj, valObj] : table.get("instincts")) + for (const auto& [keyObj, valObj] : table.get("instincts")) { uint8 key = keyObj.as(); uint8 val = valObj.as(); @@ -4009,7 +4007,7 @@ namespace luautils if (table["variants"].valid()) { - for (auto const& [keyObj, valObj] : table.get("variants")) + for (const auto& [keyObj, valObj] : table.get("variants")) { uint8 key = keyObj.as(); uint8 val = valObj.as(); @@ -4560,12 +4558,12 @@ namespace luautils return -1; } - int32 GetServerVariable(std::string const& name) + int32 GetServerVariable(const std::string& name) { return serverutils::GetServerVar(name); } - void SetServerVariable(std::string const& name, int32 value, sol::object const& expiry) + void SetServerVariable(const std::string& name, int32 value, const sol::object& expiry) { uint32 varTimestamp = expiry.is() ? expiry.as() : 0; @@ -4578,12 +4576,12 @@ namespace luautils serverutils::SetServerVar(name, value, varTimestamp); } - int32 GetVolatileServerVariable(std::string const& varName) + int32 GetVolatileServerVariable(const std::string& varName) { return serverutils::GetVolatileServerVar(varName); } - void SetVolatileServerVariable(std::string const& varName, int32 value, sol::object const& expiry) + void SetVolatileServerVariable(const std::string& varName, int32 value, const sol::object& expiry) { uint32 varTimestamp = expiry.is() ? expiry.as() : 0; @@ -4596,13 +4594,13 @@ namespace luautils serverutils::SetVolatileServerVar(varName, value, varTimestamp); } - int32 GetCharVar(uint32 charId, std::string const& varName) + int32 GetCharVar(uint32 charId, const std::string& varName) { return charutils::FetchCharVar(charId, varName).first; } // Using the charID set a char variable on the SQL DB - void SetCharVar(uint32 charId, std::string const& varName, int32 value, sol::object const& expiry) + void SetCharVar(uint32 charId, const std::string& varName, int32 value, const sol::object& expiry) { uint32 varTimestamp = expiry.is() ? expiry.as() : 0; @@ -4615,7 +4613,7 @@ namespace luautils charutils::SetCharVar(charId, varName, value, varTimestamp); } - void ClearCharVarFromAll(std::string const& varName) + void ClearCharVarFromAll(const std::string& varName) { charutils::ClearCharVarFromAll(varName); } @@ -4996,7 +4994,7 @@ namespace luautils return PSpell ? std::optional(PSpell) : std::nullopt; } - sol::table NearLocation(sol::table const& table, float radius, float theta) + sol::table NearLocation(const sol::table& table, float radius, float theta) { TracyZoneScoped; @@ -5141,7 +5139,7 @@ namespace luautils } } - void OnPlayerVolunteer(CCharEntity* PChar, std::string const& text) + void OnPlayerVolunteer(CCharEntity* PChar, const std::string& text) { TracyZoneScoped; @@ -5303,7 +5301,7 @@ namespace luautils onStart(CLuaBaseEntity(PChar)); } - auto escape = [](std::string const& s) + auto escape = [](const std::string& s) { return fmt::format("\"{}\"", s); }; @@ -5464,7 +5462,7 @@ namespace luautils customMenuContext.erase(PChar->id); } - SendToDBoxReturnCode SendItemToDeliveryBox(std::string const& playerName, uint16 itemId, uint32 quantity, std::string senderText) + SendToDBoxReturnCode SendItemToDeliveryBox(const std::string& playerName, uint16 itemId, uint32 quantity, std::string senderText) { uint32 playerID = GetPlayerIDByName(playerName); if (playerID == 0) @@ -5535,7 +5533,7 @@ namespace luautils } } - uint16 GetItemIDByName(std::string const& name) + uint16 GetItemIDByName(const std::string& name) { uint16 id = 0; auto rset = db::preparedStmt("SELECT itemid FROM item_basic WHERE name LIKE ? OR sortname LIKE ?", name, name); @@ -5604,7 +5602,7 @@ namespace luautils if (name.empty()) { ShowWarning("Trying to spawn dynamic entity without a name! (%s - %s)", - PEntity->getName(), PZone->getName()); + PEntity->getName(), PZone->getName()); // If the name hasn't been provided, use "DefaultName" for NPCs, and whatever comes from the mob_pool for Mobs name = PEntity->name; diff --git a/src/map/lua/luautils.h b/src/map/lua/luautils.h index b2dcd3934b3..239eb94bb85 100644 --- a/src/map/lua/luautils.h +++ b/src/map/lua/luautils.h @@ -130,8 +130,8 @@ namespace luautils // Cache helpers auto getEntityCachedFunction(CBaseEntity* PEntity, std::string funcName) -> sol::function; - void CacheLuaObjectFromFile(std::string const& filename, bool overwriteCurrentEntry = false); - auto GetCacheEntryFromFilename(std::string const& filename) -> sol::table; + void CacheLuaObjectFromFile(const std::string& filename, bool overwriteCurrentEntry = false); + auto GetCacheEntryFromFilename(const std::string& filename) -> sol::table; void OnEntityLoad(CBaseEntity* PEntity); void PopulateIDLookupsByFilename(std::optional maybeFilename = std::nullopt); @@ -141,9 +141,9 @@ namespace luautils void InitInteractionGlobal(); auto GetZone(uint16 zoneId) -> std::optional; auto GetItemByID(uint32 itemId) -> std::optional; - auto GetNPCByID(uint32 npcid, sol::object const& instanceObj) -> std::optional; - auto GetMobByID(uint32 mobid, sol::object const& instanceObj) -> std::optional; - auto GetEntityByID(uint32 mobid, sol::object const& instanceObj, sol::object const& arg3) -> std::optional; + auto GetNPCByID(uint32 npcid, const sol::object& instanceObj) -> std::optional; + auto GetMobByID(uint32 mobid, const sol::object& instanceObj) -> std::optional; + auto GetEntityByID(uint32 mobid, const sol::object& instanceObj, const sol::object& arg3) -> std::optional; void WeekUpdateConquest(uint8 updateType); uint8 GetRegionOwner(uint8 type); @@ -152,18 +152,18 @@ namespace luautils uint8 GetConquestBalance(); bool IsConquestAlliance(); void SetRegionalConquestOverseers(uint8 regionID); // Update NPC Conquest Guard - void SendLuaFuncStringToZone(uint16 zoneId, std::string const& str); + void SendLuaFuncStringToZone(uint16 zoneId, const std::string& str); auto GetReadOnlyItem(uint32 id) -> std::optional; // Returns a read only lookup item object of the specified ID auto GetAbility(uint16 id) -> std::optional; auto GetSpell(uint16 id) -> std::optional; - auto SpawnMob(uint32 mobid, sol::object const& arg2, sol::object const& arg3) -> std::optional; // Spawn Mob By Mob Id - NMs, BCNM... - void DespawnMob(uint32 mobid, sol::object const& arg2); // Despawn (Fade Out) Mob By Id - auto GetPlayerByName(std::string const& name) -> std::optional; + auto SpawnMob(uint32 mobid, const sol::object& arg2, const sol::object& arg3) -> std::optional; // Spawn Mob By Mob Id - NMs, BCNM... + void DespawnMob(uint32 mobid, const sol::object& arg2); // Despawn (Fade Out) Mob By Id + auto GetPlayerByName(const std::string& name) -> std::optional; auto GetPlayerByID(uint32 pid) -> std::optional; bool PlayerHasValidSession(uint32 playerId); - uint32 GetPlayerIDByName(std::string const& name); + uint32 GetPlayerIDByName(const std::string& name); void SendToJailOffline(uint32 playerId, int8 cellId, float posX, float posY, float posZ, uint8 rot); uint32 GetSystemTime(); @@ -192,13 +192,13 @@ namespace luautils void StartElevator(uint32 ElevatorID); int16 GetElevatorState(uint8 id); // Returns -1 if elevator is not found. Otherwise, returns the uint8 state. - int32 GetServerVariable(std::string const& name); - void SetServerVariable(std::string const& name, int32 value, sol::object const& expiry); - int32 GetVolatileServerVariable(std::string const& varName); - void SetVolatileServerVariable(std::string const& varName, int32 value, sol::object const& expiry); - int32 GetCharVar(uint32 charId, std::string const& varName); // Get player var directly from SQL DB - void SetCharVar(uint32 charId, std::string const& varName, int32 value, sol::object const& expiry); // Set player var in SQL DB using charId - void ClearCharVarFromAll(std::string const& varName); // Deletes a specific player variable from all players + int32 GetServerVariable(const std::string& name); + void SetServerVariable(const std::string& name, int32 value, const sol::object& expiry); + int32 GetVolatileServerVariable(const std::string& varName); + void SetVolatileServerVariable(const std::string& varName, int32 value, const sol::object& expiry); + int32 GetCharVar(uint32 charId, const std::string& varName); // Get player var directly from SQL DB + void SetCharVar(uint32 charId, const std::string& varName, int32 value, const sol::object& expiry); // Set player var in SQL DB using charId + void ClearCharVarFromAll(const std::string& varName); // Deletes a specific player variable from all players void Terminate(); // Logs off all characters and terminates the server int32 GetTextIDVariable(uint16 ZoneID, const char* variable); // Load the value of the TextID variable of the specified zone @@ -227,7 +227,7 @@ namespace luautils int32 OnTrigger(CCharEntity* PChar, CBaseEntity* PNpc); int32 OnEventUpdate(CCharEntity* PChar, uint16 eventID, uint32 result); // triggered when game triggers event update during cutscene - int32 OnEventUpdate(CCharEntity* PChar, std::string const& updateString); // triggered when game triggers event update during cutscene + int32 OnEventUpdate(CCharEntity* PChar, const std::string& updateString); // triggered when game triggers event update during cutscene int32 OnEventFinish(CCharEntity* PChar, uint16 eventID, uint32 result); void OnTrade(CCharEntity* PChar, CBaseEntity* PNpc); @@ -340,7 +340,7 @@ namespace luautils int32 additionalEffectAttack(CBattleEntity* PAttacker, CBattleEntity* PDefender, CItemWeapon* PItem, actionTarget_t* Action, int32 baseAttackDamage); // for items with additional effects void additionalEffectSpikes(CBattleEntity* PDefender, CBattleEntity* PAttacker, CItemEquipment* PItem, actionTarget_t* Action, int32 baseAttackDamage); // for armor with spikes - auto NearLocation(sol::table const& table, float radius, float theta) -> sol::table; + auto NearLocation(const sol::table& table, float radius, float theta) -> sol::table; auto GetFurthestValidPosition(CLuaBaseEntity* fromTarget, float distance, float theta) -> sol::table; void OnPlayerDeath(CCharEntity* PChar); @@ -348,7 +348,7 @@ namespace luautils void OnPlayerLevelDown(CCharEntity* PChar); void OnPlayerMount(CCharEntity* PChar); void OnPlayerEmote(CCharEntity* PChar, Emote EmoteID); - void OnPlayerVolunteer(CCharEntity* PChar, std::string const& text); + void OnPlayerVolunteer(CCharEntity* PChar, const std::string& text); bool OnChocoboDig(CCharEntity* PChar); // chocobo digging @@ -367,8 +367,8 @@ namespace luautils void HandleCustomMenu(CCharEntity* PChar, const std::string& selection); // Retrive the first itemId that matches a name - uint16 GetItemIDByName(std::string const& name); - auto SendItemToDeliveryBox(std::string const& playerName, uint16 itemId, uint32 quantity, std::string senderText) -> SendToDBoxReturnCode; + uint16 GetItemIDByName(const std::string& name); + auto SendItemToDeliveryBox(const std::string& playerName, uint16 itemId, uint32 quantity, std::string senderText) -> SendToDBoxReturnCode; std::optional GenerateDynamicEntity(CZone* PZone, CInstance* PInstance, sol::table table); diff --git a/src/map/map.cpp b/src/map/map.cpp index a64f2fefd95..a80cad55788 100755 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -252,7 +252,7 @@ int32 do_init(int32 argc, char** argv) PacketParserInitialize(); _sql->Query("DELETE FROM accounts_sessions WHERE IF(%u = 0 AND %u = 0, true, server_addr = %u AND server_port = %u)", - map_ip.s_addr, map_port, map_ip.s_addr, map_port); + map_ip.s_addr, map_port, map_ip.s_addr, map_port); ShowInfo("do_init: zlib is reading"); zlib_init(); @@ -543,10 +543,8 @@ int32 do_sockets(fd_set* rfd, duration next) { message::handle_incoming(); - struct timeval timeout - { - }; - int32 ret = 0; + struct timeval timeout{}; + int32 ret = 0; memcpy(rfd, &readfds, sizeof(*rfd)); timeout.tv_sec = std::chrono::duration_cast(next).count(); @@ -567,10 +565,8 @@ int32 do_sockets(fd_set* rfd, duration next) if (sFD_ISSET(map_fd, rfd)) { - struct sockaddr_in from - { - }; - socklen_t fromlen = sizeof(from); + struct sockaddr_in from{}; + socklen_t fromlen = sizeof(from); ret = recvudp(map_fd, g_PBuff, MAX_BUFFER_SIZE, 0, (struct sockaddr*)&from, &fromlen); if (ret != -1) @@ -825,8 +821,7 @@ int32 recv_parse(int8* buff, size_t* buffsize, sockaddr_in* from, map_session_da { // If the client is pending zone, they might not have received 0x00B, and thus not incremented their key // Check old blowfish data - if (map_session_data->blowfish.status == BLOWFISH_PENDING_ZONE && - map_decipher_packet(g_PBuffCopy, *buffsize, from, map_session_data, &map_session_data->prev_blowfish) != -1) + if (map_session_data->blowfish.status == BLOWFISH_PENDING_ZONE && map_decipher_packet(g_PBuffCopy, *buffsize, from, map_session_data, &map_session_data->prev_blowfish) != -1) { // Copy decrypted bytes back into buffer std::memcpy(buff, g_PBuffCopy, *buffsize); @@ -893,7 +888,7 @@ int32 parse(int8* buff, size_t* buffsize, sockaddr_in* from, map_session_data_t* } for (int8* SmallPD_ptr = PacketData_Begin; SmallPD_ptr + (ref(SmallPD_ptr, 1) & 0xFE) * 2 <= PacketData_End && (ref(SmallPD_ptr, 1) & 0xFE); - SmallPD_ptr = SmallPD_ptr + SmallPD_Size * 2) + SmallPD_ptr = SmallPD_ptr + SmallPD_Size * 2) { SmallPD_Size = (ref(SmallPD_ptr, 1) & 0x0FE); SmallPD_Type = (ref(SmallPD_ptr, 0) & 0x1FF); @@ -912,7 +907,7 @@ int32 parse(int8* buff, size_t* buffsize, sockaddr_in* from, map_session_data_t* if (SmallPD_Type != 0x15) { DebugPackets("parse: %03hX | %04hX %04hX %02hX from user: %s", - SmallPD_Type, ref(SmallPD_ptr, 2), ref(buff, 2), SmallPD_Size, PChar->getName()); + SmallPD_Type, ref(SmallPD_ptr, 2), ref(buff, 2), SmallPD_Size, PChar->getName()); } if (settings::get("map.PACKETGUARD_ENABLED") && PacketGuard::IsRateLimitedPacket(PChar, SmallPD_Type)) @@ -924,7 +919,7 @@ int32 parse(int8* buff, size_t* buffsize, sockaddr_in* from, map_session_data_t* if (settings::get("map.PACKETGUARD_ENABLED") && !PacketGuard::PacketIsValidForPlayerState(PChar, SmallPD_Type)) { ShowWarning("[PacketGuard] Caught mismatch between player substate and recieved packet: Player: %s - Packet: %03hX", - PChar->getName(), SmallPD_Type); + PChar->getName(), SmallPD_Type); // TODO: Plug in optional jailutils usage continue; // skip this packet } @@ -950,7 +945,7 @@ int32 parse(int8* buff, size_t* buffsize, sockaddr_in* from, map_session_data_t* else { ShowWarning("Bad packet size %03hX | %04hX %04hX %02hX from user: %s", SmallPD_Type, ref(SmallPD_ptr, 2), ref(buff, 2), - SmallPD_Size, PChar->getName()); + SmallPD_Size, PChar->getName()); } } @@ -1064,7 +1059,7 @@ int32 send_parse(int8* buff, size_t* buffsize, sockaddr_in* from, map_session_da auto offset = entry.first; auto value = entry.second; ShowInfo(fmt::format("Packet Mod ({}): {:04X}: {:04X}: {:02X}", - PChar->name, type, offset, value)); + PChar->name, type, offset, value)); PSmallPacket->ref(offset) = value; } } @@ -1198,7 +1193,7 @@ int32 send_parse(int8* buff, size_t* buffsize, sockaddr_in* from, map_session_da return 0; } ShowWarning(fmt::format("Packet backlog for char {} in {} is {}! Limit is: {}", - PChar->name, PChar->loc.zone->getName(), remainingPackets, MAX_PACKET_BACKLOG_SIZE)); + PChar->name, PChar->loc.zone->getName(), remainingPackets, MAX_PACKET_BACKLOG_SIZE)); } } diff --git a/src/map/merit.cpp b/src/map/merit.cpp index 21c45cd1db6..b20c74997f5 100644 --- a/src/map/merit.cpp +++ b/src/map/merit.cpp @@ -39,9 +39,9 @@ static uint8 upgrade[10][45] = { { 3, 4, 5, 5, 5 }, // Job Group 2 { 20, 22, 24, 27, 30 }, // Weapon Skills { 1, 3, 5, 7, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, - 42, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 51, 51, 51, 51, 51, 51, 51, - 51, 51 } // Max merits + 42, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 51, 51, 51, 51, 51, 51, 51, + 51, 51 } // Max merits }; #define MAX_LIMIT_POINTS 10000 @@ -135,8 +135,8 @@ static const MeritCategoryInfo_t meritCatInfo[] = { { 4, 10, 7 }, // MCATEGORY_RUN_2 catNumber 53 }; -#define GetMeritCategory(merit) (((merit) >> 6) - 1) // get category from merit -#define GetMeritID(merit) (((merit)&0x3F) >> 1) // get the offset in the category from merit +#define GetMeritCategory(merit) (((merit) >> 6) - 1) // get category from merit +#define GetMeritID(merit) (((merit) & 0x3F) >> 1) // get the offset in the category from merit CMeritPoints::CMeritPoints(CCharEntity* PChar) { @@ -208,7 +208,7 @@ void CMeritPoints::SaveMeritPoints(uint32 charid) if (merit.count > 0) { _sql->Query("INSERT INTO char_merit (charid, meritid, upgrades) VALUES(%u, %u, %u) ON DUPLICATE KEY UPDATE upgrades = %u", charid, - merit.id, merit.count, merit.count); + merit.id, merit.count, merit.count); } else { @@ -431,7 +431,7 @@ namespace meritNameSpace { int32 ret = _sql->Query("SELECT m.meritid, m.value, m.jobs, m.upgrade, m.upgradeid, m.catagoryid, sl.spellid, ws.unlock_id FROM merits m LEFT JOIN \ spell_list sl ON m.name = sl.name LEFT JOIN weapon_skills ws ON m.name = ws.name ORDER BY m.meritid ASC LIMIT %u", - MERITS_COUNT); + MERITS_COUNT); if (ret != SQL_ERROR && _sql->NumRows() != MERITS_COUNT) { diff --git a/src/map/merit.h b/src/map/merit.h index ad0b01b2a1a..67436a5a4a1 100644 --- a/src/map/merit.h +++ b/src/map/merit.h @@ -586,6 +586,6 @@ namespace meritNameSpace extern Merit_t GMeritsTemplate[MERITS_COUNT]; extern int16 groupOffset[MCATEGORY_COUNT / 64 - 1]; // the first merit offset of each category -}; // namespace meritNameSpace +}; // namespace meritNameSpace #endif diff --git a/src/map/message.cpp b/src/map/message.cpp index edc6afb5207..5f7a031ffef 100644 --- a/src/map/message.cpp +++ b/src/map/message.cpp @@ -87,7 +87,7 @@ namespace message TracyZoneCString(msgTypeToStr(type)); ShowDebug("Message: Received message %s (%d) from message server", - msgTypeToStr(type), static_cast(type)); + msgTypeToStr(type), static_cast(type)); switch (type) { @@ -281,9 +281,7 @@ namespace message if (PInvitee) { // make sure invitee isn't dead or in jail, they aren't a party member and don't already have an invite pending, and your party is not full - if (PInvitee->isDead() || jailutils::InPrison(PInvitee) || PInvitee->InvitePending.id != 0 || - (PInvitee->PParty && inviteType == INVITE_PARTY) || - (inviteType == INVITE_ALLIANCE && (!PInvitee->PParty || PInvitee->PParty->GetLeader() != PInvitee || (PInvitee->PParty && PInvitee->PParty->m_PAlliance)))) + if (PInvitee->isDead() || jailutils::InPrison(PInvitee) || PInvitee->InvitePending.id != 0 || (PInvitee->PParty && inviteType == INVITE_PARTY) || (inviteType == INVITE_ALLIANCE && (!PInvitee->PParty || PInvitee->PParty->GetLeader() != PInvitee || (PInvitee->PParty && PInvitee->PParty->m_PAlliance)))) { ref((uint8*)extra.data(), 0) = ref((uint8*)extra.data(), 6); send(MSG_DIRECT, extra.data(), sizeof(uint32), new CMessageStandardPacket(PInvitee, 0, 0, MsgStd::CannotInvite)); @@ -336,7 +334,7 @@ namespace message // both party leaders? int ret = _sql->Query("SELECT * FROM accounts_parties WHERE partyid <> 0 AND \ ((charid = %u OR charid = %u) AND partyflag & %u)", - inviterId, inviteeId, PARTY_LEADER); + inviterId, inviteeId, PARTY_LEADER); if (ret != SQL_ERROR && _sql->NumRows() == 2) { if (PInviter->PParty) @@ -346,7 +344,7 @@ namespace message ret = _sql->Query("SELECT * FROM accounts_parties WHERE allianceid <> 0 AND \ allianceid = (SELECT allianceid FROM accounts_parties where \ charid = %u) GROUP BY partyid", - inviterId); + inviterId); if (ret != SQL_ERROR && _sql->NumRows() > 0 && _sql->NumRows() < 3) { PInviter->PParty->m_PAlliance->addParty(inviteeId); @@ -354,7 +352,7 @@ namespace message else { send(MSG_DIRECT, (uint8*)extra.data() + 6, sizeof(uint32), - new CMessageStandardPacket(PInviter, 0, 0, MsgStd::CannotBeProcessed)); + new CMessageStandardPacket(PInviter, 0, 0, MsgStd::CannotBeProcessed)); } } else if (PInviter->PParty) @@ -367,7 +365,7 @@ namespace message else // Somehow, the inviter didn't have a party despite the database thinking they did. { send(MSG_DIRECT, (uint8*)extra.data() + 6, sizeof(uint32), - new CMessageStandardPacket(PInviter, 0, 0, MsgStd::CannotBeProcessed)); + new CMessageStandardPacket(PInviter, 0, 0, MsgStd::CannotBeProcessed)); } } else @@ -539,7 +537,7 @@ namespace message if (targetLS && (kickerRank == LSTYPE_LINKSHELL || (kickerRank == LSTYPE_PEARLSACK && targetLS->GetLSType() == LSTYPE_LINKPEARL))) { PChar->PLinkshell1->RemoveMemberByName(memberName, - (targetLS->GetLSType() == (uint8)LSTYPE_LINKSHELL ? (uint8)LSTYPE_PEARLSACK : kickerRank)); + (targetLS->GetLSType() == (uint8)LSTYPE_LINKSHELL ? (uint8)LSTYPE_PEARLSACK : kickerRank)); } } else if (PChar && PChar->PLinkshell2 && PChar->PLinkshell2->getID() == ref((uint8*)extra.data(), 24)) @@ -852,7 +850,7 @@ namespace message } } - void send_charvar_update(uint32 charId, std::string const& varName, uint32 value, uint32 expiry) + void send_charvar_update(uint32 charId, const std::string& varName, uint32 value, uint32 expiry) { const uint32 size = sizeof(uint32) + sizeof(uint32) + sizeof(uint32) + sizeof(uint8) + 256; char buf[size] = {}; @@ -1018,7 +1016,7 @@ namespace message outgoing_queue.enqueue(msg); } - void send(uint16 zone, std::string const& luaFunc) + void send(uint16 zone, const std::string& luaFunc) { TracyZoneScoped; @@ -1041,14 +1039,14 @@ namespace message message::send(MSG_DIRECT, packetData.data(), packetData.size(), packet); } - void send(std::string const& playerName, CBasicPacket* packet) + void send(const std::string& playerName, CBasicPacket* packet) { TracyZoneScoped; send(charutils::getCharIdFromName(playerName), packet); } - void rpc_send(uint16 sendZone, uint16 recvZone, std::string const& sendStr, sol::function recvFunc) + void rpc_send(uint16 sendZone, uint16 recvZone, const std::string& sendStr, sol::function recvFunc) { uint64_t slotKey = std::chrono::duration_cast(hires_clock::now().time_since_epoch()).count(); replyMap[slotKey] = std::move(recvFunc); diff --git a/src/map/message.h b/src/map/message.h index 459681da796..11bb299bf67 100644 --- a/src/map/message.h +++ b/src/map/message.h @@ -50,7 +50,7 @@ struct chat_message_t return *this; } - chat_message_t(chat_message_t const& other) noexcept + chat_message_t(const chat_message_t& other) noexcept { // NOTE: Normally we wouldn't want to use const_cast, but ZMQ has // deprecated their copy function that uses const&. @@ -75,11 +75,11 @@ namespace message void init(const char* chatIp, uint16 chatPort); void handle_incoming(); void send(MSGSERVTYPE type, void* data, size_t datalen, CBasicPacket* packet = nullptr); - void send(uint16 zone, std::string const& luaFunc); + void send(uint16 zone, const std::string& luaFunc); void send(uint32 playerId, CBasicPacket* packet); - void send(std::string const& playerName, CBasicPacket* packet); - void send_charvar_update(uint32 charId, std::string const& varName, uint32 value, uint32 expiry); - void rpc_send(uint16 sendZone, uint16 recvZone, std::string const& sendStr, sol::function recvFunc); + void send(const std::string& playerName, CBasicPacket* packet); + void send_charvar_update(uint32 charId, const std::string& varName, uint32 value, uint32 expiry); + void rpc_send(uint16 sendZone, uint16 recvZone, const std::string& sendStr, sol::function recvFunc); void close(); diff --git a/src/map/mob_spell_container.cpp b/src/map/mob_spell_container.cpp index 74a841fdea3..edba88d7772 100644 --- a/src/map/mob_spell_container.cpp +++ b/src/map/mob_spell_container.cpp @@ -106,7 +106,9 @@ void CMobSpellContainer::AddSpell(SpellID spellId) void CMobSpellContainer::RemoveSpell(SpellID spellId) { auto findAndRemove = [](std::vector& list, SpellID id) - { list.erase(std::remove(list.begin(), list.end(), id), list.end()); }; + { + list.erase(std::remove(list.begin(), list.end(), id), list.end()); + }; findAndRemove(m_gaList, spellId); findAndRemove(m_damageList, spellId); @@ -122,14 +124,9 @@ void CMobSpellContainer::RemoveSpell(SpellID spellId) // Used in Gambits to see if the Trust can cast the spell std::optional CMobSpellContainer::GetAvailable(SpellID spellId) { - auto* spell = spell::GetSpell(spellId); - bool enoughMP = spell->getMPCost() <= m_PMob->health.mp || - spell->getSkillType() == SKILL_NINJUTSU || - spell->getSkillType() == SKILL_SINGING || - spell->getSkillType() == SKILL_WIND_INSTRUMENT || - spell->getSkillType() == SKILL_STRING_INSTRUMENT || - spell->getSkillType() == SKILL_GEOMANCY; - bool isNotInRecast = !m_PMob->PRecastContainer->Has(RECAST_MAGIC, static_cast(spellId)); + auto* spell = spell::GetSpell(spellId); + bool enoughMP = spell->getMPCost() <= m_PMob->health.mp || spell->getSkillType() == SKILL_NINJUTSU || spell->getSkillType() == SKILL_SINGING || spell->getSkillType() == SKILL_WIND_INSTRUMENT || spell->getSkillType() == SKILL_STRING_INSTRUMENT || spell->getSkillType() == SKILL_GEOMANCY; + bool isNotInRecast = !m_PMob->PRecastContainer->Has(RECAST_MAGIC, static_cast(spellId)); return (isNotInRecast && enoughMP) ? std::optional(spellId) : std::nullopt; } @@ -142,15 +139,10 @@ std::optional CMobSpellContainer::GetBestAvailable(SPELLFAMILY family) { for (auto id : list) { - auto* spell = spell::GetSpell(id); - bool sameFamily = (family == SPELLFAMILY_NONE) ? true : spell->getSpellFamily() == family; - bool enoughMP = spell->getMPCost() <= m_PMob->health.mp || - spell->getSkillType() == SKILL_NINJUTSU || - spell->getSkillType() == SKILL_SINGING || - spell->getSkillType() == SKILL_WIND_INSTRUMENT || - spell->getSkillType() == SKILL_STRING_INSTRUMENT || - spell->getSkillType() == SKILL_GEOMANCY; - bool isNotInRecast = !m_PMob->PRecastContainer->Has(RECAST_MAGIC, static_cast(id)); + auto* spell = spell::GetSpell(id); + bool sameFamily = (family == SPELLFAMILY_NONE) ? true : spell->getSpellFamily() == family; + bool enoughMP = spell->getMPCost() <= m_PMob->health.mp || spell->getSkillType() == SKILL_NINJUTSU || spell->getSkillType() == SKILL_SINGING || spell->getSkillType() == SKILL_WIND_INSTRUMENT || spell->getSkillType() == SKILL_STRING_INSTRUMENT || spell->getSkillType() == SKILL_GEOMANCY; + bool isNotInRecast = !m_PMob->PRecastContainer->Has(RECAST_MAGIC, static_cast(id)); if (sameFamily && enoughMP && isNotInRecast) { matches.emplace_back(id); @@ -538,8 +530,7 @@ std::optional CMobSpellContainer::GetAggroSpell() std::optional CMobSpellContainer::GetSpell() { // prioritize curing if health low enough - if (HasHealSpells() && m_PMob->GetHPP() <= m_PMob->getMobMod(MOBMOD_HP_HEAL_CHANCE) && - xirand::GetRandomNumber(100) < m_PMob->getMobMod(MOBMOD_HEAL_CHANCE)) + if (HasHealSpells() && m_PMob->GetHPP() <= m_PMob->getMobMod(MOBMOD_HP_HEAL_CHANCE) && xirand::GetRandomNumber(100) < m_PMob->getMobMod(MOBMOD_HEAL_CHANCE)) { return GetHealSpell(); } diff --git a/src/map/mob_spell_list.cpp b/src/map/mob_spell_list.cpp index 83add512f77..ee617d18830 100644 --- a/src/map/mob_spell_list.cpp +++ b/src/map/mob_spell_list.cpp @@ -37,7 +37,7 @@ void CMobSpellList::AddSpell(SpellID spellId, uint16 minLvl, uint16 maxLvl) uint16 CMobSpellList::GetSpellMinLevel(SpellID spellId) { - for (auto const& Mob_Spell : m_spellList) + for (const auto& Mob_Spell : m_spellList) { if (spellId == Mob_Spell.spellId) { diff --git a/src/map/monstrosity.cpp b/src/map/monstrosity.cpp index 919fe58ef6a..d4c90bfc68f 100644 --- a/src/map/monstrosity.cpp +++ b/src/map/monstrosity.cpp @@ -251,24 +251,24 @@ void monstrosity::WriteMonstrosityData(CCharEntity* PChar) auto variantsEscaped = _sql->ObjectToBlobString(&PChar->m_PMonstrosity->variants); _sql->Query(Query, - PChar->id, - PChar->m_PMonstrosity->MonstrosityId, - PChar->m_PMonstrosity->Species, - PChar->m_PMonstrosity->NamePrefix1, - PChar->m_PMonstrosity->NamePrefix2, - PChar->m_PMonstrosity->CurrentExp, - equipEscaped.c_str(), - levelsEscaped.c_str(), - instinctsEscaped.c_str(), - variantsEscaped.c_str(), - static_cast(PChar->m_PMonstrosity->Belligerency), - PChar->m_PMonstrosity->EntryPos.x, - PChar->m_PMonstrosity->EntryPos.y, - PChar->m_PMonstrosity->EntryPos.z, - PChar->m_PMonstrosity->EntryPos.rotation, - PChar->m_PMonstrosity->EntryZoneId, - PChar->m_PMonstrosity->EntryMainJob, - PChar->m_PMonstrosity->EntrySubJob); + PChar->id, + PChar->m_PMonstrosity->MonstrosityId, + PChar->m_PMonstrosity->Species, + PChar->m_PMonstrosity->NamePrefix1, + PChar->m_PMonstrosity->NamePrefix2, + PChar->m_PMonstrosity->CurrentExp, + equipEscaped.c_str(), + levelsEscaped.c_str(), + instinctsEscaped.c_str(), + variantsEscaped.c_str(), + static_cast(PChar->m_PMonstrosity->Belligerency), + PChar->m_PMonstrosity->EntryPos.x, + PChar->m_PMonstrosity->EntryPos.y, + PChar->m_PMonstrosity->EntryPos.z, + PChar->m_PMonstrosity->EntryPos.rotation, + PChar->m_PMonstrosity->EntryZoneId, + PChar->m_PMonstrosity->EntryMainJob, + PChar->m_PMonstrosity->EntrySubJob); } void monstrosity::TryPopulateMonstrosityData(CCharEntity* PChar) @@ -304,7 +304,7 @@ void monstrosity::HandleZoneIn(CCharEntity* PChar) if (maybeInstinct != gMonstrosityInstinctMap.end()) { auto instinct = (*maybeInstinct).second; - for (auto const& mod : instinct.mods) + for (const auto& mod : instinct.mods) { PChar->addModifier(mod.getModID(), mod.getModAmount()); } @@ -531,7 +531,7 @@ void monstrosity::HandleEquipChangePacket(CCharEntity* PChar, CBasicPacket& data // Remove PChar->m_PMonstrosity->EquippedInstincts[idx] = 0x0000; - for (auto const& mod : gMonstrosityInstinctMap[previousEquipped[idx]].mods) + for (const auto& mod : gMonstrosityInstinctMap[previousEquipped[idx]].mods) { PChar->delModifier(mod.getModID(), mod.getModAmount()); } @@ -549,8 +549,7 @@ void monstrosity::HandleEquipChangePacket(CCharEntity* PChar, CBasicPacket& data PChar->m_PMonstrosity->EquippedInstincts[idx] = value; // Validate cost - if (getTotalInstinctsCost(PChar->m_PMonstrosity->EquippedInstincts) > maxPoints || - instinctsContainDuplicates(PChar->m_PMonstrosity->EquippedInstincts)) + if (getTotalInstinctsCost(PChar->m_PMonstrosity->EquippedInstincts) > maxPoints || instinctsContainDuplicates(PChar->m_PMonstrosity->EquippedInstincts)) { // Reset to what it was before and don't handle mods PChar->m_PMonstrosity->EquippedInstincts = previousEquipped; @@ -558,7 +557,7 @@ void monstrosity::HandleEquipChangePacket(CCharEntity* PChar, CBasicPacket& data else { auto instinct = (*maybeInstinct).second; - for (auto const& mod : instinct.mods) + for (const auto& mod : instinct.mods) { PChar->addModifier(mod.getModID(), mod.getModAmount()); } @@ -702,7 +701,7 @@ void monstrosity::MaxAllLevels(CCharEntity* PChar) return; } - for (auto const& [_, entry] : gMonstrositySpeciesMap) + for (const auto& [_, entry] : gMonstrositySpeciesMap) { SetLevel(PChar, entry.monstrosityId, 99); } @@ -716,7 +715,7 @@ void monstrosity::UnlockAllInstincts(CCharEntity* PChar) } // Level based - for (auto const& [_, entry] : gMonstrositySpeciesMap) + for (const auto& [_, entry] : gMonstrositySpeciesMap) { uint8 level = 99; uint8 byteOffset = entry.monstrosityId / 4; diff --git a/src/map/navmesh.cpp b/src/map/navmesh.cpp index d345bfc3496..2551956b71a 100644 --- a/src/map/navmesh.cpp +++ b/src/map/navmesh.cpp @@ -125,7 +125,7 @@ CNavMesh::~CNavMesh() } } -bool CNavMesh::load(std::string const& filename) +bool CNavMesh::load(const std::string& filename) { this->m_filename = filename; @@ -282,7 +282,7 @@ std::vector CNavMesh::findPath(const position_t& start, const posit int32 straightPathCount = MAX_NAV_POLYS * 3; status = m_navMeshQuery.findStraightPath(snearest, enearest, m_polys, pathCount, straightPath, straightPathFlags, straightPathPolys, &straightPathCount, - MAX_NAV_POLYS); + MAX_NAV_POLYS); if (dtStatusFailed(status)) { diff --git a/src/map/navmesh.h b/src/map/navmesh.h index 4309d2a2b74..57f1f8212aa 100644 --- a/src/map/navmesh.h +++ b/src/map/navmesh.h @@ -69,7 +69,7 @@ class CNavMesh CNavMesh(uint16 zoneID); ~CNavMesh(); - bool load(std::string const& path); + bool load(const std::string& path); void reload(); void unload(); diff --git a/src/map/packet_system.cpp b/src/map/packet_system.cpp index da01d1c6292..c3904846efd 100644 --- a/src/map/packet_system.cpp +++ b/src/map/packet_system.cpp @@ -645,14 +645,11 @@ void SmallPacket0x016(map_session_data_t* const PSession, CCharEntity* const PCh // PEntity->id will now be the full id of the entity we could not find ShowWarning(fmt::format("Server missing npc_list.sql entry <{}> in zone <{} ({})>", - PEntity->id, zoneutils::GetZone(PChar->getZone())->getName(), PChar->getZone())); + PEntity->id, zoneutils::GetZone(PChar->getZone())->getName(), PChar->getZone())); } // Special case for onZoneIn cutscenes in Mog House - if (PChar->m_moghouseID && - PEntity->status == STATUS_TYPE::DISAPPEAR && - PEntity->loc.p.z == 1.5 && - PEntity->look.face == 0x52) + if (PChar->m_moghouseID && PEntity->status == STATUS_TYPE::DISAPPEAR && PEntity->loc.p.z == 1.5 && PEntity->look.face == 0x52) { // Using the same logic as in ZoneEntities::SpawnMoogle: // Change the status of the entity, send the packet, change it back to disappear @@ -807,10 +804,7 @@ void SmallPacket0x01A(map_session_data_t* const PSession, CCharEntity* const PCh PNpc = PChar->GetEntity(TargID, TYPE_NPC | TYPE_MOB); // MONs are allowed to use doors, but nothing else - if (PChar->m_PMonstrosity != nullptr && - PNpc->look.size != 0x02 && - PChar->getZone() != ZONEID::ZONE_FERETORY && - !settings::get("main.MONSTROSITY_TRIGGER_NPCS")) + if (PChar->m_PMonstrosity != nullptr && PNpc->look.size != 0x02 && PChar->getZone() != ZONEID::ZONE_FERETORY && !settings::get("main.MONSTROSITY_TRIGGER_NPCS")) { PChar->pushPacket(new CReleasePacket(PChar, RELEASE_TYPE::STANDARD)); return; @@ -1155,7 +1149,7 @@ void SmallPacket0x01A(map_session_data_t* const PSession, CCharEntity* const PCh 1800, 0, 0x40), // previously known as nameflag "FLAG_CHOCOBO" - true); + true); PChar->PRecastContainer->Add(RECAST_ABILITY, 256, 60); PChar->pushPacket(new CCharRecastPacket(PChar)); @@ -1343,12 +1337,12 @@ void SmallPacket0x029(map_session_data_t* const PSession, CCharEntity* const PCh if (PItem == nullptr) { ShowWarning("SmallPacket0x29: Trying to move nullptr item from location %u slot %u to location %u slot %u of quan %u ", - FromLocationID, FromSlotID, ToLocationID, ToSlotID, quantity); + FromLocationID, FromSlotID, ToLocationID, ToSlotID, quantity); } else { ShowWarning("SmallPacket0x29: Trying to move LOCKED item %i from location %u slot %u to location %u slot %u of quan %u ", - PItem->getID(), FromLocationID, FromSlotID, ToLocationID, ToSlotID, quantity); + PItem->getID(), FromLocationID, FromSlotID, ToLocationID, ToSlotID, quantity); } uint8 size = PChar->getStorage(FromLocationID)->GetSize(); @@ -1387,8 +1381,7 @@ void SmallPacket0x029(map_session_data_t* const PSession, CCharEntity* const PCh ShowDebug("SmallPacket0x29: Trying to unite items", FromLocationID, FromSlotID); CItem* PItem2 = PChar->getStorage(ToLocationID)->GetItem(ToSlotID); - if ((PItem2 != nullptr) && (PItem2->getID() == PItem->getID()) && (PItem2->getQuantity() < PItem2->getStackSize()) && - !PItem2->isSubType(ITEM_LOCKED) && (PItem2->getReserve() == 0)) + if ((PItem2 != nullptr) && (PItem2->getID() == PItem->getID()) && (PItem2->getQuantity() < PItem2->getStackSize()) && !PItem2->isSubType(ITEM_LOCKED) && (PItem2->getReserve() == 0)) { uint32 totalQty = PItem->getQuantity() + PItem2->getQuantity(); uint32 moveQty = 0; @@ -1492,8 +1485,7 @@ void SmallPacket0x032(map_session_data_t* const PSession, CCharEntity* const PCh } // If either player is crafting, don't allow the trade request. - if (PChar->animation == ANIMATION_SYNTH || (PChar->CraftContainer && PChar->CraftContainer->getItemsCount() > 0) || - PTarget->animation == ANIMATION_SYNTH || (PTarget->CraftContainer && PTarget->CraftContainer->getItemsCount() > 0)) + if (PChar->animation == ANIMATION_SYNTH || (PChar->CraftContainer && PChar->CraftContainer->getItemsCount() > 0) || PTarget->animation == ANIMATION_SYNTH || (PTarget->CraftContainer && PTarget->CraftContainer->getItemsCount() > 0)) { ShowDebug("%s trade request with %s was blocked.", PChar->getName(), PTarget->getName()); PChar->pushPacket(new CTradeActionPacket(PTarget, 0x07)); @@ -1702,7 +1694,7 @@ void SmallPacket0x034(map_session_data_t* const PSession, CCharEntity* const PCh if (quantity != 0) { ShowError("SmallPacket0x034: Player %s trying to update trade quantity of a RESERVED item! [Item: %i | Trade Slot: %i] ", - PChar->getName(), PCurrentSlotItem->getID(), tradeSlotID); + PChar->getName(), PCurrentSlotItem->getID(), tradeSlotID); } PCurrentSlotItem->setReserve(0); PChar->UContainer->ClearSlot(tradeSlotID); @@ -1731,8 +1723,7 @@ void SmallPacket0x034(map_session_data_t* const PSession, CCharEntity* const PCh CItemLinkshell* PItemLinkshell = static_cast(PItem); CItemLinkshell* PItemLinkshell1 = (CItemLinkshell*)PChar->getEquip(SLOT_LINK1); CItemLinkshell* PItemLinkshell2 = (CItemLinkshell*)PChar->getEquip(SLOT_LINK2); - if ((!PItemLinkshell1 && !PItemLinkshell2) || ((!PItemLinkshell1 || PItemLinkshell1->GetLSID() != PItemLinkshell->GetLSID()) && - (!PItemLinkshell2 || PItemLinkshell2->GetLSID() != PItemLinkshell->GetLSID()))) + if ((!PItemLinkshell1 && !PItemLinkshell2) || ((!PItemLinkshell1 || PItemLinkshell1->GetLSID() != PItemLinkshell->GetLSID()) && (!PItemLinkshell2 || PItemLinkshell2->GetLSID() != PItemLinkshell->GetLSID()))) { PChar->pushPacket(new CMessageStandardPacket(MsgStd::LinkshellEquipBeforeUsing)); PItem->setReserve(0); @@ -1741,7 +1732,7 @@ void SmallPacket0x034(map_session_data_t* const PSession, CCharEntity* const PCh else { ShowInfo("%s->%s trade updating trade slot id %d with item %s, quantity %d", PChar->getName(), PTarget->getName(), - tradeSlotID, PItem->getName(), quantity); + tradeSlotID, PItem->getName(), quantity); PItem->setReserve(quantity + PItem->getReserve()); PChar->UContainer->SetItem(tradeSlotID, PItem); } @@ -1749,7 +1740,7 @@ void SmallPacket0x034(map_session_data_t* const PSession, CCharEntity* const PCh else { ShowInfo("%s->%s trade updating trade slot id %d with item %s, quantity %d", PChar->getName(), PTarget->getName(), - tradeSlotID, PItem->getName(), quantity); + tradeSlotID, PItem->getName(), quantity); PItem->setReserve(quantity + PItem->getReserve()); PChar->UContainer->SetItem(tradeSlotID, PItem); } @@ -1757,7 +1748,7 @@ void SmallPacket0x034(map_session_data_t* const PSession, CCharEntity* const PCh else { ShowInfo("%s->%s trade updating trade slot id %d with item %s, quantity 0", PChar->getName(), PTarget->getName(), - tradeSlotID, PItem->getName()); + tradeSlotID, PItem->getName()); PItem->setReserve(0); PChar->UContainer->SetItem(tradeSlotID, nullptr); } @@ -1925,8 +1916,7 @@ void SmallPacket0x03A(map_session_data_t* const PSession, CCharEntity* const PCh { CItem* PItem2 = PItemContainer->GetItem(slotID2); - if ((PItem2 != nullptr) && (PItem2->getID() == PItem->getID()) && (PItem2->getQuantity() < PItem2->getStackSize()) && - !PItem2->isSubType(ITEM_LOCKED) && (PItem2->getReserve() == 0)) + if ((PItem2 != nullptr) && (PItem2->getID() == PItem->getID()) && (PItem2->getQuantity() < PItem2->getStackSize()) && !PItem2->isSubType(ITEM_LOCKED) && (PItem2->getReserve() == 0)) { uint32 totalQty = PItem->getQuantity() + PItem2->getQuantity(); uint32 moveQty = 0; @@ -2463,8 +2453,7 @@ void SmallPacket0x04D(map_session_data_t* const PSession, CCharEntity* const PCh return; } - if ((PChar->animation >= ANIMATION_FISHING_FISH && PChar->animation <= ANIMATION_FISHING_STOP) || - PChar->animation == ANIMATION_FISHING_START_OLD || PChar->animation == ANIMATION_FISHING_START) + if ((PChar->animation >= ANIMATION_FISHING_FISH && PChar->animation <= ANIMATION_FISHING_STOP) || PChar->animation == ANIMATION_FISHING_START_OLD || PChar->animation == ANIMATION_FISHING_START) { ShowWarning("SmallPacket0x04D: %s attempting to access delivery box while fishing!", PChar->getName()); return; @@ -2665,7 +2654,7 @@ void SmallPacket0x04D(map_session_data_t* const PSession, CCharEntity* const PCh uint32 charid = _sql->GetUIntData(0); ret = _sql->Query("UPDATE delivery_box SET sent = 1 WHERE charid = %u AND senderid = %u AND slot = %u AND box = 2", - PChar->id, charid, slotID); + PChar->id, charid, slotID); if (ret != SQL_ERROR && _sql->AffectedRows() == 1) { @@ -2718,8 +2707,7 @@ void SmallPacket0x04D(map_session_data_t* const PSession, CCharEntity* const PCh if (_sql->SetAutoCommit(false) && _sql->TransactionStart()) { - int32 ret = - _sql->Query("SELECT charid FROM chars WHERE charname = '%s' LIMIT 1", PChar->UContainer->GetItem(slotID)->getReceiver()); + int32 ret = _sql->Query("SELECT charid FROM chars WHERE charname = '%s' LIMIT 1", PChar->UContainer->GetItem(slotID)->getReceiver()); if (ret != SQL_ERROR && _sql->NumRows() > 0 && _sql->NextRow() == SQL_SUCCESS) { @@ -2740,9 +2728,9 @@ void SmallPacket0x04D(map_session_data_t* const PSession, CCharEntity* const PCh PChar->UContainer->GetItem(slotID)->setSent(false); commit = true; PChar->pushPacket(new CDeliveryBoxPacket(action, boxtype, PChar->UContainer->GetItem(slotID), slotID, - PChar->UContainer->GetItemsCount(), 0x02)); + PChar->UContainer->GetItemsCount(), 0x02)); PChar->pushPacket(new CDeliveryBoxPacket(action, boxtype, PChar->UContainer->GetItem(slotID), slotID, - PChar->UContainer->GetItemsCount(), 0x01)); + PChar->UContainer->GetItemsCount(), 0x01)); } else if (ret != SQL_ERROR && _sql->AffectedRows() == 0) { @@ -2868,7 +2856,7 @@ void SmallPacket0x04D(map_session_data_t* const PSession, CCharEntity* const PCh // the result of this query doesn't really matter, it can be sent from the auction house which has no sender record _sql->Query("UPDATE delivery_box SET received = 1 WHERE senderid = %u AND charid = %u AND box = 2 AND received = 0 AND quantity " "= %u AND sent = 1 AND itemid = %u LIMIT 1", - PChar->id, senderID, PItem->getQuantity(), PItem->getID()); + PChar->id, senderID, PItem->getQuantity(), PItem->getID()); _sql->Query("SELECT slot FROM delivery_box WHERE charid = %u AND box = 1 AND slot > 7 ORDER BY slot ASC", PChar->id); if (ret != SQL_ERROR && _sql->NumRows() > 0 && _sql->NextRow() == SQL_SUCCESS) @@ -2986,7 +2974,7 @@ void SmallPacket0x04D(map_session_data_t* const PSession, CCharEntity* const PCh { // Get sender of delivery record int32 ret = _sql->Query("SELECT senderid, sender FROM delivery_box WHERE charid = %u AND slot = %u AND box = 1 LIMIT 1", - PChar->id, slotID); + PChar->id, slotID); if (ret != SQL_ERROR && _sql->NumRows() > 0 && _sql->NextRow() == SQL_SUCCESS) { @@ -3001,8 +2989,8 @@ void SmallPacket0x04D(map_session_data_t* const PSession, CCharEntity* const PCh // Insert a return record into delivery_box ret = _sql->Query("INSERT INTO delivery_box(charid, charname, box, itemid, itemsubid, quantity, extra, senderid, sender) VALUES(%u, " "'%s', 1, %u, %u, %u, '%s', %u, '%s'); ", - senderID, senderName.c_str(), PItem->getID(), PItem->getSubID(), PItem->getQuantity(), extra, PChar->id, - PChar->getName()); + senderID, senderName.c_str(), PItem->getID(), PItem->getSubID(), PItem->getQuantity(), extra, PChar->id, + PChar->getName()); if (ret != SQL_ERROR && _sql->AffectedRows() > 0) { @@ -3024,7 +3012,7 @@ void SmallPacket0x04D(map_session_data_t* const PSession, CCharEntity* const PCh { _sql->TransactionRollback(); ShowError("Could not finalize delivery return transaction. PlayerID: %d SenderID :%d ItemID: %d Quantity: %d", PChar->id, senderID, - item_id, quantity); + item_id, quantity); PChar->pushPacket(new CDeliveryBoxPacket(action, boxtype, PItem, slotID, PChar->UContainer->GetItemsCount(), 0xEB)); } @@ -3066,7 +3054,7 @@ void SmallPacket0x04D(map_session_data_t* const PSession, CCharEntity* const PCh else if (boxtype == 0x02) { ret = _sql->Query("DELETE FROM delivery_box WHERE charid = %u AND sent = 0 AND slot = %u AND box = %u LIMIT 1", PChar->id, - slotID, boxtype); + slotID, boxtype); } if (ret != SQL_ERROR && _sql->AffectedRows() != 0) @@ -3390,8 +3378,7 @@ void SmallPacket0x04E(map_session_data_t* const PSession, CCharEntity* const PCh const char* fmtQuery = "UPDATE auction_house SET buyer_name = '%s', sale = %u, sell_date = %u WHERE itemid = %u AND buyer_name IS NULL " "AND stack = %u AND price <= %u ORDER BY price LIMIT 1"; - if (_sql->Query(fmtQuery, PChar->getName(), price, (uint32)time(nullptr), itemid, quantity == 0, price) != SQL_ERROR && - _sql->AffectedRows() != 0) + if (_sql->Query(fmtQuery, PChar->getName(), price, (uint32)time(nullptr), itemid, quantity == 0, price) != SQL_ERROR && _sql->AffectedRows() != 0) { uint8 SlotID = charutils::AddItem(PChar, LOC_INVENTORY, itemid, (quantity == 0 ? PItem->getStackSize() : 1)); @@ -3434,8 +3421,7 @@ void SmallPacket0x04E(map_session_data_t* const PSession, CCharEntity* const PCh CItem* PDelItem = itemutils::GetItemPointer(canceledItem.itemid); if (PDelItem) { - uint8 SlotID = - charutils::AddItem(PChar, LOC_INVENTORY, canceledItem.itemid, (canceledItem.stack != 0 ? PDelItem->getStackSize() : 1), true); + uint8 SlotID = charutils::AddItem(PChar, LOC_INVENTORY, canceledItem.itemid, (canceledItem.stack != 0 ? PDelItem->getStackSize() : 1), true); if (SlotID != ERROR_SLOTID) { @@ -3486,27 +3472,11 @@ void SmallPacket0x050(map_session_data_t* const PSession, CCharEntity* const PCh uint8 equipSlotID = data.ref(0x05); // charequip slot uint8 containerID = data.ref(0x06); // container id - bool isAdditionalContainer = - containerID == LOC_MOGSATCHEL || - containerID == LOC_MOGSACK || - containerID == LOC_MOGCASE; - - bool isEquippableInventory = - containerID == LOC_INVENTORY || - containerID == LOC_WARDROBE || - containerID == LOC_WARDROBE2 || - containerID == LOC_WARDROBE3 || - containerID == LOC_WARDROBE4 || - containerID == LOC_WARDROBE5 || - containerID == LOC_WARDROBE6 || - containerID == LOC_WARDROBE7 || - containerID == LOC_WARDROBE8 || - (settings::get("main.EQUIP_FROM_OTHER_CONTAINERS") && - isAdditionalContainer); - - bool isLinkshell = - equipSlotID == SLOT_LINK1 || - equipSlotID == SLOT_LINK2; + bool isAdditionalContainer = containerID == LOC_MOGSATCHEL || containerID == LOC_MOGSACK || containerID == LOC_MOGCASE; + + bool isEquippableInventory = containerID == LOC_INVENTORY || containerID == LOC_WARDROBE || containerID == LOC_WARDROBE2 || containerID == LOC_WARDROBE3 || containerID == LOC_WARDROBE4 || containerID == LOC_WARDROBE5 || containerID == LOC_WARDROBE6 || containerID == LOC_WARDROBE7 || containerID == LOC_WARDROBE8 || (settings::get("main.EQUIP_FROM_OTHER_CONTAINERS") && isAdditionalContainer); + + bool isLinkshell = equipSlotID == SLOT_LINK1 || equipSlotID == SLOT_LINK2; // Sanity check if (!isEquippableInventory && !isLinkshell) @@ -3540,9 +3510,7 @@ void SmallPacket0x051(map_session_data_t* const PSession, CCharEntity* const PCh uint8 slotID = data.ref(0x08 + (0x04 * i)); // inventory slot uint8 equipSlotID = data.ref(0x09 + (0x04 * i)); // charequip slot uint8 containerID = data.ref(0x0A + (0x04 * i)); // container id - if (containerID == LOC_INVENTORY || containerID == LOC_WARDROBE || containerID == LOC_WARDROBE2 || containerID == LOC_WARDROBE3 || - containerID == LOC_WARDROBE4 || containerID == LOC_WARDROBE5 || containerID == LOC_WARDROBE6 || containerID == LOC_WARDROBE7 || - containerID == LOC_WARDROBE8) + if (containerID == LOC_INVENTORY || containerID == LOC_WARDROBE || containerID == LOC_WARDROBE2 || containerID == LOC_WARDROBE3 || containerID == LOC_WARDROBE4 || containerID == LOC_WARDROBE5 || containerID == LOC_WARDROBE6 || containerID == LOC_WARDROBE7 || containerID == LOC_WARDROBE8) { charutils::EquipItem(PChar, slotID, equipSlotID, containerID); } @@ -3863,10 +3831,10 @@ void SmallPacket0x05D(map_session_data_t* const PSession, CCharEntity* const PCh return; } - auto const& TargetID = data.ref(0x04); - auto const& TargetIndex = data.ref(0x08); - auto const& EmoteID = data.ref(0x0A); - auto const& emoteMode = data.ref(0x0B); + const auto& TargetID = data.ref(0x04); + const auto& TargetIndex = data.ref(0x08); + const auto& EmoteID = data.ref(0x0A); + const auto& emoteMode = data.ref(0x0B); // Invalid Emote ID. if (EmoteID < Emote::POINT || EmoteID > Emote::AIM) @@ -3902,8 +3870,8 @@ void SmallPacket0x05D(map_session_data_t* const PSession, CCharEntity* const PCh { // Nothing equipped in the style, look at what's actually equipped. mainWeapon = PChar->getEquip(SLOT_MAIN) != nullptr - ? PChar->getEquip(SLOT_MAIN)->getID() - : 0; + ? PChar->getEquip(SLOT_MAIN)->getID() + : 0; } if (!IsBell(mainWeapon)) @@ -4003,14 +3971,12 @@ void SmallPacket0x05E(map_session_data_t* const PSession, CCharEntity* const PCh auto destinationRegion = zoneutils::GetCurrentRegion(destinationZone); auto moghouseExitRegions = { REGION_TYPE::SANDORIA, REGION_TYPE::BASTOK, REGION_TYPE::WINDURST, REGION_TYPE::JEUNO, REGION_TYPE::WEST_AHT_URHGAN }; auto moghouseSameRegion = std::any_of(moghouseExitRegions.begin(), moghouseExitRegions.end(), - [&destinationRegion](REGION_TYPE acceptedReg) - { return destinationRegion == acceptedReg; }); + [&destinationRegion](REGION_TYPE acceptedReg) + { + return destinationRegion == acceptedReg; + }); auto moghouseQuestComplete = PChar->profile.mhflag & (town ? 0x01 << (town - 1) : 0); - bool moghouseExitQuestZoneline = moghouseQuestComplete && - startingRegion == destinationRegion && - PChar->m_moghouseID > 0 && - moghouseSameRegion && - !requestedMoghouseFloorChange; + bool moghouseExitQuestZoneline = moghouseQuestComplete && startingRegion == destinationRegion && PChar->m_moghouseID > 0 && moghouseSameRegion && !requestedMoghouseFloorChange; bool moghouseExitMogGardenZoneline = destinationZone == ZONE_MOG_GARDEN && PChar->m_moghouseID > 0; @@ -4359,9 +4325,7 @@ void SmallPacket0x06E(map_session_data_t* const PSession, CCharEntity* const PCh break; case 5: // alliance - must be unallied party leader or alliance leader of a non-full alliance - if (PChar->PParty && PChar->PParty->GetLeader() == PChar && - (PChar->PParty->m_PAlliance == nullptr || - (PChar->PParty->m_PAlliance->getMainParty() == PChar->PParty && !PChar->PParty->m_PAlliance->isFull()))) + if (PChar->PParty && PChar->PParty->GetLeader() == PChar && (PChar->PParty->m_PAlliance == nullptr || (PChar->PParty->m_PAlliance->getMainParty() == PChar->PParty && !PChar->PParty->m_PAlliance->isFull()))) { CCharEntity* PInvitee = nullptr; if (targid != 0) @@ -4393,8 +4357,7 @@ void SmallPacket0x06E(map_session_data_t* const PSession, CCharEntity* const PCh break; } // make sure intvitee isn't dead or in jail, they are an unallied party leader and don't already have an invite pending - if (PInvitee->isDead() || jailutils::InPrison(PInvitee) || PInvitee->InvitePending.id != 0 || PInvitee->PParty == nullptr || - PInvitee->PParty->GetLeader() != PInvitee || PInvitee->PParty->m_PAlliance) + if (PInvitee->isDead() || jailutils::InPrison(PInvitee) || PInvitee->InvitePending.id != 0 || PInvitee->PParty == nullptr || PInvitee->PParty->GetLeader() != PInvitee || PInvitee->PParty->m_PAlliance) { ShowDebug("%s is dead, in jail, has a pending invite, or is already in a party/alliance", PInvitee->getName()); PChar->pushPacket(new CMessageStandardPacket(PChar, 0, 0, MsgStd::CannotInvite)); @@ -4447,9 +4410,8 @@ void SmallPacket0x06F(map_session_data_t* const PSession, CCharEntity* const PCh { switch (data.ref(0x04)) { - case 0: // party - anyone may remove themself from party regardless of leadership or alliance - if (PChar->PParty->m_PAlliance && - PChar->PParty->HasOnlyOneMember()) // single member alliance parties must be removed from alliance before disband + case 0: // party - anyone may remove themself from party regardless of leadership or alliance + if (PChar->PParty->m_PAlliance && PChar->PParty->HasOnlyOneMember()) // single member alliance parties must be removed from alliance before disband { ShowDebug("%s party size is one", PChar->getName()); if (PChar->PParty->m_PAlliance->hasOnlyOneParty()) // if there is only 1 party then dissolve alliance @@ -4557,8 +4519,7 @@ void SmallPacket0x071(map_session_data_t* const PSession, CCharEntity* const PCh ShowDebug("%s is trying to kick %s from party", PChar->getName(), PVictim->getName()); if (PVictim == PChar) // using kick on yourself, let's borrow the logic from /pcmd leave to prevent alliance crash { - if (PChar->PParty->m_PAlliance && - PChar->PParty->HasOnlyOneMember()) // single member alliance parties must be removed from alliance before disband + if (PChar->PParty->m_PAlliance && PChar->PParty->HasOnlyOneMember()) // single member alliance parties must be removed from alliance before disband { if (PChar->PParty->m_PAlliance->hasOnlyOneParty()) // if there is only 1 party then dissolve alliance { @@ -4586,8 +4547,7 @@ void SmallPacket0x071(map_session_data_t* const PSession, CCharEntity* const PCh if (ret != SQL_ERROR && _sql->NumRows() == 1 && _sql->NextRow() == SQL_SUCCESS) { uint32 id = _sql->GetUIntData(0); - if (_sql->Query("DELETE FROM accounts_parties WHERE partyid = %u AND charid = %u", PChar->id, id) == SQL_SUCCESS && - _sql->AffectedRows()) + if (_sql->Query("DELETE FROM accounts_parties WHERE partyid = %u AND charid = %u", PChar->id, id) == SQL_SUCCESS && _sql->AffectedRows()) { ShowDebug("%s has removed %s from party", PChar->getName(), str(data[0x0C])); @@ -4690,8 +4650,9 @@ void SmallPacket0x071(map_session_data_t* const PSession, CCharEntity* const PCh { uint32 partyid = _sql->GetUIntData(0); if (_sql->Query("UPDATE accounts_parties SET allianceid = 0, partyflag = partyflag & ~%d WHERE partyid = %u", - PARTY_SECOND | PARTY_THIRD, partyid) == SQL_SUCCESS && - _sql->AffectedRows()) + PARTY_SECOND | PARTY_THIRD, partyid) + == SQL_SUCCESS + && _sql->AffectedRows()) { ShowDebug("%s has removed %s party from alliance", PChar->getName(), str(data[0x0C])); // notify party they were removed @@ -4902,8 +4863,7 @@ void SmallPacket0x077(map_session_data_t* const PSession, CCharEntity* const PCh break; case 5: // alliance { - if (PChar->PParty && PChar->PParty->m_PAlliance && PChar->PParty->GetLeader() == PChar && - PChar->PParty->m_PAlliance->getMainParty() == PChar->PParty) + if (PChar->PParty && PChar->PParty->m_PAlliance && PChar->PParty->GetLeader() == PChar && PChar->PParty->m_PAlliance->getMainParty() == PChar->PParty) { char memberName[PacketNameLength] = {}; memcpy(&memberName, data[0x04], PacketNameLength - 1); @@ -5121,7 +5081,7 @@ void SmallPacket0x096(map_session_data_t* const PSession, CCharEntity* const PCh if (PTarget) { ShowDebug("%s trade request with %s was canceled because %s tried to craft.", - PChar->getName(), PTarget->getName(), PChar->getName()); + PChar->getName(), PTarget->getName(), PChar->getName()); PTarget->TradePending.clean(); PTarget->UContainer->Clean(); @@ -5450,7 +5410,7 @@ void SmallPacket0x0AC(map_session_data_t* const PSession, CCharEntity* const PCh ShowInfo("SmallPacket0x0AC: Player '%s' sold %u of itemID %u [to GUILD] ", PChar->getName(), quantity, itemID); PChar->PGuildShop->GetItem(shopSlotID)->setQuantity(PChar->PGuildShop->GetItem(shopSlotID)->getQuantity() + quantity); PChar->pushPacket(new CGuildMenuSellUpdatePacket(PChar, PChar->PGuildShop->GetItem(PChar->PGuildShop->SearchItem(itemID))->getQuantity(), - itemID, quantity)); + itemID, quantity)); PChar->pushPacket(new CInventoryFinishPacket()); } } @@ -5576,7 +5536,7 @@ void SmallPacket0x0B5(map_session_data_t* const PSession, CCharEntity* const PCh ref(packetData, 0) = PChar->PLinkshell1->getID(); ref(packetData, 4) = PChar->id; message::send(MSG_CHAT_LINKSHELL, packetData, sizeof packetData, - new CChatMessagePacket(PChar, MESSAGE_LINKSHELL, (const char*)data[6])); + new CChatMessagePacket(PChar, MESSAGE_LINKSHELL, (const char*)data[6])); if (settings::get("map.AUDIT_CHAT") && settings::get("map.AUDIT_LINKSHELL")) { @@ -5604,7 +5564,7 @@ void SmallPacket0x0B5(map_session_data_t* const PSession, CCharEntity* const PCh ref(packetData, 0) = PChar->PLinkshell2->getID(); ref(packetData, 4) = PChar->id; message::send(MSG_CHAT_LINKSHELL, packetData, sizeof packetData, - new CChatMessagePacket(PChar, MESSAGE_LINKSHELL, (const char*)data[6])); + new CChatMessagePacket(PChar, MESSAGE_LINKSHELL, (const char*)data[6])); if (settings::get("map.AUDIT_CHAT") && settings::get("map.AUDIT_LINKSHELL")) { @@ -5707,7 +5667,7 @@ void SmallPacket0x0B5(map_session_data_t* const PSession, CCharEntity* const PCh ref(packetData, 0) = PChar->PUnityChat->getLeader(); ref(packetData, 4) = PChar->id; message::send(MSG_CHAT_UNITY, packetData, sizeof packetData, - new CChatMessagePacket(PChar, MESSAGE_UNITY, (const char*)data[6])); + new CChatMessagePacket(PChar, MESSAGE_UNITY, (const char*)data[6])); roeutils::event(ROE_EVENT::ROE_UNITY_CHAT, PChar, RoeDatagram("unityMessage", (const char*)data[6])); @@ -5756,8 +5716,7 @@ void SmallPacket0x0B6(map_session_data_t* const PSession, CCharEntity* const PCh memcpy(&message, data[messagePosition], std::min(data.getSize() - messagePosition, sizeof(message))); - if (strcmp(RecipientName.c_str(), "_CUSTOM_MENU") == 0 && - luautils::HasCustomMenuContext(PChar)) + if (strcmp(RecipientName.c_str(), "_CUSTOM_MENU") == 0 && luautils::HasCustomMenuContext(PChar)) { luautils::HandleCustomMenu(PChar, message); return; @@ -5921,8 +5880,7 @@ void SmallPacket0x0C3(map_session_data_t* const PSession, CCharEntity* const PCh PItemLinkshell = (CItemLinkshell*)PChar->getEquip(SLOT_LINK2); } - if (PItemLinkshell != nullptr && PItemLinkshell->isType(ITEM_LINKSHELL) && - (PItemLinkshell->GetLSType() == LSTYPE_PEARLSACK || PItemLinkshell->GetLSType() == LSTYPE_LINKSHELL)) + if (PItemLinkshell != nullptr && PItemLinkshell->isType(ITEM_LINKSHELL) && (PItemLinkshell->GetLSType() == LSTYPE_PEARLSACK || PItemLinkshell->GetLSType() == LSTYPE_LINKSHELL)) { CItemLinkshell* PItemLinkPearl = (CItemLinkshell*)itemutils::GetItem(515); if (PItemLinkPearl) @@ -5989,8 +5947,7 @@ void SmallPacket0x0C4(map_session_data_t* const PSession, CCharEntity* const PCh char extra[sizeof(PItemLinkshell->m_extra) * 2 + 1]; _sql->EscapeStringLen(extra, (const char*)PItemLinkshell->m_extra, sizeof(PItemLinkshell->m_extra)); - const char* Query = - "UPDATE char_inventory SET signature = '%s', extra = '%s', itemId = 513 WHERE charid = %u AND location = 0 AND slot = %u LIMIT 1"; + const char* Query = "UPDATE char_inventory SET signature = '%s', extra = '%s', itemId = 513 WHERE charid = %u AND location = 0 AND slot = %u LIMIT 1"; if (_sql->Query(Query, DecodedName, extra, PChar->id, SlotID) != SQL_ERROR && _sql->AffectedRows() != 0) { @@ -6202,7 +6159,7 @@ void SmallPacket0x0DB(map_session_data_t* const PSession, CCharEntity* const PCh // https://github.com/atom0s/XiPackets/tree/main/world/client/0x00DB struct packet_c2s_0DB_t { - uint16_t id : 9; + uint16_t id : 9; uint16_t size : 7; uint16_t sync; uint8_t unknown04; // Set to 0. @@ -6776,8 +6733,7 @@ void SmallPacket0x0E8(map_session_data_t* const PSession, CCharEntity* const PCh return; } - if (PChar->PPet == nullptr || - (PChar->PPet->m_EcoSystem != ECOSYSTEM::AVATAR && PChar->PPet->m_EcoSystem != ECOSYSTEM::ELEMENTAL && !PChar->PAI->IsEngaged())) + if (PChar->PPet == nullptr || (PChar->PPet->m_EcoSystem != ECOSYSTEM::AVATAR && PChar->PPet->m_EcoSystem != ECOSYSTEM::ELEMENTAL && !PChar->PAI->IsEngaged())) { PChar->PAI->ClearStateStack(); if (PChar->PPet && PChar->PPet->objtype == TYPE_PET && ((CPetEntity*)PChar->PPet)->getPetType() == PET_TYPE::AUTOMATON) @@ -7043,8 +6999,7 @@ void SmallPacket0x0FA(map_session_data_t* const PSession, CCharEntity* const PCh // Try to catch packet abuse, leading to gardening pots being placed on 2nd floor. if (on2ndFloor && PItem->isGardeningPot()) { - RATE_LIMIT(30s, ShowErrorFmt("{} has tried to gardening pot {} ({}) on 2nd floor", - PChar->getName(), PItem->getID(), PItem->getName())); + RATE_LIMIT(30s, ShowErrorFmt("{} has tried to gardening pot {} ({}) on 2nd floor", PChar->getName(), PItem->getID(), PItem->getName())); return; } @@ -7272,7 +7227,7 @@ void SmallPacket0x0FC(map_session_data_t* const PSession, CCharEntity* const PCh if (!PPotItem->isGardeningPot()) { ShowWarning(fmt::format("{} has tried to invalid gardening pot {} ({})", - PChar->getName(), PPotItem->getID(), PPotItem->getName())); + PChar->getName(), PPotItem->getID(), PPotItem->getName())); return; } @@ -7361,7 +7316,7 @@ void SmallPacket0x0FD(map_session_data_t* const PSession, CCharEntity* const PCh if (PItem->getExtraCrystalFeed() != FLOWERPOT_ELEMENT_NONE) { PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, CItemFlowerpot::getItemFromElement(PItem->getExtraCrystalFeed()), 0, - MSGBASIC_GARDENING_CRYSTAL_USED)); + MSGBASIC_GARDENING_CRYSTAL_USED)); } else { @@ -7374,7 +7329,7 @@ void SmallPacket0x0FD(map_session_data_t* const PSession, CCharEntity* const PCh if (PItem->getCommonCrystalFeed() != FLOWERPOT_ELEMENT_NONE) { PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, CItemFlowerpot::getItemFromElement(PItem->getCommonCrystalFeed()), 0, - MSGBASIC_GARDENING_CRYSTAL_USED)); + MSGBASIC_GARDENING_CRYSTAL_USED)); } else { @@ -7428,7 +7383,7 @@ void SmallPacket0x0FE(map_session_data_t* const PSession, CCharEntity* const PCh if (PItem->getOn2ndFloor() && PItem->isGardeningPot()) { ShowWarning(fmt::format("{} has tried to uproot gardening pot {} ({}) on 2nd floor", - PChar->getName(), PItem->getID(), PItem->getName())); + PChar->getName(), PItem->getID(), PItem->getName())); return; } @@ -8083,7 +8038,7 @@ void SmallPacket0x10A(map_session_data_t* const PSession, CCharEntity* const PCh if (PItem->getReserve() > 0) { ShowError("SmallPacket0x10A: Player %s trying to bazaar a RESERVED item! [Item: %i | Slot ID: %i] ", PChar->getName(), PItem->getID(), - slotID); + slotID); return; } @@ -8406,8 +8361,8 @@ void SmallPacket0x11D(map_session_data_t* const PSession, CCharEntity* const PCh return; } - auto const& targetIndex = data.ref(0x08); - auto const& extra = data.ref(0x0A); + const auto& targetIndex = data.ref(0x08); + const auto& extra = data.ref(0x0A); PChar->loc.zone->PushPacket(PChar, CHAR_INRANGE_SELF, new CCharEmotionJumpPacket(PChar, targetIndex, extra)); } diff --git a/src/map/packets/campaign_map.cpp b/src/map/packets/campaign_map.cpp index cbdf8f846cc..ee9db3b23fe 100644 --- a/src/map/packets/campaign_map.cpp +++ b/src/map/packets/campaign_map.cpp @@ -83,7 +83,7 @@ Region Order: 24 - Castle Zvahl Keep [S] 25 - Throne Room [S] */ -CCampaignPacket::CCampaignPacket(CCharEntity* PChar, CampaignState const& state, uint8 number) +CCampaignPacket::CCampaignPacket(CCharEntity* PChar, const CampaignState& state, uint8 number) { this->setType(0x71); this->setSize(0xCC); diff --git a/src/map/packets/campaign_map.h b/src/map/packets/campaign_map.h index 5561c34007c..0a59b25b110 100644 --- a/src/map/packets/campaign_map.h +++ b/src/map/packets/campaign_map.h @@ -32,7 +32,7 @@ class CCharEntity; class CCampaignPacket : public CBasicPacket { public: - CCampaignPacket(CCharEntity* PChar, CampaignState const& state, uint8 number); + CCampaignPacket(CCharEntity* PChar, const CampaignState& state, uint8 number); private: void SetRegions(std::vector areas, int start = 0); diff --git a/src/map/packets/char.h b/src/map/packets/char.h index 95f105b066b..6eeea372286 100644 --- a/src/map/packets/char.h +++ b/src/map/packets/char.h @@ -34,127 +34,127 @@ namespace charflags // PS2: (Non-defined bitfield type.) struct sendflags_t { - uint8_t Position : 1; + uint8_t Position : 1; uint8_t ClaimStatus : 1; - uint8_t General : 1; - uint8_t Name : 1; - uint8_t Model : 1; - uint8_t Despawn : 1; - uint8_t unused : 2; + uint8_t General : 1; + uint8_t Name : 1; + uint8_t Model : 1; + uint8_t Despawn : 1; + uint8_t unused : 2; }; // PS2: (Unnamed bitfield struct.) struct flags0_t { - uint32_t MovTime : 13; // PS2: MovTime - uint32_t RunMode : 1; // PS2: RunMode - uint32_t unknown_1_6 : 1; // PS2: TargetMode - uint32_t GroundFlag : 1; // PS2: GroundFlag - uint32_t KingFlag : 1; // PS2: KingFlag - uint32_t facetarget : 15; // PS2: facetarget + uint32_t MovTime : 13; // PS2: MovTime + uint32_t RunMode : 1; // PS2: RunMode + uint32_t unknown_1_6 : 1; // PS2: TargetMode + uint32_t GroundFlag : 1; // PS2: GroundFlag + uint32_t KingFlag : 1; // PS2: KingFlag + uint32_t facetarget : 15; // PS2: facetarget }; // PS2: (Unnamed bitfield struct.) struct flags1_t { - uint32_t MonsterFlag : 1; // PS2: MonsterFlag - uint32_t HideFlag : 1; // PS2: HideFlag - uint32_t SleepFlag : 1; // PS2: SleepFlag - uint32_t unknown_0_3 : 1; // PS2: MonStat - uint32_t unknown_0_4 : 1; // PS2: (unknown) - uint32_t ChocoboIndex : 3; // PS2: ChocoboIndex - uint32_t CliPosInitFlag : 1; // PS2: CliPosInitFlag - uint32_t GraphSize : 2; // PS2: GraphSize - uint32_t LfgFlag : 1; // PS2: LfgFlag - uint32_t AnonymousFlag : 1; // PS2: AnonymousFlag - uint32_t YellFlag : 1; // PS2: YellFlag - uint32_t AwayFlag : 1; // PS2: AwayFlag - uint32_t Gender : 1; // PS2: Gender + uint32_t MonsterFlag : 1; // PS2: MonsterFlag + uint32_t HideFlag : 1; // PS2: HideFlag + uint32_t SleepFlag : 1; // PS2: SleepFlag + uint32_t unknown_0_3 : 1; // PS2: MonStat + uint32_t unknown_0_4 : 1; // PS2: (unknown) + uint32_t ChocoboIndex : 3; // PS2: ChocoboIndex + uint32_t CliPosInitFlag : 1; // PS2: CliPosInitFlag + uint32_t GraphSize : 2; // PS2: GraphSize + uint32_t LfgFlag : 1; // PS2: LfgFlag + uint32_t AnonymousFlag : 1; // PS2: AnonymousFlag + uint32_t YellFlag : 1; // PS2: YellFlag + uint32_t AwayFlag : 1; // PS2: AwayFlag + uint32_t Gender : 1; // PS2: Gender uint32_t PlayOnelineFlag : 1; // PS2: PlayOnelineFlag - uint32_t LinkShellFlag : 1; // PS2: LinkShellFlag - uint32_t LinkDeadFlag : 1; // PS2: LinkDeadFlag - uint32_t TargetOffFlag : 1; // PS2: TargetOffFlag - uint32_t TalkUcoffFlag : 1; // PS2: TalkUcoffFlag - uint32_t unknown_2_5 : 1; // PS2: PartyLeaderFlg - uint32_t unknown_2_6 : 1; // PS2: AllianceLeaderFlg - uint32_t unknown_2_7 : 1; // PS2: DebugClientFlg - uint32_t GmLevel : 3; // PS2: GmLevel - uint32_t HackMove : 1; // PS2: HackMove - uint32_t unknown_3_4 : 1; // PS2: GMInvisFlag - uint32_t InvisFlag : 1; // PS2: InvisFlag - uint32_t TurnFlag : 1; // PS2: TurnFlag - uint32_t BazaarFlag : 1; // PS2: BazaarFlag + uint32_t LinkShellFlag : 1; // PS2: LinkShellFlag + uint32_t LinkDeadFlag : 1; // PS2: LinkDeadFlag + uint32_t TargetOffFlag : 1; // PS2: TargetOffFlag + uint32_t TalkUcoffFlag : 1; // PS2: TalkUcoffFlag + uint32_t unknown_2_5 : 1; // PS2: PartyLeaderFlg + uint32_t unknown_2_6 : 1; // PS2: AllianceLeaderFlg + uint32_t unknown_2_7 : 1; // PS2: DebugClientFlg + uint32_t GmLevel : 3; // PS2: GmLevel + uint32_t HackMove : 1; // PS2: HackMove + uint32_t unknown_3_4 : 1; // PS2: GMInvisFlag + uint32_t InvisFlag : 1; // PS2: InvisFlag + uint32_t TurnFlag : 1; // PS2: TurnFlag + uint32_t BazaarFlag : 1; // PS2: BazaarFlag }; // PS2: (Unnamed bitfield struct.) struct flags2_t { - uint32_t r : 8; // PS2: r - uint32_t g : 8; // PS2: g - uint32_t b : 8; // PS2: b - uint32_t PvPFlag : 1; // PS2: PvPFlag - uint32_t ShadowFlag : 1; // PS2: ShadowFlag + uint32_t r : 8; // PS2: r + uint32_t g : 8; // PS2: g + uint32_t b : 8; // PS2: b + uint32_t PvPFlag : 1; // PS2: PvPFlag + uint32_t ShadowFlag : 1; // PS2: ShadowFlag uint32_t ShipStartMode : 1; // PS2: ShipStartMode - uint32_t CharmFlag : 1; // PS2: CharmFlag - uint32_t GmIconFlag : 1; // PS2: GmIconFlag - uint32_t NamedFlag : 1; // PS2: NamedFlag - uint32_t SingleFlag : 1; // PS2: SingleFlag + uint32_t CharmFlag : 1; // PS2: CharmFlag + uint32_t GmIconFlag : 1; // PS2: GmIconFlag + uint32_t NamedFlag : 1; // PS2: NamedFlag + uint32_t SingleFlag : 1; // PS2: SingleFlag uint32_t AutoPartyFlag : 1; // PS2: AutoPartyFlag }; // PS2: (Unnamed bitfield struct. This has been fully repurposed.) struct flags3_t { - uint32_t TrustFlag : 1; // PS2: (New; replaced 'PetMode'.) - uint32_t LfgMasterFlag : 1; // PS2: (New; replaced 'PetMode'.) - uint32_t PetNewFlag : 1; // PS2: PetNewFlag - uint32_t unknown_0_3 : 1; // PS2: PetKillFlag - uint32_t MotStopFlag : 1; // PS2: MotStopFlag - uint32_t CliPriorityFlag : 1; // PS2: CliPriorityFlag - uint32_t PetFlag : 1; // PS2: NpcPetFlag + uint32_t TrustFlag : 1; // PS2: (New; replaced 'PetMode'.) + uint32_t LfgMasterFlag : 1; // PS2: (New; replaced 'PetMode'.) + uint32_t PetNewFlag : 1; // PS2: PetNewFlag + uint32_t unknown_0_3 : 1; // PS2: PetKillFlag + uint32_t MotStopFlag : 1; // PS2: MotStopFlag + uint32_t CliPriorityFlag : 1; // PS2: CliPriorityFlag + uint32_t PetFlag : 1; // PS2: NpcPetFlag uint32_t OcclusionoffFlag : 1; // PS2: OcclusionoffFlag - uint32_t BallistaTeam : 8; // PS2: (New; did not exist.) - uint32_t MonStat : 3; // PS2: (New; did not exist.) - uint32_t unknown_2_3 : 1; // PS2: (New; did not exist.) - uint32_t unknown_2_4 : 1; // PS2: (New; did not exist.) - uint32_t SilenceFlag : 1; // PS2: (New; did not exist.) - uint32_t unknown_2_6 : 1; // PS2: (New; did not exist.) + uint32_t BallistaTeam : 8; // PS2: (New; did not exist.) + uint32_t MonStat : 3; // PS2: (New; did not exist.) + uint32_t unknown_2_3 : 1; // PS2: (New; did not exist.) + uint32_t unknown_2_4 : 1; // PS2: (New; did not exist.) + uint32_t SilenceFlag : 1; // PS2: (New; did not exist.) + uint32_t unknown_2_6 : 1; // PS2: (New; did not exist.) uint32_t NewCharacterFlag : 1; // PS2: (New; did not exist.) - uint32_t MentorFlag : 1; // PS2: (New; did not exist.) - uint32_t unknown_3_1 : 1; // PS2: (New; did not exist.) - uint32_t unknown_3_2 : 1; // PS2: (New; did not exist.) - uint32_t unknown_3_3 : 1; // PS2: (New; did not exist.) - uint32_t unknown_3_4 : 1; // PS2: (New; did not exist.) - uint32_t unknown_3_5 : 1; // PS2: (New; did not exist.) - uint32_t unknown_3_6 : 1; // PS2: (New; did not exist.) - uint32_t unknown_3_7 : 1; // PS2: (New; did not exist.) + uint32_t MentorFlag : 1; // PS2: (New; did not exist.) + uint32_t unknown_3_1 : 1; // PS2: (New; did not exist.) + uint32_t unknown_3_2 : 1; // PS2: (New; did not exist.) + uint32_t unknown_3_3 : 1; // PS2: (New; did not exist.) + uint32_t unknown_3_4 : 1; // PS2: (New; did not exist.) + uint32_t unknown_3_5 : 1; // PS2: (New; did not exist.) + uint32_t unknown_3_6 : 1; // PS2: (New; did not exist.) + uint32_t unknown_3_7 : 1; // PS2: (New; did not exist.) }; // PS2: (New; did not exist.) struct flags4_t { - uint8_t unknown_0_0 : 1; // PS2: (New; did not exist.) - uint8_t TrialFlag : 1; // PS2: (New; did not exist.) - uint8_t unknown_0_2 : 2; // PS2: (New; did not exist.) - uint8_t unknown_0_4 : 2; // PS2: (New; did not exist.) + uint8_t unknown_0_0 : 1; // PS2: (New; did not exist.) + uint8_t TrialFlag : 1; // PS2: (New; did not exist.) + uint8_t unknown_0_2 : 2; // PS2: (New; did not exist.) + uint8_t unknown_0_4 : 2; // PS2: (New; did not exist.) uint8_t JobMasterFlag : 1; // PS2: (New; did not exist.) - uint8_t unknown_0_7 : 1; // PS2: (New; did not exist.) + uint8_t unknown_0_7 : 1; // PS2: (New; did not exist.) }; // PS2: (New; did not exist.) struct flags5_t { uint8_t GeoIndiElement : 4; // PS2: (New; did not exist.) - uint8_t GeoIndiSize : 2; // PS2: (New; did not exist.) - uint8_t GeoIndiFlag : 1; // PS2: (New; did not exist.) - uint8_t unknown_0_7 : 1; // PS2: (New; did not exist.) + uint8_t GeoIndiSize : 2; // PS2: (New; did not exist.) + uint8_t GeoIndiFlag : 1; // PS2: (New; did not exist.) + uint8_t unknown_0_7 : 1; // PS2: (New; did not exist.) }; // PS2: (New; did not exist.) struct flags6_t { - uint32_t GateId : 4; // PS2: (New; did not exist.) - uint32_t MountIndex : 8; // PS2: (New; did not exist.) + uint32_t GateId : 4; // PS2: (New; did not exist.) + uint32_t MountIndex : 8; // PS2: (New; did not exist.) uint32_t unknown_1_3 : 20; // PS2: (New; did not exist.) }; } // namespace charflags @@ -162,7 +162,7 @@ namespace charflags // PS2: GP_SERV_CHAR_PC struct GP_SERV_CHAR_PC { - uint16_t id : 9; + uint16_t id : 9; uint16_t size : 7; uint16_t sync; diff --git a/src/map/packets/char_emote_list.h b/src/map/packets/char_emote_list.h index 1fdc5dd64e9..c2593f6cc77 100644 --- a/src/map/packets/char_emote_list.h +++ b/src/map/packets/char_emote_list.h @@ -26,7 +26,7 @@ #include "basic.h" -std::vector const jobGestureKeyItems = { +const std::vector jobGestureKeyItems = { "JOB_GESTURE_WARRIOR", "JOB_GESTURE_MONK", "JOB_GESTURE_WHITE_MAGE", @@ -51,7 +51,7 @@ std::vector const jobGestureKeyItems = { "JOB_GESTURE_RUNE_FENCER", }; -std::vector const chairKeyItems = { +const std::vector chairKeyItems = { "IMPERIAL_CHAIR", "DECORATIVE_CHAIR", "ORNATE_STOOL", diff --git a/src/map/packets/char_jobs.cpp b/src/map/packets/char_jobs.cpp index 5e715a0ebef..0fc9482776f 100644 --- a/src/map/packets/char_jobs.cpp +++ b/src/map/packets/char_jobs.cpp @@ -47,9 +47,8 @@ CCharJobsPacket::CCharJobsPacket(CCharEntity* PChar) ref(0x44) = PChar->jobs.unlocked & 1; // The first bit in jobs.unlocked is responsible for an additional job - ref(0x60) = PChar->m_EquipBlock; // Locked equipment slots - ref(0x62) = - PChar->m_StatsDebilitation; // Bit field. Underestimation of physical characteristics, the characteristic turns red and a red arrlow appears next to it. + ref(0x60) = PChar->m_EquipBlock; // Locked equipment slots + ref(0x62) = PChar->m_StatsDebilitation; // Bit field. Underestimation of physical characteristics, the characteristic turns red and a red arrlow appears next to it. ref(0x64) = 0x01; // Unknown, set due to Retail reference; suspicion around mentor unlock ref(0x65) = 0; // Mentor Icon diff --git a/src/map/packets/char_update.cpp b/src/map/packets/char_update.cpp index fe20d6c2771..120e468d3a9 100644 --- a/src/map/packets/char_update.cpp +++ b/src/map/packets/char_update.cpp @@ -41,75 +41,75 @@ namespace charUpateFlags { struct flags0_t { - uint32_t HideFlag : 1; - uint32_t SleepFlag : 1; - uint32_t GroundFlag : 1; - uint32_t CliPosInitFlag : 1; - uint32_t LfgFlag : 1; - uint32_t AnonymousFlag : 1; - uint32_t CfhFlag : 1; - uint32_t AwayFlag : 1; - uint32_t Gender : 1; - uint32_t unknown_1_9 : 1; - uint32_t unknown_1_10 : 1; - uint32_t GraphSize : 2; - uint32_t Chocobo_Index : 3; - uint32_t hpp : 8; + uint32_t HideFlag : 1; + uint32_t SleepFlag : 1; + uint32_t GroundFlag : 1; + uint32_t CliPosInitFlag : 1; + uint32_t LfgFlag : 1; + uint32_t AnonymousFlag : 1; + uint32_t CfhFlag : 1; + uint32_t AwayFlag : 1; + uint32_t Gender : 1; + uint32_t unknown_1_9 : 1; + uint32_t unknown_1_10 : 1; + uint32_t GraphSize : 2; + uint32_t Chocobo_Index : 3; + uint32_t hpp : 8; uint32_t PlayOnelineFlag : 1; - uint32_t LinkShellFlag : 1; - uint32_t LinkDeadFlag : 1; - uint32_t TargetOffFlag : 1; - uint32_t unknown_3_28 : 1; - uint32_t GmLevel : 3; + uint32_t LinkShellFlag : 1; + uint32_t LinkDeadFlag : 1; + uint32_t TargetOffFlag : 1; + uint32_t unknown_3_28 : 1; + uint32_t GmLevel : 3; }; struct flags1_t { - uint32_t Speed : 12; - uint32_t Hackmove : 1; - uint32_t FreezeFlag : 1; + uint32_t Speed : 12; + uint32_t Hackmove : 1; + uint32_t FreezeFlag : 1; uint32_t unknown_1_14 : 1; - uint32_t InvisFlag : 1; + uint32_t InvisFlag : 1; uint32_t unknown_2_16 : 1; - uint32_t SpeedBase : 8; + uint32_t SpeedBase : 8; uint32_t unknown_3_25 : 4; - uint32_t BazaarFlag : 1; - uint32_t CharmFlag : 1; - uint32_t GmIconFlag : 1; + uint32_t BazaarFlag : 1; + uint32_t CharmFlag : 1; + uint32_t GmIconFlag : 1; }; struct flags2_t { - uint32_t NamedFlag : 1; - uint32_t SingleFlag : 1; - uint32_t AutoPartyFlag : 1; - uint32_t PetIndex : 16; - uint32_t MotStopFlag : 1; + uint32_t NamedFlag : 1; + uint32_t SingleFlag : 1; + uint32_t AutoPartyFlag : 1; + uint32_t PetIndex : 16; + uint32_t MotStopFlag : 1; uint32_t CliPriorityFlag : 1; - uint32_t BallistaFlg : 8; - uint32_t unknown_3_29 : 3; + uint32_t BallistaFlg : 8; + uint32_t unknown_3_29 : 3; }; struct flags3_t { - uint32_t LfgMasterFlag : 1; - uint32_t TrialFlag : 1; - uint32_t SilenceFlag : 1; + uint32_t LfgMasterFlag : 1; + uint32_t TrialFlag : 1; + uint32_t SilenceFlag : 1; uint32_t NewCharacterFlag : 1; - uint32_t MentorFlag : 1; - uint32_t unknown_0_5 : 1; - uint32_t unknown_0_6 : 1; - uint32_t unknown_0_7 : 1; - uint32_t BallistaTeam : 8; - uint32_t unknown_2_16 : 16; + uint32_t MentorFlag : 1; + uint32_t unknown_0_5 : 1; + uint32_t unknown_0_6 : 1; + uint32_t unknown_0_7 : 1; + uint32_t BallistaTeam : 8; + uint32_t unknown_2_16 : 16; }; struct flags4_t { uint8_t GeoIndiElement : 4; - uint8_t GeoIndiSize : 2; - uint8_t GeoIndiFlag : 1; - uint8_t JobMasterFlag : 1; + uint8_t GeoIndiSize : 2; + uint8_t GeoIndiFlag : 1; + uint8_t JobMasterFlag : 1; }; struct flags5_t @@ -134,15 +134,15 @@ namespace charUpateFlags struct status_bits_t { - uint8_t Status1 : 2; - uint8_t Status2 : 2; - uint8_t Status3 : 2; - uint8_t Status4 : 2; - uint8_t Status5 : 2; - uint8_t Status6 : 2; - uint8_t Status7 : 2; - uint8_t Status8 : 2; - uint8_t Status9 : 2; + uint8_t Status1 : 2; + uint8_t Status2 : 2; + uint8_t Status3 : 2; + uint8_t Status4 : 2; + uint8_t Status5 : 2; + uint8_t Status6 : 2; + uint8_t Status7 : 2; + uint8_t Status8 : 2; + uint8_t Status9 : 2; uint8_t Status10 : 2; uint8_t Status11 : 2; uint8_t Status12 : 2; @@ -171,7 +171,7 @@ struct status_bits_t // PS2: GP_SERV_SERVERSTATUS struct GP_SERV_SERVERSTATUS { - uint16_t id : 9; + uint16_t id : 9; uint16_t size : 7; uint16_t sync; uint8_t BufStatus[32]; // PS2: BufStatus diff --git a/src/map/packets/chat_message.cpp b/src/map/packets/chat_message.cpp index c6c669dce1d..4adcca40c82 100644 --- a/src/map/packets/chat_message.cpp +++ b/src/map/packets/chat_message.cpp @@ -24,7 +24,7 @@ #include "entities/charentity.h" #include -CChatMessagePacket::CChatMessagePacket(CCharEntity* PChar, CHAT_MESSAGE_TYPE MessageType, std::string const& message, std::string const& sender) +CChatMessagePacket::CChatMessagePacket(CCharEntity* PChar, CHAT_MESSAGE_TYPE MessageType, const std::string& message, const std::string& sender) { // there seems to be some sort of variable cap on the length of the packet, which I cannot determine // (it changed when zoning, but not when zoning back) @@ -32,7 +32,7 @@ CChatMessagePacket::CChatMessagePacket(CCharEntity* PChar, CHAT_MESSAGE_TYPE Mes // variable in the same way, and is probably so under the same circumstances // until that can be found, we'll just use the max length auto buffSize = std::min(message.size(), 236); - std::string const& name = sender.empty() ? PChar->getName() : sender; + const std::string& name = sender.empty() ? PChar->getName() : sender; // Build the packet.. // CBasicPacket::id(id); diff --git a/src/map/packets/chat_message.h b/src/map/packets/chat_message.h index b3ae2f5a701..2ff72dbe752 100644 --- a/src/map/packets/chat_message.h +++ b/src/map/packets/chat_message.h @@ -83,7 +83,7 @@ class CChatMessagePacket : public CBasicPacket { public: static const uint16 id{ 0x17 }; - CChatMessagePacket(CCharEntity* PChar, CHAT_MESSAGE_TYPE MessageType, std::string const& message, std::string const& sender = std::string()); + CChatMessagePacket(CCharEntity* PChar, CHAT_MESSAGE_TYPE MessageType, const std::string& message, const std::string& sender = std::string()); }; #endif diff --git a/src/map/packets/delivery_box.cpp b/src/map/packets/delivery_box.cpp index 0e4a4dd5550..a945b506e57 100644 --- a/src/map/packets/delivery_box.cpp +++ b/src/map/packets/delivery_box.cpp @@ -76,13 +76,13 @@ CDeliveryBoxPacket::CDeliveryBoxPacket(uint8 action, uint8 boxid, CItem* PItem, { ref(0x10) = 0x07; memcpy(data + 0x14, PItem->getSender().c_str(), - PItem->getSender().size()); // Sender's name. Client disables "Return" if it starts with "AH" + PItem->getSender().size()); // Sender's name. Client disables "Return" if it starts with "AH" } else { ref(0x10) = PItem->isSent() ? 0x03 : 0x05; // 0x05 in send: canceled. other values are unknown memcpy(data + 0x14, PItem->getReceiver().c_str(), - PItem->getReceiver().size()); // Receiver's name. Client disables "Return" if it starts with "AH" + PItem->getReceiver().size()); // Receiver's name. Client disables "Return" if it starts with "AH" } } if (action == 0x02) diff --git a/src/map/packets/event_string.cpp b/src/map/packets/event_string.cpp index 02f5ab051ce..91651faa661 100644 --- a/src/map/packets/event_string.cpp +++ b/src/map/packets/event_string.cpp @@ -64,7 +64,7 @@ CEventStringPacket::CEventStringPacket(CCharEntity* PChar, EventInfo* eventInfo) ref(0x0E) = 8; // if the parameter is less than 8, then after the event is over the camera will "jump" behind the character } - for (auto const& stringPair : eventInfo->strings) + for (const auto& stringPair : eventInfo->strings) { memcpy(data + 0x10 + 0x10 * stringPair.first, stringPair.second.c_str(), stringPair.second.size()); } diff --git a/src/map/packets/event_update.cpp b/src/map/packets/event_update.cpp index 9d3f1a222b3..7789458fc2f 100644 --- a/src/map/packets/event_update.cpp +++ b/src/map/packets/event_update.cpp @@ -24,7 +24,7 @@ #include "entities/charentity.h" #include "event_update.h" -CEventUpdatePacket::CEventUpdatePacket(std::vector> const& params) +CEventUpdatePacket::CEventUpdatePacket(const std::vector>& params) { this->setType(0x5C); this->setSize(0x24); diff --git a/src/map/packets/event_update.h b/src/map/packets/event_update.h index 7492c1e2572..79af6caceb4 100644 --- a/src/map/packets/event_update.h +++ b/src/map/packets/event_update.h @@ -29,7 +29,7 @@ class CEventUpdatePacket : public CBasicPacket { public: - CEventUpdatePacket(std::vector> const& params); + CEventUpdatePacket(const std::vector>& params); }; #endif diff --git a/src/map/packets/event_update_string.cpp b/src/map/packets/event_update_string.cpp index e78b453277a..a9275692a98 100644 --- a/src/map/packets/event_update_string.cpp +++ b/src/map/packets/event_update_string.cpp @@ -26,9 +26,9 @@ #include "entities/charentity.h" #include "event_update_string.h" -CEventUpdateStringPacket::CEventUpdateStringPacket(std::string const& string0, std::string const& string1, std::string const& string2, - std::string const& string3, uint32 param0, uint32 param1, uint32 param2, uint32 param3, uint32 param4, - uint32 param5, uint32 param6, uint32 param7, uint32 param8) +CEventUpdateStringPacket::CEventUpdateStringPacket(const std::string& string0, const std::string& string1, const std::string& string2, + const std::string& string3, uint32 param0, uint32 param1, uint32 param2, uint32 param3, uint32 param4, + uint32 param5, uint32 param6, uint32 param7, uint32 param8) { this->setType(0x5D); this->setSize(0x68); diff --git a/src/map/packets/event_update_string.h b/src/map/packets/event_update_string.h index c2769fddb46..9beebac1967 100644 --- a/src/map/packets/event_update_string.h +++ b/src/map/packets/event_update_string.h @@ -34,9 +34,9 @@ class CCharEntity; class CEventUpdateStringPacket : public CBasicPacket { public: - CEventUpdateStringPacket(std::string const& string0 = "", std::string const& string1 = "", std::string const& string2 = "", std::string const& string3 = "", - uint32 param0 = 0, uint32 param1 = 0, uint32 param2 = 0, uint32 param3 = 0, uint32 param4 = 0, uint32 param5 = 0, - uint32 param6 = 0, uint32 param7 = 0, uint32 param8 = 0); + CEventUpdateStringPacket(const std::string& string0 = "", const std::string& string1 = "", const std::string& string2 = "", const std::string& string3 = "", + uint32 param0 = 0, uint32 param1 = 0, uint32 param2 = 0, uint32 param3 = 0, uint32 param4 = 0, uint32 param5 = 0, + uint32 param6 = 0, uint32 param7 = 0, uint32 param8 = 0); }; #endif diff --git a/src/map/packets/fishing.cpp b/src/map/packets/fishing.cpp index 03d29b108c5..cdcadc6c8a6 100644 --- a/src/map/packets/fishing.cpp +++ b/src/map/packets/fishing.cpp @@ -52,7 +52,7 @@ // New Fishing Packet: Mini-Game Data. CFishingPacket::CFishingPacket(uint16 stamina, uint16 regen, uint16 response, uint16 hitDmg, uint16 arrowDelay, uint16 missRegen, uint16 gameTime, uint8 sense, - uint32 special) + uint32 special) { this->setType(0x115); this->setSize(0x1A); @@ -69,8 +69,7 @@ CFishingPacket::CFishingPacket(uint16 stamina, uint16 regen, uint16 response, ui // Ring is equipped with fishing support in effect, this value also decreases (investigating on decrease amount, seems like // 10% decrease rounded to nearest 10 or 20 if not integer result). ref(0x10) = gameTime; // how long you have to reel the fish in (base 60s) - ref(0x12) = - sense; // 0 = small fish/item, 1 = large fish/monster (battle music), 2 = small fish/item (lightbulb), 3 = large fish/monster (lightbulb + fight music) - ref(0x14) = special; // value will be returned in 0x110 on catch (LSB represents % chance of getting gold arrows while fishing) - value increases on - // use of "Duck ring" or on angler's discernment proc, both of which increase chance of gold arrows + ref(0x12) = sense; // 0 = small fish/item, 1 = large fish/monster (battle music), 2 = small fish/item (lightbulb), 3 = large fish/monster (lightbulb + fight music) + ref(0x14) = special; // value will be returned in 0x110 on catch (LSB represents % chance of getting gold arrows while fishing) - value increases on + // use of "Duck ring" or on angler's discernment proc, both of which increase chance of gold arrows } diff --git a/src/map/packets/fishing.h b/src/map/packets/fishing.h index bc29c3e0376..f9c7f7ffd3e 100644 --- a/src/map/packets/fishing.h +++ b/src/map/packets/fishing.h @@ -30,7 +30,7 @@ class CFishingPacket : public CBasicPacket { public: CFishingPacket(uint16 stamina, uint16 regen, uint16 response, uint16 hitDmg, uint16 arrowDelay, uint16 missRegen, uint16 gameTime, uint8 sense, - uint32 special); + uint32 special); }; #endif diff --git a/src/map/packets/menu_config.cpp b/src/map/packets/menu_config.cpp index c8089403cdc..1d77283dcaf 100644 --- a/src/map/packets/menu_config.cpp +++ b/src/map/packets/menu_config.cpp @@ -27,7 +27,7 @@ struct GP_SERV_CONFIG { - uint16_t id : 9; + uint16_t id : 9; uint16_t size : 7; uint16_t sync; SAVE_CONF ConfData; // PS2: ConfData diff --git a/src/map/packets/message_name.cpp b/src/map/packets/message_name.cpp index 42b69eb1b76..61814effc01 100644 --- a/src/map/packets/message_name.cpp +++ b/src/map/packets/message_name.cpp @@ -24,8 +24,8 @@ #include "entities/baseentity.h" CMessageNamePacket::CMessageNamePacket(CBaseEntity* PActor, uint16 messageID, CBaseEntity* PNameActor /* = nullptr*/, int32 param0 /* = 0*/, - int32 param1 /* = 0*/, int32 param2 /* = 0*/, int32 param3 /* = 0*/, int32 chatType /* = 4*/, - bool showSender /* = false*/) + int32 param1 /* = 0*/, int32 param2 /* = 0*/, int32 param3 /* = 0*/, int32 chatType /* = 4*/, + bool showSender /* = false*/) { this->setType(0x27); this->setSize(0x70); diff --git a/src/map/packets/message_name.h b/src/map/packets/message_name.h index 7034c1f9a57..8a10b9982b8 100644 --- a/src/map/packets/message_name.h +++ b/src/map/packets/message_name.h @@ -38,7 +38,7 @@ class CMessageNamePacket : public CBasicPacket { public: CMessageNamePacket(CBaseEntity* PActor, uint16 messageID, CBaseEntity* PNameActor = nullptr, int32 param0 = 0, int32 param1 = 0, int32 param2 = 0, - int32 param3 = 0, int32 chatType = 4, bool showSender = false); + int32 param3 = 0, int32 chatType = 4, bool showSender = false); }; #endif // _CMESSAGENAMEPACKET_H_ diff --git a/src/map/packets/message_special.h b/src/map/packets/message_special.h index d4812e63262..22a75104254 100644 --- a/src/map/packets/message_special.h +++ b/src/map/packets/message_special.h @@ -32,7 +32,7 @@ class CMessageSpecialPacket : public CBasicPacket { public: CMessageSpecialPacket(CBaseEntity* PEntity, uint16 messageID, uint32 param0 = 0, uint32 param1 = 0, uint32 param2 = 0, uint32 param3 = 0, - bool ShowName = false); + bool ShowName = false); }; #endif diff --git a/src/map/packets/send_blacklist.cpp b/src/map/packets/send_blacklist.cpp index 76f715c48b3..5765605b403 100644 --- a/src/map/packets/send_blacklist.cpp +++ b/src/map/packets/send_blacklist.cpp @@ -36,7 +36,7 @@ struct SAVE_BLACK // PS2: GP_BLACK_LIST struct GP_BLACK_LIST { - uint16_t id : 9; + uint16_t id : 9; uint16_t size : 7; uint16_t sync; SAVE_BLACK List[12]; // PS2: List diff --git a/src/map/packets/zone_in.cpp b/src/map/packets/zone_in.cpp index 3576db86a73..47697766f3f 100644 --- a/src/map/packets/zone_in.cpp +++ b/src/map/packets/zone_in.cpp @@ -93,7 +93,7 @@ struct SAVE_CONF_PKT // PS2: GP_SERV_LOGIN struct GP_SERV_LOGIN { - uint16_t id : 9; + uint16_t id : 9; uint16_t size : 7; uint16_t sync; GP_SERV_POS_HEAD PosHead; // PS2: PosHead @@ -329,7 +329,7 @@ CZoneInPacket::CZoneInPacket(CCharEntity* PChar, const EventInfo* currentEvent) ref(0xAF) = PChar->loc.zone->CanUseMisc(MISC_MOGMENU); // flag allows you to use Mog Menu outside Mog House } - auto const& nameStr = PChar->getName(); + const auto& nameStr = PChar->getName(); std::memcpy(data + 0x84, nameStr.data(), nameStr.size()); ref(0xA0) = PChar->GetPlayTime(); // time spent by the character in the game from the moment of creation diff --git a/src/map/party.cpp b/src/map/party.cpp index 2783c1efbcc..e7d9bca26d8 100644 --- a/src/map/party.cpp +++ b/src/map/party.cpp @@ -189,7 +189,7 @@ void CParty::AssignPartyRole(const std::string& MemberName, uint8 role) // Make sure that the the character is actually a part of this party int ret = _sql->Query("SELECT chars.charid FROM chars \ JOIN accounts_parties ON accounts_parties.charid = chars.charid WHERE charname = '%s' AND partyid = %u", - MemberName, m_PartyID); + MemberName, m_PartyID); if (ret == SQL_ERROR || _sql->NumRows() == 0) { return; @@ -501,7 +501,7 @@ bool CParty::RemovePartyLeader(CBattleEntity* PEntity) int ret = _sql->Query("SELECT charname FROM accounts_sessions JOIN chars ON accounts_sessions.charid = chars.charid \ JOIN accounts_parties ON accounts_parties.charid = chars.charid WHERE partyid = %u AND NOT partyflag & %d \ ORDER BY timestamp ASC LIMIT 1", - m_PartyID, PARTY_LEADER); + m_PartyID, PARTY_LEADER); if (ret != SQL_ERROR && _sql->NumRows() != 0 && _sql->NextRow() == SQL_SUCCESS) { std::string newLeader((const char*)_sql->GetData(0)); @@ -540,15 +540,15 @@ std::vector CParty::GetPartyInfo() const int ret = _sql->Query("SELECT chars.charid, partyid, allianceid, charname, partyflag, pos_zone, pos_prevzone FROM accounts_parties \ LEFT JOIN chars ON accounts_parties.charid = chars.charid WHERE \ (allianceid <> 0 AND allianceid = %d) OR partyid = %d ORDER BY partyflag & %u, timestamp", - m_PAlliance ? m_PAlliance->m_AllianceID : 0, m_PartyID, PARTY_SECOND | PARTY_THIRD); + m_PAlliance ? m_PAlliance->m_AllianceID : 0, m_PartyID, PARTY_SECOND | PARTY_THIRD); if (ret != SQL_ERROR && _sql->NumRows() != 0) { while (_sql->NextRow() == SQL_SUCCESS) { memberinfo.emplace_back(CParty::partyInfo_t{ _sql->GetUIntData(0), _sql->GetUIntData(1), _sql->GetUIntData(2), - std::string((const char*)_sql->GetData(3)), static_cast(_sql->GetUIntData(4)), - static_cast(_sql->GetUIntData(5)), static_cast(_sql->GetUIntData(6)) }); + std::string((const char*)_sql->GetData(3)), static_cast(_sql->GetUIntData(4)), + static_cast(_sql->GetUIntData(5)), static_cast(_sql->GetUIntData(6)) }); } } return memberinfo; @@ -604,7 +604,7 @@ void CParty::AddMember(CBattleEntity* PEntity) } _sql->Query("INSERT INTO accounts_parties (charid, partyid, allianceid, partyflag) VALUES (%u, %u, %u, %u)", PChar->id, m_PartyID, allianceid, - GetMemberFlags(PChar)); + GetMemberFlags(PChar)); uint8 data[4]{}; if (m_PAlliance) { @@ -676,7 +676,7 @@ void CParty::AddMember(uint32 id) } } _sql->Query("INSERT INTO accounts_parties (charid, partyid, allianceid, partyflag) VALUES (%u, %u, %u, %u)", id, m_PartyID, allianceid, - Flags); + Flags); uint8 data[4]{}; if (m_PAlliance) { @@ -1028,7 +1028,7 @@ void CParty::SetLeader(const std::string& MemberName) } _sql->Query("UPDATE accounts_parties SET partyflag = partyflag & ~%d WHERE partyid = %u AND partyflag & %d", ALLIANCE_LEADER | PARTY_LEADER, - m_PartyID, PARTY_LEADER); + m_PartyID, PARTY_LEADER); _sql->Query("UPDATE accounts_parties SET partyid = %u WHERE partyid = %u", newId, m_PartyID); _sql->Query("UPDATE accounts_parties SET allianceid = %u WHERE allianceid = %u", newId, m_PartyID); @@ -1040,7 +1040,7 @@ void CParty::SetLeader(const std::string& MemberName) m_PartyID = newId; _sql->Query("UPDATE accounts_parties SET partyflag = partyflag | IF(allianceid = partyid, %d, %d) WHERE charid = %u", - ALLIANCE_LEADER | PARTY_LEADER, PARTY_LEADER, newId); + ALLIANCE_LEADER | PARTY_LEADER, PARTY_LEADER, newId); // Passing leader dismisses trusts for (auto* PMemberEntity : members) @@ -1106,9 +1106,9 @@ void CParty::SetSyncTarget(const std::string& MemberName, MsgStd message) } } _sql->Query("UPDATE accounts_parties SET partyflag = partyflag & ~%d WHERE partyid = %u AND partyflag & %d", PARTY_SYNC, m_PartyID, - PARTY_SYNC); + PARTY_SYNC); _sql->Query("UPDATE accounts_parties SET partyflag = partyflag | %d WHERE partyid = %u AND charid = '%u'", PARTY_SYNC, m_PartyID, - PChar->id); + PChar->id); } } else @@ -1139,7 +1139,7 @@ void CParty::SetSyncTarget(const std::string& MemberName, MsgStd message) } m_PSyncTarget = nullptr; _sql->Query("UPDATE accounts_parties SET partyflag = partyflag & ~%d WHERE partyid = %u AND partyflag & %d", PARTY_SYNC, m_PartyID, - PARTY_SYNC); + PARTY_SYNC); } } } @@ -1154,7 +1154,7 @@ void CParty::SetQuarterMaster(const std::string& MemberName) { _sql->Query("UPDATE accounts_parties JOIN chars ON accounts_parties.charid = chars.charid \ SET partyflag = partyflag | %d WHERE partyid = %u AND charname = '%s'", - PARTY_QM, m_PartyID, MemberName); + PARTY_QM, m_PartyID, MemberName); } } diff --git a/src/map/recast_container.cpp b/src/map/recast_container.cpp index 0c7f9887a3a..d9c1e299c35 100644 --- a/src/map/recast_container.cpp +++ b/src/map/recast_container.cpp @@ -170,8 +170,10 @@ void CRecastContainer::Del(RECASTTYPE type, uint16 id) else { PRecastList->erase(std::remove_if(PRecastList->begin(), PRecastList->end(), [&id](auto& recast) - { return recast.ID == id; }), - PRecastList->end()); + { + return recast.ID == id; + }), + PRecastList->end()); } } diff --git a/src/map/roe.cpp b/src/map/roe.cpp index 788c555cea7..c1539e8aef5 100644 --- a/src/map/roe.cpp +++ b/src/map/roe.cpp @@ -97,7 +97,7 @@ void call_onRecordTrigger(CCharEntity* PChar, uint16 recordID, const RoeDatagram namespace roeutils { - void ParseRecords(sol::table const& records_table) + void ParseRecords(const sol::table& records_table) { TracyZoneScoped; RoeHandlers.fill(RoeCheckHandler()); @@ -187,7 +187,7 @@ namespace roeutils } } - void ParseTimedSchedule(sol::table const& schedule_table) + void ParseTimedSchedule(const sol::table& schedule_table) { TracyZoneScoped; roeutils::RoeSystem.TimedRecords.reset(); @@ -197,7 +197,7 @@ namespace roeutils { uint8 day = entry.first.as() - 1; auto timeslots = entry.second.as(); - for (auto const& slot_entry : timeslots) + for (const auto& slot_entry : timeslots) { auto block = slot_entry.first.as() - 1; uint16 recordID = slot_entry.second.as(); diff --git a/src/map/roe.h b/src/map/roe.h index 76453c70f3c..445c6f3f458 100644 --- a/src/map/roe.h +++ b/src/map/roe.h @@ -112,17 +112,17 @@ struct RoeDatagram std::string luaKey; RoeDatagramPayload data; - RoeDatagram(std::string const& param, uint32 payload) + RoeDatagram(const std::string& param, uint32 payload) : luaKey{ param } , data{ payload } { } - RoeDatagram(std::string const& param, CMobEntity* payload) + RoeDatagram(const std::string& param, CMobEntity* payload) : luaKey{ param } , data{ payload } { } - RoeDatagram(std::string const& param, std::string const& payload) + RoeDatagram(const std::string& param, const std::string& payload) : luaKey{ param } , data{ payload } { @@ -136,8 +136,8 @@ namespace roeutils extern RoeSystemData RoeSystem; void init(); - void ParseRecords(sol::table const& records_table); - void ParseTimedSchedule(sol::table const& schedule_table); + void ParseRecords(const sol::table& records_table); + void ParseTimedSchedule(const sol::table& schedule_table); bool event(ROE_EVENT eventID, CCharEntity* PChar, const RoeDatagramList& payload); bool event(ROE_EVENT eventID, CCharEntity* PChar, const RoeDatagram& payload); diff --git a/src/map/spell.cpp b/src/map/spell.cpp index 5861969f36c..d04e35d29aa 100644 --- a/src/map/spell.cpp +++ b/src/map/spell.cpp @@ -150,20 +150,17 @@ bool CSpell::hasMPCost() bool CSpell::isHeal() { - return ((getValidTarget() & TARGET_SELF) && getSkillType() == SKILL_HEALING_MAGIC) || m_ID == SpellID::Pollen || m_ID == SpellID::Wild_Carrot || - m_ID == SpellID::Healing_Breeze || m_ID == SpellID::Magic_Fruit; + return ((getValidTarget() & TARGET_SELF) && getSkillType() == SKILL_HEALING_MAGIC) || m_ID == SpellID::Pollen || m_ID == SpellID::Wild_Carrot || m_ID == SpellID::Healing_Breeze || m_ID == SpellID::Magic_Fruit; } bool CSpell::isCure() { - return ((static_cast(m_ID) >= 1 && static_cast(m_ID) <= 11) || m_ID == SpellID::Cura || m_ID == SpellID::Cura_II || - m_ID == SpellID::Cura_III); + return ((static_cast(m_ID) >= 1 && static_cast(m_ID) <= 11) || m_ID == SpellID::Cura || m_ID == SpellID::Cura_II || m_ID == SpellID::Cura_III); } bool CSpell::isDebuff() { - return ((getValidTarget() & TARGET_ENEMY) && getSkillType() == SKILL_ENFEEBLING_MAGIC) || m_spellFamily == SPELLFAMILY_ELE_DOT || - m_spellFamily == SPELLFAMILY_BIO || m_ID == SpellID::Stun || m_ID == SpellID::Curse; + return ((getValidTarget() & TARGET_ENEMY) && getSkillType() == SKILL_ENFEEBLING_MAGIC) || m_spellFamily == SPELLFAMILY_ELE_DOT || m_spellFamily == SPELLFAMILY_BIO || m_ID == SpellID::Stun || m_ID == SpellID::Curse; } bool CSpell::isNa() @@ -856,8 +853,7 @@ namespace spell // brd gets bonus radius from string skill if (spell->getSpellGroup() == SPELLGROUP_SONG && (spell->getValidTarget() & TARGET_SELF)) { - if (entity->objtype == TYPE_MOB || (entity->GetMJob() == JOB_BRD && entity->objtype == TYPE_PC && ((CCharEntity*)entity)->getEquip(SLOT_RANGED) && - ((CItemWeapon*)((CCharEntity*)entity)->getEquip(SLOT_RANGED))->getSkillType() == SKILL_STRING_INSTRUMENT)) + if (entity->objtype == TYPE_MOB || (entity->GetMJob() == JOB_BRD && entity->objtype == TYPE_PC && ((CCharEntity*)entity)->getEquip(SLOT_RANGED) && ((CItemWeapon*)((CCharEntity*)entity)->getEquip(SLOT_RANGED))->getSkillType() == SKILL_STRING_INSTRUMENT)) { total += ((float)entity->GetSkill(SKILL_STRING_INSTRUMENT) / 276) * 10; } diff --git a/src/map/status_effect_container.cpp b/src/map/status_effect_container.cpp index a5f5f424053..55ba234837a 100644 --- a/src/map/status_effect_container.cpp +++ b/src/map/status_effect_container.cpp @@ -753,8 +753,7 @@ void CStatusEffectContainer::ApplyStateAlteringEffects(CStatusEffect* StatusEffe } } - if (effect == EFFECT_SLEEP || effect == EFFECT_SLEEP_II || effect == EFFECT_STUN || effect == EFFECT_PETRIFICATION || effect == EFFECT_TERROR || - effect == EFFECT_LULLABY || effect == EFFECT_PENALTY) + if (effect == EFFECT_SLEEP || effect == EFFECT_SLEEP_II || effect == EFFECT_STUN || effect == EFFECT_PETRIFICATION || effect == EFFECT_TERROR || effect == EFFECT_LULLABY || effect == EFFECT_PENALTY) { // change icon of sleep II and lullaby. Apparently they don't stop player movement. if (effect == EFFECT_SLEEP_II || effect == EFFECT_LULLABY) @@ -809,9 +808,7 @@ void CStatusEffectContainer::DelStatusEffectsByFlag(uint32 flag, bool silent) // If this is an NM/Mob Nightmare sleep, it can be removed explictly by a cure // see mobskills/nightmare.lua for full explanation if ( - flag & EFFECTFLAG_DAMAGE && - PStatusEffect->GetStatusID() == EFFECT_SLEEP && - PStatusEffect->GetTier() > 1) + flag & EFFECTFLAG_DAMAGE && PStatusEffect->GetStatusID() == EFFECT_SLEEP && PStatusEffect->GetTier() > 1) { continue; } @@ -852,10 +849,7 @@ EFFECT CStatusEffectContainer::HealingWaltz() std::vector waltzableList; for (CStatusEffect* PStatusEffect : m_StatusEffectSet) { - if ((PStatusEffect->HasEffectFlag(EFFECTFLAG_WALTZABLE) || - PStatusEffect->HasEffectFlag(EFFECTFLAG_ERASABLE)) && - PStatusEffect->GetDuration() > 0 && - !PStatusEffect->deleted) + if ((PStatusEffect->HasEffectFlag(EFFECTFLAG_WALTZABLE) || PStatusEffect->HasEffectFlag(EFFECTFLAG_ERASABLE)) && PStatusEffect->GetDuration() > 0 && !PStatusEffect->deleted) { waltzableList.emplace_back(PStatusEffect); } @@ -996,8 +990,7 @@ bool CStatusEffectContainer::ApplyBardEffect(CStatusEffect* PStatusEffect, uint8 { oldestSong = ExistingStatusEffect; } - else if (std::chrono::milliseconds(ExistingStatusEffect->GetDuration()) + ExistingStatusEffect->GetStartTime() < - std::chrono::milliseconds(oldestSong->GetDuration()) + oldestSong->GetStartTime()) + else if (std::chrono::milliseconds(ExistingStatusEffect->GetDuration()) + ExistingStatusEffect->GetStartTime() < std::chrono::milliseconds(oldestSong->GetDuration()) + oldestSong->GetStartTime()) { oldestSong = ExistingStatusEffect; } @@ -1030,8 +1023,7 @@ bool CStatusEffectContainer::ApplyBardEffect(CStatusEffect* PStatusEffect, uint8 bool CStatusEffectContainer::ApplyCorsairEffect(CStatusEffect* PStatusEffect, uint8 maxRolls, uint8 bustDuration) { // Don't process if not a COR roll. - if (!((PStatusEffect->GetStatusID() >= EFFECT_FIGHTERS_ROLL && PStatusEffect->GetStatusID() <= EFFECT_NATURALISTS_ROLL) || - (PStatusEffect->GetStatusID() == EFFECT_RUNEISTS_ROLL))) + if (!((PStatusEffect->GetStatusID() >= EFFECT_FIGHTERS_ROLL && PStatusEffect->GetStatusID() <= EFFECT_NATURALISTS_ROLL) || (PStatusEffect->GetStatusID() == EFFECT_RUNEISTS_ROLL))) { return false; } @@ -1046,11 +1038,9 @@ bool CStatusEffectContainer::ApplyCorsairEffect(CStatusEffect* PStatusEffect, ui CStatusEffect* oldestRoll = nullptr; for (auto&& PEffect : m_StatusEffectSet) { - if ((PEffect->GetStatusID() >= EFFECT_FIGHTERS_ROLL && PEffect->GetStatusID() <= EFFECT_NATURALISTS_ROLL) || - PEffect->GetStatusID() == EFFECT_RUNEISTS_ROLL || PEffect->GetStatusID() == EFFECT_BUST) // is a cor effect + if ((PEffect->GetStatusID() >= EFFECT_FIGHTERS_ROLL && PEffect->GetStatusID() <= EFFECT_NATURALISTS_ROLL) || PEffect->GetStatusID() == EFFECT_RUNEISTS_ROLL || PEffect->GetStatusID() == EFFECT_BUST) // is a cor effect { - if (PEffect->GetStatusID() == PStatusEffect->GetStatusID() && PEffect->GetSubID() == PStatusEffect->GetSubID() && - PEffect->GetSubPower() < PStatusEffect->GetSubPower()) + if (PEffect->GetStatusID() == PStatusEffect->GetStatusID() && PEffect->GetSubID() == PStatusEffect->GetSubID() && PEffect->GetSubPower() < PStatusEffect->GetSubPower()) { // same type, double up if (PStatusEffect->GetSubPower() < 12) { @@ -1069,7 +1059,7 @@ bool CStatusEffectContainer::ApplyCorsairEffect(CStatusEffect* PStatusEffect, ui uint16 duration = 300; duration -= bustDuration; CStatusEffect* bustEffect = new CStatusEffect(EFFECT_BUST, EFFECT_BUST, PStatusEffect->GetPower(), 0, duration, - PStatusEffect->GetTier(), PStatusEffect->GetStatusID()); + PStatusEffect->GetTier(), PStatusEffect->GetStatusID()); AddStatusEffect(bustEffect, true); DelStatusEffectSilent(EFFECT_DOUBLE_UP_CHANCE); } @@ -1086,8 +1076,7 @@ bool CStatusEffectContainer::ApplyCorsairEffect(CStatusEffect* PStatusEffect, ui { oldestRoll = PEffect; } - else if (std::chrono::milliseconds(PEffect->GetDuration()) + PEffect->GetStartTime() < - std::chrono::milliseconds(oldestRoll->GetDuration()) + oldestRoll->GetStartTime()) + else if (std::chrono::milliseconds(PEffect->GetDuration()) + PEffect->GetStartTime() < std::chrono::milliseconds(oldestRoll->GetDuration()) + oldestRoll->GetStartTime()) { oldestRoll = PEffect; } @@ -1115,8 +1104,7 @@ bool CStatusEffectContainer::HasCorsairEffect(uint32 charid) { for (CStatusEffect* PStatusEffect : m_StatusEffectSet) { - if ((PStatusEffect->GetStatusID() >= EFFECT_FIGHTERS_ROLL && PStatusEffect->GetStatusID() <= EFFECT_NATURALISTS_ROLL) || - PStatusEffect->GetStatusID() == EFFECT_RUNEISTS_ROLL || PStatusEffect->GetStatusID() == EFFECT_BUST) // is a cor effect + if ((PStatusEffect->GetStatusID() >= EFFECT_FIGHTERS_ROLL && PStatusEffect->GetStatusID() <= EFFECT_NATURALISTS_ROLL) || PStatusEffect->GetStatusID() == EFFECT_RUNEISTS_ROLL || PStatusEffect->GetStatusID() == EFFECT_BUST) // is a cor effect { if (PStatusEffect->GetSubID() == charid || PStatusEffect->GetStatusID() == EFFECT_BUST) { @@ -1132,8 +1120,7 @@ void CStatusEffectContainer::Fold(uint32 charid) CStatusEffect* oldestRoll = nullptr; for (CStatusEffect* PStatusEffect : m_StatusEffectSet) { - if ((PStatusEffect->GetStatusID() >= EFFECT_FIGHTERS_ROLL && PStatusEffect->GetStatusID() <= EFFECT_NATURALISTS_ROLL) || - PStatusEffect->GetStatusID() == EFFECT_RUNEISTS_ROLL || PStatusEffect->GetStatusID() == EFFECT_BUST) // is a cor effect + if ((PStatusEffect->GetStatusID() >= EFFECT_FIGHTERS_ROLL && PStatusEffect->GetStatusID() <= EFFECT_NATURALISTS_ROLL) || PStatusEffect->GetStatusID() == EFFECT_RUNEISTS_ROLL || PStatusEffect->GetStatusID() == EFFECT_BUST) // is a cor effect { if (PStatusEffect->GetSubID() == charid || PStatusEffect->GetStatusID() == EFFECT_BUST) { @@ -1330,8 +1317,8 @@ CStatusEffect* CStatusEffectContainer::StealStatusEffect(EFFECTFLAG flag) // make a copy CStatusEffect* EffectCopy = new CStatusEffect(oldEffect->GetStatusID(), oldEffect->GetIcon(), oldEffect->GetPower(), oldEffect->GetTickTime() / 1000, - oldEffect->GetDuration() / 1000, oldEffect->GetSubID(), oldEffect->GetSubPower(), oldEffect->GetTier(), - oldEffect->GetEffectFlags()); + oldEffect->GetDuration() / 1000, oldEffect->GetSubID(), oldEffect->GetSubPower(), oldEffect->GetTier(), + oldEffect->GetEffectFlags()); RemoveStatusEffect(oldEffect); @@ -1514,16 +1501,7 @@ void CStatusEffectContainer::SetEffectParams(CStatusEffect* StatusEffect) EFFECT effect = StatusEffect->GetStatusID(); // Determine if this is a BRD Song or COR Effect. - if (subType == 0 || - subType > 20000 || - (effect >= EFFECT_REQUIEM && effect <= EFFECT_NOCTURNE) || - (effect >= EFFECT_DOUBLE_UP_CHANCE && effect <= EFFECT_NATURALISTS_ROLL) || - effect == EFFECT_RUNEISTS_ROLL || - effect == EFFECT_DRAIN_DAZE || - effect == EFFECT_ASPIR_DAZE || - effect == EFFECT_HASTE_DAZE || - effect == EFFECT_ATMA || - effect == EFFECT_BATTLEFIELD) + if (subType == 0 || subType > 20000 || (effect >= EFFECT_REQUIEM && effect <= EFFECT_NOCTURNE) || (effect >= EFFECT_DOUBLE_UP_CHANCE && effect <= EFFECT_NATURALISTS_ROLL) || effect == EFFECT_RUNEISTS_ROLL || effect == EFFECT_DRAIN_DAZE || effect == EFFECT_ASPIR_DAZE || effect == EFFECT_HASTE_DAZE || effect == EFFECT_ATMA || effect == EFFECT_BATTLEFIELD) { name.insert(0, "effects/"); name.insert(name.size(), effects::EffectsParams[effect].Name); @@ -1590,8 +1568,7 @@ void CStatusEffectContainer::LoadStatusEffects() auto timestamp = rset->getUInt("timestamp"); if (server_clock::now() < time_point() + std::chrono::seconds(timestamp) + std::chrono::seconds(duration)) { - duration = (uint32)std::chrono::duration_cast(time_point() + std::chrono::seconds(timestamp) + - std::chrono::seconds(duration) - server_clock::now()) + duration = (uint32)std::chrono::duration_cast(time_point() + std::chrono::seconds(timestamp) + std::chrono::seconds(duration) - server_clock::now()) .count(); } else if (effectID == EFFECT::EFFECT_VISITANT) @@ -1606,16 +1583,15 @@ void CStatusEffectContainer::LoadStatusEffects() continue; } } - CStatusEffect* PStatusEffect = - new CStatusEffect(effectID, - (uint16)rset->getUInt("icon"), - (uint16)rset->getUInt("power"), - (uint16)rset->getUInt("tick"), - duration, - (uint16)rset->getUInt("subid"), - (uint16)rset->getUInt("subpower"), - (uint16)rset->getUInt("tier"), - flags); + CStatusEffect* PStatusEffect = new CStatusEffect(effectID, + (uint16)rset->getUInt("icon"), + (uint16)rset->getUInt("power"), + (uint16)rset->getUInt("tick"), + duration, + (uint16)rset->getUInt("subid"), + (uint16)rset->getUInt("subpower"), + (uint16)rset->getUInt("tier"), + flags); PEffectList.emplace_back(PStatusEffect); @@ -1715,8 +1691,8 @@ void CStatusEffectContainer::SaveStatusEffects(bool logout) } } _sql->Query(Query, m_POwner->id, PStatusEffect->GetStatusID(), PStatusEffect->GetIcon(), PStatusEffect->GetPower(), tick, duration, - PStatusEffect->GetSubID(), PStatusEffect->GetSubPower(), PStatusEffect->GetTier(), PStatusEffect->GetEffectFlags(), - std::chrono::duration_cast(PStatusEffect->GetStartTime().time_since_epoch()).count()); + PStatusEffect->GetSubID(), PStatusEffect->GetSubPower(), PStatusEffect->GetTier(), PStatusEffect->GetEffectFlags(), + std::chrono::duration_cast(PStatusEffect->GetStartTime().time_since_epoch()).count()); } } DeleteStatusEffects(); @@ -1812,11 +1788,7 @@ void CStatusEffectContainer::HandleAura(CStatusEffect* PStatusEffect) { for (CBattleEntity* PTarget : *PEntity->PNotorietyContainer) { // Check for trust here so negitive effects wont affect trust - if (PTarget != nullptr && - PTarget->loc.zone && - PEntity->loc.zone && - PTarget->objtype != TYPE_TRUST && PEntity->loc.zone->GetID() == PTarget->loc.zone->GetID() && distance(m_POwner->loc.p, PTarget->loc.p) <= aura_range && - !PTarget->isDead()) + if (PTarget != nullptr && PTarget->loc.zone && PEntity->loc.zone && PTarget->objtype != TYPE_TRUST && PEntity->loc.zone->GetID() == PTarget->loc.zone->GetID() && distance(m_POwner->loc.p, PTarget->loc.p) <= aura_range && !PTarget->isDead()) { CStatusEffect* PEffect = PTarget->StatusEffectContainer->GetStatusEffect(static_cast(PStatusEffect->GetSubID())); @@ -1838,10 +1810,10 @@ void CStatusEffectContainer::HandleAura(CStatusEffect* PStatusEffect) else { PEffect = new CStatusEffect(static_cast(PStatusEffect->GetSubID()), // Effect ID - PStatusEffect->GetSubID(), // Effect Icon (Associated with ID) - PStatusEffect->GetSubPower(), // Power - 3, // Tick - 4); // Duration + PStatusEffect->GetSubID(), // Effect Icon (Associated with ID) + PStatusEffect->GetSubPower(), // Power + 3, // Tick + 4); // Duration PEffect->AddEffectFlag(EFFECTFLAG_NO_LOSS_MESSAGE); PEffect->AddEffectFlag(EFFECTFLAG_ALWAYS_EXPIRING); PTarget->StatusEffectContainer->AddStatusEffect(PEffect, true); @@ -1902,11 +1874,7 @@ void CStatusEffectContainer::HandleAura(CStatusEffect* PStatusEffect) for (auto& enmityPair : *enmityList) { auto* PTarget = enmityPair.second.PEnmityOwner; - if (PTarget != nullptr && - PTarget->loc.zone && - PEntity->loc.zone && - PEntity->loc.zone->GetID() == PTarget->loc.zone->GetID() && distance(m_POwner->loc.p, PTarget->loc.p) <= aura_range && - !PTarget->isDead()) + if (PTarget != nullptr && PTarget->loc.zone && PEntity->loc.zone && PEntity->loc.zone->GetID() == PTarget->loc.zone->GetID() && distance(m_POwner->loc.p, PTarget->loc.p) <= aura_range && !PTarget->isDead()) { CStatusEffect* PEffect = PTarget->StatusEffectContainer->GetStatusEffect(static_cast(PStatusEffect->GetSubID())); @@ -1928,10 +1896,10 @@ void CStatusEffectContainer::HandleAura(CStatusEffect* PStatusEffect) else { PEffect = new CStatusEffect(static_cast(PStatusEffect->GetSubID()), // Effect ID - PStatusEffect->GetSubID(), // Effect Icon (Associated with ID) - PStatusEffect->GetSubPower(), // Power - 3, // Tick - 4); // Duration + PStatusEffect->GetSubID(), // Effect Icon (Associated with ID) + PStatusEffect->GetSubPower(), // Power + 3, // Tick + 4); // Duration PEffect->AddEffectFlag(EFFECTFLAG_NO_LOSS_MESSAGE); PEffect->AddEffectFlag(EFFECTFLAG_ALWAYS_EXPIRING); PTarget->StatusEffectContainer->AddStatusEffect(PEffect, true); @@ -1962,9 +1930,7 @@ void CStatusEffectContainer::TickEffects(time_point tick) { for (const auto& PStatusEffect : m_StatusEffectSet) { - if (PStatusEffect->GetTickTime() != 0 && - PStatusEffect->GetElapsedTickCount() <= - std::chrono::duration_cast(tick - PStatusEffect->GetStartTime()).count() / PStatusEffect->GetTickTime()) + if (PStatusEffect->GetTickTime() != 0 && PStatusEffect->GetElapsedTickCount() <= std::chrono::duration_cast(tick - PStatusEffect->GetStartTime()).count() / PStatusEffect->GetTickTime()) { if (PStatusEffect->HasEffectFlag(EFFECTFLAG_AURA)) { @@ -2022,8 +1988,7 @@ void CStatusEffectContainer::TickRegen(time_point tick) // see mobskills/nightmare.lua for full explanation if ( !( - m_POwner->StatusEffectContainer->GetStatusEffect(EFFECT_SLEEP) && - m_POwner->StatusEffectContainer->GetStatusEffect(EFFECT_SLEEP)->GetTier() > 0)) + m_POwner->StatusEffectContainer->GetStatusEffect(EFFECT_SLEEP) && m_POwner->StatusEffectContainer->GetStatusEffect(EFFECT_SLEEP)->GetTier() > 0)) { WakeUp(); } @@ -2047,8 +2012,7 @@ void CStatusEffectContainer::TickRegen(time_point tick) CPetEntity* PPet = (CPetEntity*)m_POwner->PPet; CItem* hands = PChar->getEquip(SLOT_HANDS); - if (PChar->StatusEffectContainer->HasStatusEffect(EFFECT_AVATARS_FAVOR) && - ((PPet->m_PetID >= PETID_CARBUNCLE && PPet->m_PetID <= PETID_CAIT_SITH) || PPet->m_PetID == PETID_SIREN)) + if (PChar->StatusEffectContainer->HasStatusEffect(EFFECT_AVATARS_FAVOR) && ((PPet->m_PetID >= PETID_CARBUNCLE && PPet->m_PetID <= PETID_CAIT_SITH) || PPet->m_PetID == PETID_SIREN)) { perpetuation = static_cast(perpetuation * 1.2); } @@ -2135,9 +2099,7 @@ bool CStatusEffectContainer::CheckForElevenRoll() { for (CStatusEffect* PStatusEffect : m_StatusEffectSet) { - if ((PStatusEffect->GetStatusID() >= EFFECT_FIGHTERS_ROLL && PStatusEffect->GetStatusID() <= EFFECT_NATURALISTS_ROLL && - PStatusEffect->GetSubPower() == 11) || - (PStatusEffect->GetStatusID() == EFFECT_RUNEISTS_ROLL && PStatusEffect->GetSubPower() == 11)) + if ((PStatusEffect->GetStatusID() >= EFFECT_FIGHTERS_ROLL && PStatusEffect->GetStatusID() <= EFFECT_NATURALISTS_ROLL && PStatusEffect->GetSubPower() == 11) || (PStatusEffect->GetStatusID() == EFFECT_RUNEISTS_ROLL && PStatusEffect->GetSubPower() == 11)) { return true; } diff --git a/src/map/treasure_pool.cpp b/src/map/treasure_pool.cpp index f65de362e85..43b8c61f2c7 100644 --- a/src/map/treasure_pool.cpp +++ b/src/map/treasure_pool.cpp @@ -440,9 +440,7 @@ void CTreasurePool::CheckTreasureItem(time_point tick, uint8 SlotID) return; } - if ((tick - m_PoolItems[SlotID].TimeStamp) > treasure_livetime || - (m_TreasurePoolType == TREASUREPOOL_SOLO && members[0]->getStorage(LOC_INVENTORY)->GetFreeSlotsCount() != 0) || - m_PoolItems[SlotID].Lotters.size() == members.size()) + if ((tick - m_PoolItems[SlotID].TimeStamp) > treasure_livetime || (m_TreasurePoolType == TREASUREPOOL_SOLO && members[0]->getStorage(LOC_INVENTORY)->GetFreeSlotsCount() != 0) || m_PoolItems[SlotID].Lotters.size() == members.size()) { // Find item's highest lotter LotInfo highestInfo; diff --git a/src/map/utils/attackutils.h b/src/map/utils/attackutils.h index f28ea044084..7a86903a0d6 100644 --- a/src/map/utils/attackutils.h +++ b/src/map/utils/attackutils.h @@ -38,6 +38,6 @@ namespace attackutils bool IsParried(CBattleEntity* PAttacker, CBattleEntity* PDefender); // Is the attack parried. bool IsGuarded(CBattleEntity* PAttacker, CBattleEntity* PDefender); // Is the attack guarded. bool IsBlocked(CBattleEntity* PAttacker, CBattleEntity* PDefender); // Is the attack blocked. -}; // namespace attackutils +}; // namespace attackutils #endif diff --git a/src/map/utils/battleutils.cpp b/src/map/utils/battleutils.cpp index 62cfb73cf88..cb3b0135df1 100644 --- a/src/map/utils/battleutils.cpp +++ b/src/map/utils/battleutils.cpp @@ -397,11 +397,7 @@ namespace battleutils bool CanUseWeaponskill(CCharEntity* PChar, CWeaponSkill* PSkill) { - return ((PSkill->getSkillLevel() > 0 && PChar->GetSkill(PSkill->getType()) >= PSkill->getSkillLevel() && - (PSkill->getUnlockId() == 0 || charutils::hasLearnedWeaponskill(PChar, PSkill->getUnlockId()))) || - (PSkill->getSkillLevel() == 0 && (PSkill->getUnlockId() == 0 || - (charutils::hasLearnedWeaponskill(PChar, PSkill->getUnlockId()) && PChar->GetMLevel() >= 75)))) && - (PSkill->getJob(PChar->GetMJob()) > 0 || (PSkill->getJob(PChar->GetSJob()) > 0 && !PSkill->mainOnly())); + return ((PSkill->getSkillLevel() > 0 && PChar->GetSkill(PSkill->getType()) >= PSkill->getSkillLevel() && (PSkill->getUnlockId() == 0 || charutils::hasLearnedWeaponskill(PChar, PSkill->getUnlockId()))) || (PSkill->getSkillLevel() == 0 && (PSkill->getUnlockId() == 0 || (charutils::hasLearnedWeaponskill(PChar, PSkill->getUnlockId()) && PChar->GetMLevel() >= 75)))) && (PSkill->getJob(PChar->GetMJob()) > 0 || (PSkill->getJob(PChar->GetSJob()) > 0 && !PSkill->mainOnly())); } /************************************************************************ @@ -651,16 +647,16 @@ namespace battleutils DAYTYPE strongDay[8] = { FIRESDAY, ICEDAY, WINDSDAY, EARTHSDAY, LIGHTNINGDAY, WATERSDAY, LIGHTSDAY, DARKSDAY }; DAYTYPE weakDay[8] = { WATERSDAY, FIRESDAY, ICEDAY, WINDSDAY, EARTHSDAY, LIGHTNINGDAY, DARKSDAY, LIGHTSDAY }; WEATHER strongWeatherSingle[8] = { WEATHER_HOT_SPELL, WEATHER_SNOW, WEATHER_WIND, WEATHER_DUST_STORM, - WEATHER_THUNDER, WEATHER_RAIN, WEATHER_AURORAS, WEATHER_GLOOM }; + WEATHER_THUNDER, WEATHER_RAIN, WEATHER_AURORAS, WEATHER_GLOOM }; WEATHER strongWeatherDouble[8] = { WEATHER_HEAT_WAVE, WEATHER_BLIZZARDS, WEATHER_GALES, WEATHER_SAND_STORM, - WEATHER_THUNDERSTORMS, WEATHER_SQUALL, WEATHER_STELLAR_GLARE, WEATHER_DARKNESS }; + WEATHER_THUNDERSTORMS, WEATHER_SQUALL, WEATHER_STELLAR_GLARE, WEATHER_DARKNESS }; WEATHER weakWeatherSingle[8] = { WEATHER_RAIN, WEATHER_HOT_SPELL, WEATHER_SNOW, WEATHER_WIND, - WEATHER_DUST_STORM, WEATHER_THUNDER, WEATHER_GLOOM, WEATHER_AURORAS }; + WEATHER_DUST_STORM, WEATHER_THUNDER, WEATHER_GLOOM, WEATHER_AURORAS }; WEATHER weakWeatherDouble[8] = { WEATHER_SQUALL, WEATHER_HEAT_WAVE, WEATHER_BLIZZARDS, WEATHER_GALES, - WEATHER_SAND_STORM, WEATHER_THUNDERSTORMS, WEATHER_DARKNESS, WEATHER_STELLAR_GLARE }; + WEATHER_SAND_STORM, WEATHER_THUNDERSTORMS, WEATHER_DARKNESS, WEATHER_STELLAR_GLARE }; uint32 obi[8] = { 15435, 15436, 15437, 15438, 15439, 15440, 15441, 15442 }; Mod resistarray[8] = { Mod::FIRE_MEVA, Mod::ICE_MEVA, Mod::WIND_MEVA, Mod::EARTH_MEVA, - Mod::THUNDER_MEVA, Mod::WATER_MEVA, Mod::LIGHT_MEVA, Mod::DARK_MEVA }; + Mod::THUNDER_MEVA, Mod::WATER_MEVA, Mod::LIGHT_MEVA, Mod::DARK_MEVA }; bool obiBonus = false; double half = (double)(PDefender->getMod(resistarray[element - 1])) / 100; @@ -780,8 +776,7 @@ namespace battleutils Action->spikesParam = std::max(PDefender->getMod(Mod::SPIKES_DMG), 0); // Handle Retaliation - if (PDefender->StatusEffectContainer->HasStatusEffect(EFFECT_RETALIATION) && PDefender->PAI->IsEngaged() && - battleutils::GetHitRate(PDefender, PAttacker) / 2 > xirand::GetRandomNumber(100) && facing(PDefender->loc.p, PAttacker->loc.p, 64)) + if (PDefender->StatusEffectContainer->HasStatusEffect(EFFECT_RETALIATION) && PDefender->PAI->IsEngaged() && battleutils::GetHitRate(PDefender, PAttacker) / 2 > xirand::GetRandomNumber(100) && facing(PDefender->loc.p, PAttacker->loc.p, 64)) { // Retaliation rate is based on player acc vs mob evasion. Missed retaliations do not even display in log. // Other theories exist but were not proven or reliably tested (I have to assume too many things to even consider JP translations about weapon @@ -820,14 +815,13 @@ namespace battleutils float DamageRatio = GetDamageRatio(PDefender, PAttacker, crit, 1.f, skilltype, SLOT_MAIN); uint16 dmg = (uint32)((PDefender->GetMainWeaponDmg() + battleutils::GetFSTR(PDefender, PAttacker, SLOT_MAIN)) * DamageRatio); dmg = attackutils::CheckForDamageMultiplier(((CCharEntity*)PDefender), dynamic_cast(PDefender->m_Weapons[SLOT_MAIN]), dmg, - PHYSICAL_ATTACK_TYPE::NORMAL, SLOT_MAIN); + PHYSICAL_ATTACK_TYPE::NORMAL, SLOT_MAIN); uint16 bonus = dmg * (PDefender->getMod(Mod::RETALIATION) / 100); dmg = dmg + bonus; // TP and stoneskin are handled inside TakePhysicalDamage Action->spikesMessage = 536; - Action->spikesParam = - battleutils::TakePhysicalDamage(PDefender, PAttacker, PHYSICAL_ATTACK_TYPE::NORMAL, dmg, false, SLOT_MAIN, 1, nullptr, true, true, true); + Action->spikesParam = battleutils::TakePhysicalDamage(PDefender, PAttacker, PHYSICAL_ATTACK_TYPE::NORMAL, dmg, false, SLOT_MAIN, 1, nullptr, true, true, true); } } @@ -1200,8 +1194,8 @@ namespace battleutils } if ((PAttacker->getMod(Mod::ENSPELL) > 0 && // Enspell overwrites weapon effects - (PAttacker->getMod(Mod::ENSPELL_CHANCE) == 0 || PAttacker->getMod(Mod::ENSPELL_CHANCE) > xirand::GetRandomNumber(100))) || - PAttacker->StatusEffectContainer->GetActiveRuneCount() > 0) // Rune Enhancement means we deal enspell damage + (PAttacker->getMod(Mod::ENSPELL_CHANCE) == 0 || PAttacker->getMod(Mod::ENSPELL_CHANCE) > xirand::GetRandomNumber(100))) + || PAttacker->StatusEffectContainer->GetActiveRuneCount() > 0) // Rune Enhancement means we deal enspell damage { static SUBEFFECT enspell_subeffects[8] = { SUBEFFECT_FIRE_DAMAGE, @@ -1324,8 +1318,7 @@ namespace battleutils } } // check weapon for additional effects - else if (PAttacker->objtype == TYPE_PC && battleutils::GetScaledItemModifier(PAttacker, weapon, Mod::ITEM_ADDEFFECT_TYPE) > 0 && - luautils::additionalEffectAttack(PAttacker, PDefender, weapon, Action, finaldamage) == 0 && Action->additionalEffect) + else if (PAttacker->objtype == TYPE_PC && battleutils::GetScaledItemModifier(PAttacker, weapon, Mod::ITEM_ADDEFFECT_TYPE) > 0 && luautils::additionalEffectAttack(PAttacker, PDefender, weapon, Action, finaldamage) == 0 && Action->additionalEffect) { if (Action->addEffectMessage == 163 && Action->addEffectParam < 0) { @@ -1333,12 +1326,7 @@ namespace battleutils } } // check script for grip if main failed - else if (PAttacker->objtype == TYPE_PC && static_cast(PAttacker)->getEquip(SLOT_SUB) && weapon == PAttacker->m_Weapons[SLOT_MAIN] && - static_cast(static_cast(PAttacker)->getEquip(SLOT_SUB))->getSkillType() == SKILL_NONE && - battleutils::GetScaledItemModifier(PAttacker, static_cast(PAttacker)->getEquip(SLOT_SUB), Mod::ITEM_ADDEFFECT_TYPE) > 0 && - luautils::additionalEffectAttack(PAttacker, PDefender, static_cast(static_cast(PAttacker)->getEquip(SLOT_SUB)), Action, - finaldamage) == 0 && - Action->additionalEffect) + else if (PAttacker->objtype == TYPE_PC && static_cast(PAttacker)->getEquip(SLOT_SUB) && weapon == PAttacker->m_Weapons[SLOT_MAIN] && static_cast(static_cast(PAttacker)->getEquip(SLOT_SUB))->getSkillType() == SKILL_NONE && battleutils::GetScaledItemModifier(PAttacker, static_cast(PAttacker)->getEquip(SLOT_SUB), Mod::ITEM_ADDEFFECT_TYPE) > 0 && luautils::additionalEffectAttack(PAttacker, PDefender, static_cast(static_cast(PAttacker)->getEquip(SLOT_SUB)), Action, finaldamage) == 0 && Action->additionalEffect) { if (Action->addEffectMessage == 163 && Action->addEffectParam < 0) { @@ -1676,9 +1664,8 @@ namespace battleutils if (isCritical) { pdif *= 1.25; - int16 criticaldamage = - PAttacker->getMod(Mod::CRIT_DMG_INCREASE) + PAttacker->getMod(Mod::RANGED_CRIT_DMG_INCREASE) - PDefender->getMod(Mod::CRIT_DEF_BONUS); - criticaldamage = std::clamp(criticaldamage, 0, 100); + int16 criticaldamage = PAttacker->getMod(Mod::CRIT_DMG_INCREASE) + PAttacker->getMod(Mod::RANGED_CRIT_DMG_INCREASE) - PDefender->getMod(Mod::CRIT_DEF_BONUS); + criticaldamage = std::clamp(criticaldamage, 0, 100); pdif *= ((100 + criticaldamage) / 100.0f); } @@ -1957,8 +1944,7 @@ namespace battleutils uint8 GetParryRate(CBattleEntity* PAttacker, CBattleEntity* PDefender) { CItemWeapon* PWeapon = GetEntityWeapon(PDefender, SLOT_MAIN); - if ((PWeapon != nullptr && PWeapon->getID() != 0 && PWeapon->getID() != 65535 && PWeapon->getSkillType() != SKILL_HAND_TO_HAND) && - PDefender->PAI->IsEngaged()) + if ((PWeapon != nullptr && PWeapon->getID() != 0 && PWeapon->getID() != 65535 && PWeapon->getSkillType() != SKILL_HAND_TO_HAND) && PDefender->PAI->IsEngaged()) { // http://wiki.ffxiclopedia.org/wiki/Talk:Parrying_Skill // {(Parry Skill x .125) + ([Player Agi - Enemy Dex] x .125)} x Diff @@ -2063,8 +2049,8 @@ namespace battleutils ************************************************************************/ int32 TakePhysicalDamage(CBattleEntity* PAttacker, CBattleEntity* PDefender, PHYSICAL_ATTACK_TYPE physicalAttackType, int32 damage, bool isBlocked, - uint8 slot, uint16 tpMultiplier, CBattleEntity* taChar, bool giveTPtoVictim, bool giveTPtoAttacker, bool isCounter, bool isCovered, - CBattleEntity* POriginalTarget) + uint8 slot, uint16 tpMultiplier, CBattleEntity* taChar, bool giveTPtoVictim, bool giveTPtoAttacker, bool isCounter, bool isCovered, + CBattleEntity* POriginalTarget) { auto* weapon = GetEntityWeapon(PAttacker, (SLOTTYPE)slot); giveTPtoAttacker = giveTPtoAttacker && !PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_MEIKYO_SHISUI); @@ -2155,8 +2141,7 @@ namespace battleutils absorb = std::clamp(100 - slotSub->getShieldAbsorption(), 0, 100); // Shield Mastery - if ((std::max(damage - (PDefender->getMod(Mod::PHALANX) + PDefender->getMod(Mod::STONESKIN)), 0) > 0) && - PDefender->getMod(Mod::SHIELD_MASTERY_TP)) + if ((std::max(damage - (PDefender->getMod(Mod::PHALANX) + PDefender->getMod(Mod::STONESKIN)), 0) > 0) && PDefender->getMod(Mod::SHIELD_MASTERY_TP)) { // If the player blocked with a shield and has shield mastery, add shield mastery TP bonus // unblocked damage (before block but as if affected by stoneskin/phalanx) must be greater than zero @@ -2169,8 +2154,7 @@ namespace battleutils absorb = 50; // Shield Mastery - if ((std::max(damage - (PDefender->getMod(Mod::PHALANX) + PDefender->getMod(Mod::STONESKIN)), 0) > 0) && - (PDefender->getMod(Mod::SHIELD_MASTERY_TP))) + if ((std::max(damage - (PDefender->getMod(Mod::PHALANX) + PDefender->getMod(Mod::STONESKIN)), 0) > 0) && (PDefender->getMod(Mod::SHIELD_MASTERY_TP))) { // If the pet blocked with a shield and has shield mastery, add shield mastery TP bonus // unblocked damage (before block but as if affected by stoneskin/phalanx) must be greater than zero @@ -2182,8 +2166,7 @@ namespace battleutils absorb = 50; // Shield Mastery - if ((std::max(damage - (PDefender->getMod(Mod::PHALANX) + PDefender->getMod(Mod::STONESKIN)), 0) > 0) && - (PDefender->getMod(Mod::SHIELD_MASTERY_TP))) + if ((std::max(damage - (PDefender->getMod(Mod::PHALANX) + PDefender->getMod(Mod::STONESKIN)), 0) > 0) && (PDefender->getMod(Mod::SHIELD_MASTERY_TP))) { // If the trust blocked with a shield and has shield mastery, add shield mastery TP bonus // unblocked damage (before block but as if affected by stoneskin/phalanx) must be greater than zero @@ -2328,8 +2311,7 @@ namespace battleutils int32 delay = PAttacker->GetWeaponDelay(true); auto* sub_weapon = dynamic_cast(PAttacker->m_Weapons[SLOT_SUB]); - if (sub_weapon && sub_weapon->getDmgType() > DAMAGE_TYPE::NONE && sub_weapon->getDmgType() < DAMAGE_TYPE::HTH && - weapon->getSkillType() != SKILL_HAND_TO_HAND) + if (sub_weapon && sub_weapon->getDmgType() > DAMAGE_TYPE::NONE && sub_weapon->getDmgType() < DAMAGE_TYPE::HTH && weapon->getSkillType() != SKILL_HAND_TO_HAND) { delay = delay / 2; } @@ -2372,15 +2354,11 @@ namespace battleutils if (PDefender->objtype == TYPE_PC || (PDefender->objtype == TYPE_PET && PDefender->PMaster && PDefender->PMaster->objtype == TYPE_PC)) { PDefender->addTP( - (int16)(tpMultiplier * ((baseTp / 3) * sBlowMult * - (1.0f + 0.01f * (float)((PDefender->getMod(Mod::STORETP) + - getStoreTPbonusFromMerit(PAttacker))))))); // yup store tp counts on hits taken too! + (int16)(tpMultiplier * ((baseTp / 3) * sBlowMult * (1.0f + 0.01f * (float)((PDefender->getMod(Mod::STORETP) + getStoreTPbonusFromMerit(PAttacker))))))); // yup store tp counts on hits taken too! } else { - PDefender->addTP((uint16)(tpMultiplier * - ((baseTp + 30) * sBlowMult * - (1.0f + 0.01f * (float)PDefender->getMod(Mod::STORETP))))); // subtle blow also reduces the "+30" on mob tp gain + PDefender->addTP((uint16)(tpMultiplier * ((baseTp + 30) * sBlowMult * (1.0f + 0.01f * (float)PDefender->getMod(Mod::STORETP))))); // subtle blow also reduces the "+30" on mob tp gain } } } @@ -2404,15 +2382,12 @@ namespace battleutils ************************************************************************/ int32 TakeWeaponskillDamage(CBattleEntity* PAttacker, CBattleEntity* PDefender, int32 damage, ATTACK_TYPE attackType, DAMAGE_TYPE damageType, uint8 slot, - bool primary, float tpMultiplier, uint16 bonusTP, float targetTPMultiplier) + bool primary, float tpMultiplier, uint16 bonusTP, float targetTPMultiplier) { auto* weapon = GetEntityWeapon(PAttacker, (SLOTTYPE)slot); bool isRanged = (slot == SLOT_AMMO || slot == SLOT_RANGED); - if (attackType == ATTACK_TYPE::PHYSICAL && - PDefender->StatusEffectContainer->HasStatusEffect(EFFECT_DEFENSE_BOOST) && - PDefender->StatusEffectContainer->GetStatusEffect(EFFECT_DEFENSE_BOOST)->GetSubPower() != 0 && - infront(PAttacker->loc.p, PDefender->loc.p, PDefender->StatusEffectContainer->GetStatusEffect(EFFECT_DEFENSE_BOOST)->GetSubPower())) + if (attackType == ATTACK_TYPE::PHYSICAL && PDefender->StatusEffectContainer->HasStatusEffect(EFFECT_DEFENSE_BOOST) && PDefender->StatusEffectContainer->GetStatusEffect(EFFECT_DEFENSE_BOOST)->GetSubPower() != 0 && infront(PAttacker->loc.p, PDefender->loc.p, PDefender->StatusEffectContainer->GetStatusEffect(EFFECT_DEFENSE_BOOST)->GetSubPower())) { damage = 0; } @@ -2494,8 +2469,7 @@ namespace battleutils auto* sub_weapon = dynamic_cast(PAttacker->m_Weapons[SLOT_SUB]); - if (sub_weapon && sub_weapon->getDmgType() > DAMAGE_TYPE::NONE && sub_weapon->getDmgType() < DAMAGE_TYPE::HTH && - weapon->getSkillType() != SKILL_HAND_TO_HAND) + if (sub_weapon && sub_weapon->getDmgType() > DAMAGE_TYPE::NONE && sub_weapon->getDmgType() < DAMAGE_TYPE::HTH && weapon->getSkillType() != SKILL_HAND_TO_HAND) { delay /= 2; } @@ -2514,8 +2488,7 @@ namespace battleutils if (primary) // Calculate TP Return from WS { - standbyTp = bonusTP + ((int16)((tpMultiplier * baseTp) * - (1.0f + 0.01f * (float)((PAttacker->getMod(Mod::STORETP) + getStoreTPbonusFromMerit(PAttacker)))))); + standbyTp = bonusTP + ((int16)((tpMultiplier * baseTp) * (1.0f + 0.01f * (float)((PAttacker->getMod(Mod::STORETP) + getStoreTPbonusFromMerit(PAttacker)))))); } uint32 sBlowMerit = 0; @@ -2532,16 +2505,11 @@ namespace battleutils // mobs hit get basetp+30 whereas pcs hit get basetp/3 if (PDefender->objtype == TYPE_PC) { - PDefender->addTP((int16)(tpMultiplier * targetTPMultiplier * - ((baseTp / 3) * sBlowMult * - (1.0f + 0.01f * (float)((PDefender->getMod(Mod::STORETP) + - getStoreTPbonusFromMerit(PAttacker))))))); // yup store tp counts on hits taken too! + PDefender->addTP((int16)(tpMultiplier * targetTPMultiplier * ((baseTp / 3) * sBlowMult * (1.0f + 0.01f * (float)((PDefender->getMod(Mod::STORETP) + getStoreTPbonusFromMerit(PAttacker))))))); // yup store tp counts on hits taken too! } else { - PDefender->addTP((int16)(tpMultiplier * targetTPMultiplier * - ((baseTp + 30) * sBlowMult * - (1.0f + 0.01f * (float)PDefender->getMod(Mod::STORETP))))); // subtle blow also reduces the "+30" on mob tp gain + PDefender->addTP((int16)(tpMultiplier * targetTPMultiplier * ((baseTp + 30) * sBlowMult * (1.0f + 0.01f * (float)PDefender->getMod(Mod::STORETP))))); // subtle blow also reduces the "+30" on mob tp gain } } else if (PDefender->objtype == TYPE_MOB) @@ -2635,15 +2603,11 @@ namespace battleutils ************************************************************************/ uint8 GetHitRateEx(CBattleEntity* PAttacker, CBattleEntity* PDefender, uint8 attackNumber, - int8 offsetAccuracy) // subWeaponAttack is for calculating acc of dual wielded sub weapon + int8 offsetAccuracy) // subWeaponAttack is for calculating acc of dual wielded sub weapon { int32 hitrate = 75; - if (PAttacker->objtype == TYPE_PC && - ((PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_SNEAK_ATTACK) && - (behind(PAttacker->loc.p, PDefender->loc.p, 64) || PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_HIDE))) || - (charutils::hasTrait((CCharEntity*)PAttacker, TRAIT_ASSASSIN) && PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_TRICK_ATTACK) && - battleutils::getAvailableTrickAttackChar(PAttacker, PDefender)))) + if (PAttacker->objtype == TYPE_PC && ((PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_SNEAK_ATTACK) && (behind(PAttacker->loc.p, PDefender->loc.p, 64) || PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_HIDE))) || (charutils::hasTrait((CCharEntity*)PAttacker, TRAIT_ASSASSIN) && PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_TRICK_ATTACK) && battleutils::getAvailableTrickAttackChar(PAttacker, PDefender)))) { hitrate = 100; // Attack with SA active or TA/Assassin cannot miss } @@ -2655,14 +2619,12 @@ namespace battleutils offsetAccuracy += ((CCharEntity*)PAttacker)->PMeritPoints->GetMeritValue(MERIT_AMBUSH, (CCharEntity*)PAttacker); } // Check for Closed Position merit on attacker for additional accuracy and that attacker and defender are facing each other - if (PAttacker->objtype == TYPE_PC && (charutils::hasTrait((CCharEntity*)PAttacker, TRAIT_CLOSED_POSITION)) && - (infront(PAttacker->loc.p, PDefender->loc.p, 64) && facing(PAttacker->loc.p, PDefender->loc.p, 64))) + if (PAttacker->objtype == TYPE_PC && (charutils::hasTrait((CCharEntity*)PAttacker, TRAIT_CLOSED_POSITION)) && (infront(PAttacker->loc.p, PDefender->loc.p, 64) && facing(PAttacker->loc.p, PDefender->loc.p, 64))) { offsetAccuracy += ((CCharEntity*)PAttacker)->PMeritPoints->GetMeritValue(MERIT_CLOSED_POSITION, (CCharEntity*)PAttacker); } // Check for Closed Position merit on defender for additional evasion and that attacker and defender are facing each other - if (PDefender->objtype == TYPE_PC && (charutils::hasTrait((CCharEntity*)PDefender, TRAIT_CLOSED_POSITION)) && - (infront(PDefender->loc.p, PAttacker->loc.p, 64) && facing(PDefender->loc.p, PAttacker->loc.p, 64))) + if (PDefender->objtype == TYPE_PC && (charutils::hasTrait((CCharEntity*)PDefender, TRAIT_CLOSED_POSITION)) && (infront(PDefender->loc.p, PAttacker->loc.p, 64) && facing(PDefender->loc.p, PAttacker->loc.p, 64))) { offsetAccuracy -= ((CCharEntity*)PDefender)->PMeritPoints->GetMeritValue(MERIT_CLOSED_POSITION, (CCharEntity*)PDefender); } @@ -2777,8 +2739,7 @@ namespace battleutils uint8 GetCritHitRate(CBattleEntity* PAttacker, CBattleEntity* PDefender, bool ignoreSneakTrickAttack, SLOTTYPE weaponSlot) { int32 critHitRate = 5; - if (PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_MIGHTY_STRIKES, 0) || - PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_MIGHTY_STRIKES)) + if (PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_MIGHTY_STRIKES, 0) || PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_MIGHTY_STRIKES)) { return 100; } @@ -2789,8 +2750,7 @@ namespace battleutils critHitRate = 100; } } - else if (PAttacker->objtype == TYPE_PC && PAttacker->GetMJob() == JOB_THF && charutils::hasTrait((CCharEntity*)PAttacker, TRAIT_ASSASSIN) && - (!ignoreSneakTrickAttack) && PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_TRICK_ATTACK)) + else if (PAttacker->objtype == TYPE_PC && PAttacker->GetMJob() == JOB_THF && charutils::hasTrait((CCharEntity*)PAttacker, TRAIT_ASSASSIN) && (!ignoreSneakTrickAttack) && PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_TRICK_ATTACK)) { CBattleEntity* taChar = battleutils::getAvailableTrickAttackChar(PAttacker, PDefender); if (taChar != nullptr) @@ -2811,8 +2771,7 @@ namespace battleutils CItemEquipment* PSub = PCharAttacker->getEquip(SLOT_SUB); CItemWeapon* PSubWeapon = dynamic_cast(PCharAttacker->m_Weapons[SLOT_SUB]); - if (PMain && !PMain->isTwoHanded() && !PMain->isHandToHand() && - (!PSub || (PSubWeapon && PSubWeapon->getSkillType() == SKILL_NONE) || PSub->IsShield())) + if (PMain && !PMain->isTwoHanded() && !PMain->isHandToHand() && (!PSub || (PSubWeapon && PSubWeapon->getSkillType() == SKILL_NONE) || PSub->IsShield())) { critHitRate += PCharAttacker->getMod(Mod::FENCER_CRITHITRATE); } @@ -3987,8 +3946,7 @@ namespace battleutils // TODO: × (1 + Day/Weather bonuses) // TODO: × (1 + Staff Affinity) - auto damage = (int32)floor((double)(abs(lastSkillDamage)) * g_SkillChainDamageModifiers[chainLevel][chainCount] / 1000 * - (100 + PAttacker->getMod(Mod::SKILLCHAINBONUS)) / 100 * (10000 + PAttacker->getMod(Mod::SKILLCHAINDMG)) / 10000); + auto damage = (int32)floor((double)(abs(lastSkillDamage))*g_SkillChainDamageModifiers[chainLevel][chainCount] / 1000 * (100 + PAttacker->getMod(Mod::SKILLCHAINBONUS)) / 100 * (10000 + PAttacker->getMod(Mod::SKILLCHAINDMG)) / 10000); auto* PChar = dynamic_cast(PAttacker); if (PChar && PChar->StatusEffectContainer->HasStatusEffect(EFFECT_INNIN) && behind(PChar->loc.p, PDefender->loc.p, 64)) @@ -4015,7 +3973,7 @@ namespace battleutils uint16 elementOffset = static_cast(DAMAGE_TYPE::ELEMENTAL) + static_cast(appliedEle); PDefender->takeDamage(damage, PAttacker, ATTACK_TYPE::SPECIAL, - appliedEle == ELEMENT_NONE ? DAMAGE_TYPE::NONE : static_cast(elementOffset), true); + appliedEle == ELEMENT_NONE ? DAMAGE_TYPE::NONE : static_cast(elementOffset), true); battleutils::ClaimMob(PDefender, PAttacker); PDefender->updatemask |= UPDATE_STATUS; @@ -4184,8 +4142,7 @@ namespace battleutils // Check For Futae Effect bool hasFutae = PChar->StatusEffectContainer->HasStatusEffect(EFFECT_FUTAE); // Futae only applies to Elemental Wheel Tools - bool useFutae = (toolID == ITEM_UCHITAKE || toolID == ITEM_TSURARA || toolID == ITEM_KAWAHORI_OGI || toolID == ITEM_MAKIBISHI || - toolID == ITEM_HIRAISHIN || toolID == ITEM_MIZU_DEPPO); + bool useFutae = (toolID == ITEM_UCHITAKE || toolID == ITEM_TSURARA || toolID == ITEM_KAWAHORI_OGI || toolID == ITEM_MAKIBISHI || toolID == ITEM_HIRAISHIN || toolID == ITEM_MIZU_DEPPO); // If you have Futae active, Ninja Tool Expertise does not apply. if (ConsumeTool && hasFutae && useFutae) @@ -4318,7 +4275,7 @@ namespace battleutils { // sorts by distance then by pointer id (only if floats are equal) std::sort(taTargetList.begin(), taTargetList.end()); - for (auto const& [dist, potentialTAtarget] : taTargetList) + for (const auto& [dist, potentialTAtarget] : taTargetList) { if (taUser->id == potentialTAtarget->id || // can't TA self potentialTAtarget->isDead()) // Dead entity should not be TA-able @@ -4694,8 +4651,7 @@ namespace battleutils { TracyZoneScoped; - if (PDefender == nullptr || - (PDefender && PDefender->objtype != ENTITYTYPE::TYPE_MOB) || // Do not try to claim anything but mobs (trusts, pets, players don't count) + if (PDefender == nullptr || (PDefender && PDefender->objtype != ENTITYTYPE::TYPE_MOB) || // Do not try to claim anything but mobs (trusts, pets, players don't count) (PDefender && PDefender->objtype == ENTITYTYPE::TYPE_MOB && PDefender->allegiance == ALLEGIANCE_TYPE::PLAYER)) // Added mobs that are in allied with player { return; @@ -4735,8 +4691,7 @@ namespace battleutils } if (!battleTarget || battleTarget == PDefender || battleTarget != attacker->PClaimedMob || PDefender->isDead()) { - if (PDefender->isAlive() && attacker->PClaimedMob && attacker->PClaimedMob != PDefender && attacker->PClaimedMob->isAlive() && - attacker->PClaimedMob->m_OwnerID.id == attacker->id) + if (PDefender->isAlive() && attacker->PClaimedMob && attacker->PClaimedMob != PDefender && attacker->PClaimedMob->isAlive() && attacker->PClaimedMob->m_OwnerID.id == attacker->id) { // unclaim any other living mobs owned by attacker static_cast(attacker->PClaimedMob->PAI->GetController())->TapDeclaimTime(); attacker->PClaimedMob = nullptr; @@ -4898,8 +4853,8 @@ namespace battleutils } // Handle damage nullification. - else if (xirand::GetRandomNumber(100) < PDefender->getMod(Mod::NULL_DAMAGE) || // All damage. - xirand::GetRandomNumber(100) < PDefender->getMod(Mod::NULL_BREATH_DAMAGE)) // Breath damage. + else if (xirand::GetRandomNumber(100) < PDefender->getMod(Mod::NULL_DAMAGE) || // All damage. + xirand::GetRandomNumber(100) < PDefender->getMod(Mod::NULL_BREATH_DAMAGE)) // Breath damage. { damage = 0; } @@ -4918,7 +4873,7 @@ namespace battleutils int32 MagicDmgTaken(CBattleEntity* PDefender, int32 damage, ELEMENT element) { Mod absorb[8] = { Mod::FIRE_ABSORB, Mod::ICE_ABSORB, Mod::WIND_ABSORB, Mod::EARTH_ABSORB, - Mod::LTNG_ABSORB, Mod::WATER_ABSORB, Mod::LIGHT_ABSORB, Mod::DARK_ABSORB }; + Mod::LTNG_ABSORB, Mod::WATER_ABSORB, Mod::LIGHT_ABSORB, Mod::DARK_ABSORB }; Mod nullarray[8] = { Mod::FIRE_NULL, Mod::ICE_NULL, Mod::WIND_NULL, Mod::EARTH_NULL, Mod::LTNG_NULL, Mod::WATER_NULL, Mod::LIGHT_NULL, Mod::DARK_NULL }; DAMAGE_TYPE damageType = (DAMAGE_TYPE)((uint8)DAMAGE_TYPE::ELEMENTAL + (uint8)element); @@ -4955,9 +4910,9 @@ namespace battleutils } // Handle damage nullification. - else if (xirand::GetRandomNumber(100) < PDefender->getMod(Mod::NULL_DAMAGE) || // All damage. - xirand::GetRandomNumber(100) < PDefender->getMod(Mod::NULL_MAGICAL_DAMAGE) || // Magical damage - (element && xirand::GetRandomNumber(100) < PDefender->getMod(nullarray[element - 1]))) // Elemental damage. + else if (xirand::GetRandomNumber(100) < PDefender->getMod(Mod::NULL_DAMAGE) || // All damage. + xirand::GetRandomNumber(100) < PDefender->getMod(Mod::NULL_MAGICAL_DAMAGE) || // Magical damage + (element && xirand::GetRandomNumber(100) < PDefender->getMod(nullarray[element - 1]))) // Elemental damage. { damage = 0; } @@ -5000,8 +4955,8 @@ namespace battleutils } // Handle damage nullification. - else if (xirand::GetRandomNumber(100) < PDefender->getMod(Mod::NULL_DAMAGE) || // All damage. - xirand::GetRandomNumber(100) < PDefender->getMod(Mod::NULL_PHYSICAL_DAMAGE)) // Physical damage. + else if (xirand::GetRandomNumber(100) < PDefender->getMod(Mod::NULL_DAMAGE) || // All damage. + xirand::GetRandomNumber(100) < PDefender->getMod(Mod::NULL_PHYSICAL_DAMAGE)) // Physical damage. { damage = 0; } @@ -5048,8 +5003,8 @@ namespace battleutils } // Handle damage nullification. - else if (xirand::GetRandomNumber(100) < PDefender->getMod(Mod::NULL_DAMAGE) || // All damage. - xirand::GetRandomNumber(100) < PDefender->getMod(Mod::NULL_RANGED_DAMAGE)) // Ranged damage. + else if (xirand::GetRandomNumber(100) < PDefender->getMod(Mod::NULL_DAMAGE) || // All damage. + xirand::GetRandomNumber(100) < PDefender->getMod(Mod::NULL_RANGED_DAMAGE)) // Ranged damage. { damage = 0; } @@ -5229,8 +5184,7 @@ namespace battleutils damage = HandleSevereDamageEffect(PDefender, EFFECT_MIGAWARI, damage, true); // In the future, handle other Severe Damage Effects like Earthen Armor here - if (isPhysical && PDefender->objtype == TYPE_PET && PDefender->getMod(Mod::AUTO_SCHURZEN) != 0 && damage >= PDefender->health.hp && - ((CPetEntity*)PDefender)->PMaster->StatusEffectContainer->GetEffectsCount(EFFECT_EARTH_MANEUVER) >= 1) + if (isPhysical && PDefender->objtype == TYPE_PET && PDefender->getMod(Mod::AUTO_SCHURZEN) != 0 && damage >= PDefender->health.hp && ((CPetEntity*)PDefender)->PMaster->StatusEffectContainer->GetEffectsCount(EFFECT_EARTH_MANEUVER) >= 1) { damage = PDefender->health.hp - 1; ((CPetEntity*)PDefender)->PMaster->StatusEffectContainer->DelStatusEffectSilent(EFFECT_EARTH_MANEUVER); @@ -5337,17 +5291,14 @@ namespace battleutils uint8 GetSpellAoEType(CBattleEntity* PCaster, CSpell* PSpell) { // Majesty turns the Cure and Protect spell families into AoE when active - if (PCaster->StatusEffectContainer->HasStatusEffect(EFFECT_MAJESTY) && - (PSpell->getSpellFamily() == SPELLFAMILY_CURE || PSpell->getSpellFamily() == SPELLFAMILY_PROTECT)) + if (PCaster->StatusEffectContainer->HasStatusEffect(EFFECT_MAJESTY) && (PSpell->getSpellFamily() == SPELLFAMILY_CURE || PSpell->getSpellFamily() == SPELLFAMILY_PROTECT)) { return SPELLAOE_RADIAL; } if (PSpell->getAOE() == SPELLAOE_RADIAL_ACCE) // Divine Veil goes here because -na spells have AoE w/ Accession { - if (PCaster->StatusEffectContainer->HasStatusEffect(EFFECT_ACCESSION) || - (PCaster->objtype == TYPE_PC && charutils::hasTrait((CCharEntity*)PCaster, TRAIT_DIVINE_VEIL) && PSpell->isNa() && - (PCaster->StatusEffectContainer->HasStatusEffect(EFFECT_DIVINE_SEAL) || xirand::GetRandomNumber(100) < PCaster->getMod(Mod::AOE_NA)))) + if (PCaster->StatusEffectContainer->HasStatusEffect(EFFECT_ACCESSION) || (PCaster->objtype == TYPE_PC && charutils::hasTrait((CCharEntity*)PCaster, TRAIT_DIVINE_VEIL) && PSpell->isNa() && (PCaster->StatusEffectContainer->HasStatusEffect(EFFECT_DIVINE_SEAL) || xirand::GetRandomNumber(100) < PCaster->getMod(Mod::AOE_NA)))) { return SPELLAOE_RADIAL; } @@ -6219,8 +6170,7 @@ namespace battleutils } if (PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_NIGHTINGALE)) { - if (PEntity->objtype == TYPE_PC && - xirand::GetRandomNumber(100) < ((CCharEntity*)PEntity)->PMeritPoints->GetMeritValue(MERIT_NIGHTINGALE, (CCharEntity*)PEntity) - 25) + if (PEntity->objtype == TYPE_PC && xirand::GetRandomNumber(100) < ((CCharEntity*)PEntity)->PMeritPoints->GetMeritValue(MERIT_NIGHTINGALE, (CCharEntity*)PEntity) - 25) { return 0; } @@ -6379,8 +6329,7 @@ namespace battleutils recast -= ((CCharEntity*)PEntity)->PMeritPoints->GetMeritValue(MERIT_FINALE_RECAST, (CCharEntity*)PEntity) * 1000; } - if (PSpell->getID() == SpellID::Foe_Lullaby || PSpell->getID() == SpellID::Foe_Lullaby_II || PSpell->getID() == SpellID::Horde_Lullaby || - PSpell->getID() == SpellID::Horde_Lullaby_II) // apply Lullaby recast merits + if (PSpell->getID() == SpellID::Foe_Lullaby || PSpell->getID() == SpellID::Foe_Lullaby_II || PSpell->getID() == SpellID::Horde_Lullaby || PSpell->getID() == SpellID::Horde_Lullaby_II) // apply Lullaby recast merits { recast -= ((CCharEntity*)PEntity)->PMeritPoints->GetMeritValue(MERIT_LULLABY_RECAST, (CCharEntity*)PEntity) * 1000; } @@ -6552,8 +6501,7 @@ namespace battleutils CItemEquipment* PSub = PChar->getEquip(SLOT_SUB); CItemWeapon* PSubWeapon = dynamic_cast(PChar->m_Weapons[SLOT_SUB]); - if (PMain && !PMain->isTwoHanded() && !PMain->isHandToHand() && - (!PSub || (PSubWeapon && PSubWeapon->getSkillType() == SKILL_NONE) || PSub->IsShield())) + if (PMain && !PMain->isTwoHanded() && !PMain->isHandToHand() && (!PSub || (PSubWeapon && PSubWeapon->getSkillType() == SKILL_NONE) || PSub->IsShield())) { tp += PEntity->getMod(Mod::FENCER_TP_BONUS); } @@ -6772,8 +6720,7 @@ namespace battleutils { for (auto member : PCoverAbilityTarget->PParty->members) { - if (coverAbilityTargetID == member->GetLocalVar("COVER_ABILITY_TARGET") && member->StatusEffectContainer->HasStatusEffect(EFFECT_COVER) && - member->isAlive()) + if (coverAbilityTargetID == member->GetLocalVar("COVER_ABILITY_TARGET") && member->StatusEffectContainer->HasStatusEffect(EFFECT_COVER) && member->isAlive()) { PCoverAbilityUser = member; break; diff --git a/src/map/utils/battleutils.h b/src/map/utils/battleutils.h index 8eff76652cd..6382e76dbb1 100644 --- a/src/map/utils/battleutils.h +++ b/src/map/utils/battleutils.h @@ -156,10 +156,10 @@ namespace battleutils float GetDamageRatio(CBattleEntity* PAttacker, CBattleEntity* PDefender, bool isCritical, float bonusAttPercent, SKILLTYPE weaponType, SLOTTYPE weaponSlot); int32 TakePhysicalDamage(CBattleEntity* PAttacker, CBattleEntity* PDefender, PHYSICAL_ATTACK_TYPE physicalAttackType, int32 damage, bool isBlocked, - uint8 slot, uint16 tpMultiplier, CBattleEntity* taChar, bool giveTPtoVictim, bool giveTPtoAttacker, bool isCounter = false, - bool isCovered = false, CBattleEntity* POriginalTarget = nullptr); + uint8 slot, uint16 tpMultiplier, CBattleEntity* taChar, bool giveTPtoVictim, bool giveTPtoAttacker, bool isCounter = false, + bool isCovered = false, CBattleEntity* POriginalTarget = nullptr); int32 TakeWeaponskillDamage(CBattleEntity* PAttacker, CBattleEntity* PDefender, int32 damage, ATTACK_TYPE attackType, DAMAGE_TYPE damageType, uint8 slot, - bool primary, float tpMultiplier, uint16 bonusTP, float targetTPMultiplier); + bool primary, float tpMultiplier, uint16 bonusTP, float targetTPMultiplier); int32 TakeSkillchainDamage(CBattleEntity* PAttacker, CBattleEntity* PDefender, int32 lastSkillDamage, CBattleEntity* taChar); int32 TakeSpellDamage(CBattleEntity* PDefender, CCharEntity* PAttacker, CSpell* PSpell, int32 damage, ATTACK_TYPE attackType, DAMAGE_TYPE damageType); int32 TakeSwipeLungeDamage(CBattleEntity* PDefender, CCharEntity* PAttacker, int32 damage, ATTACK_TYPE attackType, DAMAGE_TYPE damageType); diff --git a/src/map/utils/blueutils.cpp b/src/map/utils/blueutils.cpp index 90f429ea042..ad6b99e0bb8 100644 --- a/src/map/utils/blueutils.cpp +++ b/src/map/utils/blueutils.cpp @@ -324,7 +324,7 @@ namespace blueutils { auto set_blue_spells = db::encodeToBlob(PChar->m_SetBlueSpells); auto query = fmt::format("UPDATE chars SET set_blue_spells = '{}' WHERE charid = {} LIMIT 1", - set_blue_spells, PChar->id); + set_blue_spells, PChar->id); db::query(query); } } diff --git a/src/map/utils/charutils.cpp b/src/map/utils/charutils.cpp index a1a5d63122d..ea542cd0ca8 100644 --- a/src/map/utils/charutils.cpp +++ b/src/map/utils/charutils.cpp @@ -209,16 +209,12 @@ namespace charutils grade = grade::GetRaceGrades(race, 0); - raceStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * mainLevelUpTo60) + - (grade::GetHPScale(grade, scaleOver30Column) * mainLevelOver30) + (grade::GetHPScale(grade, scaleOver60Column) * mainLevelOver60To75) + - (grade::GetHPScale(grade, scaleOver75Column) * mainLevelOver75); + raceStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * mainLevelUpTo60) + (grade::GetHPScale(grade, scaleOver30Column) * mainLevelOver30) + (grade::GetHPScale(grade, scaleOver60Column) * mainLevelOver60To75) + (grade::GetHPScale(grade, scaleOver75Column) * mainLevelOver75); // Calculation on Main Job grade = grade::GetJobGrade(mjob, 0); - jobStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * mainLevelUpTo60) + - (grade::GetHPScale(grade, scaleOver30Column) * mainLevelOver30) + (grade::GetHPScale(grade, scaleOver60Column) * mainLevelOver60To75) + - (grade::GetHPScale(grade, scaleOver75Column) * mainLevelOver75); + jobStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * mainLevelUpTo60) + (grade::GetHPScale(grade, scaleOver30Column) * mainLevelOver30) + (grade::GetHPScale(grade, scaleOver60Column) * mainLevelOver60To75) + (grade::GetHPScale(grade, scaleOver75Column) * mainLevelOver75); // Calculation of bonus HP. bonusStat = (mainLevelOver10 + mainLevelOver50andUnder60) * 2; @@ -228,8 +224,7 @@ namespace charutils { grade = grade::GetJobGrade(sjob, 0); - sJobStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * (slvl - 1)) + - (grade::GetHPScale(grade, scaleOver30Column) * subLevelOver30) + subLevelOver30 + subLevelOver10; + sJobStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * (slvl - 1)) + (grade::GetHPScale(grade, scaleOver30Column) * subLevelOver30) + subLevelOver30 + subLevelOver10; sJobStat = sJobStat / 2; } @@ -250,23 +245,20 @@ namespace charutils { if (grade::GetJobGrade(sjob, 1) != 0 && slvl > 0) // TODO: In this expression, an error { - raceStat = - (grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * (slvl - 1)) / settings::get("map.SJ_MP_DIVISOR"); // TODO: Here is a mistake + raceStat = (grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * (slvl - 1)) / settings::get("map.SJ_MP_DIVISOR"); // TODO: Here is a mistake } } else { // Calculation of a normal racial bonus - raceStat = grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * mainLevelUpTo60 + - grade::GetMPScale(grade, scaleOver60) * mainLevelOver60; + raceStat = grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * mainLevelUpTo60 + grade::GetMPScale(grade, scaleOver60) * mainLevelOver60; } // Main Job grade = grade::GetJobGrade(mjob, 1); if (grade > 0) { - jobStat = grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * mainLevelUpTo60 + - grade::GetMPScale(grade, scaleOver60) * mainLevelOver60; + jobStat = grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * mainLevelUpTo60 + grade::GetMPScale(grade, scaleOver60) * mainLevelOver60; } // Subjob @@ -876,7 +868,7 @@ namespace charutils // Compile a list of all enabled expansions std::vector enabledExpansions; - for (auto const& expansion : { "COP", "TOAU", "WOTG", "ACP", "AMK", "ASA", "ABYSSEA", "SOA", "ROV", "TVR", "VOIDWATCH" }) + for (const auto& expansion : { "COP", "TOAU", "WOTG", "ACP", "AMK", "ASA", "ABYSSEA", "SOA", "ROV", "TVR", "VOIDWATCH" }) { if (luautils::IsContentEnabled(expansion)) { @@ -892,7 +884,7 @@ namespace charutils "WHERE charid = (?) AND " "(spell_list.content_tag IN ({}) OR " "spell_list.content_tag IS NULL)", - fmt::join(enabledExpansions, ",")); + fmt::join(enabledExpansions, ",")); auto rset = db::preparedStmt(query, PChar->id); if (rset && rset->rowsCount()) @@ -1041,7 +1033,7 @@ namespace charutils CItemLinkshell* PLinkshell2 = nullptr; bool hasMainWeapon = false; - for (auto const& [equipSlotId, inventoryLoc] : equipSlotData) + for (const auto& [equipSlotId, inventoryLoc] : equipSlotData) { if (equipSlotId < 16) { @@ -1089,7 +1081,7 @@ namespace charutils PLinkshell1->setSubType(ITEM_UNLOCKED); PChar->equip[SLOT_LINK1] = 0; db::query(fmt::format("DELETE char_equip FROM char_equip WHERE charid = {} AND slotid = {} AND containerid = {}", - PChar->id, SlotID, LocationID)); + PChar->id, SlotID, LocationID)); } else { @@ -1107,7 +1099,7 @@ namespace charutils PLinkshell2->setSubType(ITEM_UNLOCKED); PChar->equip[SLOT_LINK2] = 0; db::query(fmt::format("DELETE char_equip FROM char_equip WHERE charid = {} AND slotid = {} AND containerid = {}", - PChar->id, SlotID, LocationID)); + PChar->id, SlotID, LocationID)); } else { @@ -1214,9 +1206,9 @@ namespace charutils // TODO: What order are these sent in? for (auto&& containerID : { LOC_INVENTORY, LOC_TEMPITEMS, LOC_WARDROBE, LOC_WARDROBE2, LOC_WARDROBE3, LOC_WARDROBE4, - LOC_WARDROBE5, LOC_WARDROBE6, LOC_WARDROBE7, LOC_WARDROBE8, - LOC_MOGSAFE, LOC_STORAGE, - LOC_MOGLOCKER, LOC_MOGSATCHEL, LOC_MOGSACK, LOC_MOGCASE, LOC_MOGSAFE2 }) + LOC_WARDROBE5, LOC_WARDROBE6, LOC_WARDROBE7, LOC_WARDROBE8, + LOC_MOGSAFE, LOC_STORAGE, + LOC_MOGLOCKER, LOC_MOGSATCHEL, LOC_MOGSACK, LOC_MOGCASE, LOC_MOGSAFE2 }) { pushContainer(containerID); } @@ -1738,8 +1730,7 @@ namespace charutils if (PItem->isSubType(ITEM_CHARGED)) { - PChar->PRecastContainer->Del(RECAST_ITEM, PItem->getSlotID() << 8 | - PItem->getLocationID()); // Also remove item from the Recast List no matter what bag its in + PChar->PRecastContainer->Del(RECAST_ITEM, PItem->getSlotID() << 8 | PItem->getLocationID()); // Also remove item from the Recast List no matter what bag its in } PItem->setSubType(ITEM_UNLOCKED); @@ -1896,18 +1887,14 @@ namespace charutils return false; } - if ((PChar->m_EquipBlock & (1 << equipSlotID)) || !(PItem->getJobs() & (1 << (PChar->GetMJob() - 1))) || - (PItem->getSuperiorLevel() > PChar->getMod(Mod::SUPERIOR_LEVEL)) || - (PItem->getReqLvl() > (settings::get("map.DISABLE_GEAR_SCALING") ? PChar->GetMLevel() : PChar->jobs.job[PChar->GetMJob()])) || - !PItem->isEquippableByRace(PChar->look.race)) + if ((PChar->m_EquipBlock & (1 << equipSlotID)) || !(PItem->getJobs() & (1 << (PChar->GetMJob() - 1))) || (PItem->getSuperiorLevel() > PChar->getMod(Mod::SUPERIOR_LEVEL)) || (PItem->getReqLvl() > (settings::get("map.DISABLE_GEAR_SCALING") ? PChar->GetMLevel() : PChar->jobs.job[PChar->GetMJob()])) || !PItem->isEquippableByRace(PChar->look.race)) { return false; } if (equipSlotID == SLOT_MAIN) { - if (!(slotID == PItem->getSlotID() && oldItem && (oldItem->isType(ITEM_WEAPON) && PItem->isType(ITEM_WEAPON)) && - (static_cast(PItem)->isTwoHanded() && static_cast(oldItem)->isTwoHanded()))) + if (!(slotID == PItem->getSlotID() && oldItem && (oldItem->isType(ITEM_WEAPON) && PItem->isType(ITEM_WEAPON)) && (static_cast(PItem)->isTwoHanded() && static_cast(oldItem)->isTwoHanded()))) { CItemEquipment* PSubItem = PChar->getEquip(SLOT_SUB); @@ -2094,8 +2081,7 @@ namespace charutils CItemWeapon* weapon = dynamic_cast(PChar->getEquip(SLOT_AMMO)); if (weapon) { - if (static_cast(PItem)->getSkillType() != weapon->getSkillType() || - static_cast(PItem)->getSubSkillType() != weapon->getSubSkillType()) + if (static_cast(PItem)->getSkillType() != weapon->getSkillType() || static_cast(PItem)->getSubSkillType() != weapon->getSubSkillType()) { UnequipItem(PChar, SLOT_AMMO, false); } @@ -2113,8 +2099,7 @@ namespace charutils CItemWeapon* weapon = dynamic_cast(PChar->getEquip(SLOT_RANGED)); if (weapon) { - if (static_cast(PItem)->getSkillType() != weapon->getSkillType() || - static_cast(PItem)->getSubSkillType() != weapon->getSubSkillType()) + if (static_cast(PItem)->getSkillType() != weapon->getSkillType() || static_cast(PItem)->getSubSkillType() != weapon->getSubSkillType()) { UnequipItem(PChar, SLOT_RANGED, false); } @@ -2499,7 +2484,7 @@ namespace charutils // Evict recycle bin slot 1 RecycleBin->InsertItem(nullptr, 1); _sql->Query("DELETE FROM char_inventory WHERE charid = %u AND location = %u AND slot = %u", - PChar->id, LOC_RECYCLEBIN, 1); + PChar->id, LOC_RECYCLEBIN, 1); // Move everything around to accomodate for (int i = 2; i <= 10; ++i) @@ -2597,8 +2582,8 @@ namespace charutils uint16 back = getEquipIdFromSlot(PChar, SLOT_BACK); _sql->Query(Query, PChar->id, PChar->GetMJob(), main, sub, ranged, ammo, - head, body, hands, legs, feet, neck, waist, ear1, ear2, ring1, - ring2, back); + head, body, hands, legs, feet, neck, waist, ear1, ear2, ring1, + ring2, back); } void LoadJobChangeGear(CCharEntity* PChar) @@ -2629,9 +2614,7 @@ namespace charutils CItem* PItem = PChar->getStorage(container)->GetItem(slot); auto* PEquip = dynamic_cast(PItem); - if ((PItem != nullptr && PItem->getID() == itemId && PEquip != nullptr) && - (PEquip != PChar->getEquip(static_cast(equipSlot - 1)) && - PEquip != PChar->getEquip(static_cast(equipSlot + 1)))) + if ((PItem != nullptr && PItem->getID() == itemId && PEquip != nullptr) && (PEquip != PChar->getEquip(static_cast(equipSlot - 1)) && PEquip != PChar->getEquip(static_cast(equipSlot + 1)))) { found = true; charutils::EquipItem(PChar, PItem->getSlotID(), equipSlot, static_cast(container)); @@ -2720,7 +2703,7 @@ namespace charutils { PItem->setAssignTime(CVanaTime::getInstance()->getVanaTime()); PChar->PRecastContainer->Add(RECAST_ITEM, slotID << 8 | containerID, - PItem->getReuseTime() / 1000); // add recast timer to Recast List from any bag + PItem->getReuseTime() / 1000); // add recast timer to Recast List from any bag // Do not forget to update the timer when equipping the subject @@ -2753,16 +2736,14 @@ namespace charutils } if (equipSlotID == SLOT_MAIN || equipSlotID == SLOT_RANGED || equipSlotID == SLOT_SUB) { - if (!PItem || !PItem->isType(ITEM_EQUIPMENT) || - (((CItemWeapon*)PItem)->getSkillType() != SKILL_STRING_INSTRUMENT && ((CItemWeapon*)PItem)->getSkillType() != SKILL_WIND_INSTRUMENT)) + if (!PItem || !PItem->isType(ITEM_EQUIPMENT) || (((CItemWeapon*)PItem)->getSkillType() != SKILL_STRING_INSTRUMENT && ((CItemWeapon*)PItem)->getSkillType() != SKILL_WIND_INSTRUMENT)) { // If the weapon ISN'T a wind based instrument or a string based instrument PChar->health.tp = 0; PChar->StatusEffectContainer->DelStatusEffect(EFFECT_AFTERMATH); } - if (!PChar->getEquip(SLOT_MAIN) || !PChar->getEquip(SLOT_MAIN)->isType(ITEM_EQUIPMENT) || - PChar->m_Weapons[SLOT_MAIN] == itemutils::GetUnarmedH2HItem()) + if (!PChar->getEquip(SLOT_MAIN) || !PChar->getEquip(SLOT_MAIN)->isType(ITEM_EQUIPMENT) || PChar->m_Weapons[SLOT_MAIN] == itemutils::GetUnarmedH2HItem()) { CheckUnarmedWeapon(PChar); } @@ -2901,7 +2882,7 @@ namespace charutils bool isInDynamis = PChar->isInDynamis(); for (auto&& slot : - { std::make_tuple(SLOT_MAIN, std::ref(main_ws), std::ref(main_ws_dyn)), std::make_tuple(SLOT_RANGED, std::ref(range_ws), std::ref(range_ws_dyn)) }) + { std::make_tuple(SLOT_MAIN, std::ref(main_ws), std::ref(main_ws_dyn)), std::make_tuple(SLOT_RANGED, std::ref(range_ws), std::ref(range_ws_dyn)) }) { if (PChar->m_Weapons[std::get<0>(slot)]) { @@ -3125,41 +3106,41 @@ namespace charutils void BuildingCharSkillsTable(CCharEntity* PChar) { MERIT_TYPE skillMerit[] = { MERIT_H2H, - MERIT_DAGGER, - MERIT_SWORD, - MERIT_GSWORD, - MERIT_AXE, - MERIT_GAXE, - MERIT_SCYTHE, - MERIT_POLEARM, - MERIT_KATANA, - MERIT_GKATANA, - MERIT_CLUB, - MERIT_STAFF, - MERIT_AUTOMATON_SKILLS, - MERIT_AUTOMATON_SKILLS, - MERIT_AUTOMATON_SKILLS, - MERIT_ARCHERY, - MERIT_MARKSMANSHIP, - MERIT_THROWING, - MERIT_GUARDING, - MERIT_EVASION, - MERIT_SHIELD, - MERIT_PARRYING, - MERIT_DIVINE, - MERIT_HEALING, - MERIT_ENHANCING, - MERIT_ENFEEBLING, - MERIT_ELEMENTAL, - MERIT_DARK, - MERIT_SUMMONING, - MERIT_NINJITSU, - MERIT_SINGING, - MERIT_STRING, - MERIT_WIND, - MERIT_BLUE, - MERIT_GEO, - MERIT_HANDBELL }; + MERIT_DAGGER, + MERIT_SWORD, + MERIT_GSWORD, + MERIT_AXE, + MERIT_GAXE, + MERIT_SCYTHE, + MERIT_POLEARM, + MERIT_KATANA, + MERIT_GKATANA, + MERIT_CLUB, + MERIT_STAFF, + MERIT_AUTOMATON_SKILLS, + MERIT_AUTOMATON_SKILLS, + MERIT_AUTOMATON_SKILLS, + MERIT_ARCHERY, + MERIT_MARKSMANSHIP, + MERIT_THROWING, + MERIT_GUARDING, + MERIT_EVASION, + MERIT_SHIELD, + MERIT_PARRYING, + MERIT_DIVINE, + MERIT_HEALING, + MERIT_ENHANCING, + MERIT_ENFEEBLING, + MERIT_ELEMENTAL, + MERIT_DARK, + MERIT_SUMMONING, + MERIT_NINJITSU, + MERIT_SINGING, + MERIT_STRING, + MERIT_WIND, + MERIT_BLUE, + MERIT_GEO, + MERIT_HANDBELL }; uint8 meritIndex = 0; @@ -3177,8 +3158,7 @@ namespace charutils int16 skillBonus = 0; // apply arts bonuses - if ((i >= SKILL_DIVINE_MAGIC && i <= SKILL_ENFEEBLING_MAGIC && PChar->StatusEffectContainer->HasStatusEffect({ EFFECT_LIGHT_ARTS, EFFECT_ADDENDUM_WHITE })) || - (i >= SKILL_ENFEEBLING_MAGIC && i <= SKILL_DARK_MAGIC && PChar->StatusEffectContainer->HasStatusEffect({ EFFECT_DARK_ARTS, EFFECT_ADDENDUM_BLACK }))) + if ((i >= SKILL_DIVINE_MAGIC && i <= SKILL_ENFEEBLING_MAGIC && PChar->StatusEffectContainer->HasStatusEffect({ EFFECT_LIGHT_ARTS, EFFECT_ADDENDUM_WHITE })) || (i >= SKILL_ENFEEBLING_MAGIC && i <= SKILL_DARK_MAGIC && PChar->StatusEffectContainer->HasStatusEffect({ EFFECT_DARK_ARTS, EFFECT_ADDENDUM_BLACK }))) { uint16 artsSkill = battleutils::GetMaxSkill(SKILL_ENHANCING_MAGIC, JOB_RDM, PChar->GetMLevel()); // B+ skill uint16 skillCapD = battleutils::GetMaxSkill((SKILLTYPE)i, JOB_SCH, PChar->GetMLevel()); // D skill cap @@ -4596,7 +4576,7 @@ namespace charutils uint8 mobLevel = PMob->GetMLevel(); PChar->ForAlliance([&PMob, &zone, &mobLevel](CBattleEntity* PPartyMember) - { + { CCharEntity* PMember = dynamic_cast(PPartyMember); if (!PMember || PMember->isDead() || (PMember->loc.zone->GetID() != zone)) @@ -4647,7 +4627,8 @@ namespace charutils capacityPoints = AddCapacityBonus(PMember, capacityPoints); AddCapacityPoints(PMember, PMob, capacityPoints, levelDiff, chainActive); - } }); + } + }); } /************************************************************************ @@ -4691,7 +4672,7 @@ namespace charutils } // RoE Objectives - for (auto const& recordValue : roeCapacityBonusRecords) + for (const auto& recordValue : roeCapacityBonusRecords) { if (roeutils::GetEminenceRecordCompletion(PChar, recordValue.first)) { @@ -4915,8 +4896,7 @@ namespace charutils } // we check if the player is level capped and max exp.. - if (PChar->jobs.job[PChar->GetMJob()] > 74 && PChar->jobs.job[PChar->GetMJob()] >= PChar->jobs.genkai && - PChar->jobs.exp[PChar->GetMJob()] == GetExpNEXTLevel(PChar->jobs.job[PChar->GetMJob()]) - 1) + if (PChar->jobs.job[PChar->GetMJob()] > 74 && PChar->jobs.job[PChar->GetMJob()] >= PChar->jobs.genkai && PChar->jobs.exp[PChar->GetMJob()] == GetExpNEXTLevel(PChar->jobs.job[PChar->GetMJob()]) - 1) { onLimitMode = true; } @@ -5198,8 +5178,8 @@ namespace charutils "WHERE charid = %u"; _sql->Query(Query, PChar->profile.fame[0], PChar->profile.fame[1], PChar->profile.fame[2], PChar->profile.fame[3], PChar->profile.fame[4], - PChar->profile.fame[5], PChar->profile.fame[6], PChar->profile.fame[7], PChar->profile.fame[8], PChar->profile.fame[9], - PChar->profile.fame[10], PChar->profile.fame[11], PChar->profile.fame[12], PChar->profile.fame[13], PChar->profile.fame[14], PChar->id); + PChar->profile.fame[5], PChar->profile.fame[6], PChar->profile.fame[7], PChar->profile.fame[8], PChar->profile.fame[9], + PChar->profile.fame[10], PChar->profile.fame[11], PChar->profile.fame[12], PChar->profile.fame[13], PChar->profile.fame[14], PChar->id); } /************************************************************************ @@ -5234,7 +5214,7 @@ namespace charutils _sql->EscapeStringLen(campaignList, (const char*)&PChar->m_campaignLog, sizeof(PChar->m_campaignLog)); _sql->Query(Query, missionslist, assaultList, campaignList, PChar->profile.rankpoints, PChar->profile.rank[0], PChar->profile.rank[1], - PChar->profile.rank[2], PChar->id); + PChar->profile.rank[2], PChar->id); } /************************************************************************ @@ -5287,21 +5267,21 @@ namespace charutils "WHERE charid = %u"; _sql->Query(Query, - PChar->getStorage(LOC_INVENTORY)->GetSize(), - PChar->getStorage(LOC_MOGSAFE)->GetSize(), - PChar->getStorage(LOC_MOGLOCKER)->GetSize(), - PChar->getStorage(LOC_MOGSATCHEL)->GetSize(), - PChar->getStorage(LOC_MOGSACK)->GetSize(), - PChar->getStorage(LOC_MOGCASE)->GetSize(), - PChar->getStorage(LOC_WARDROBE)->GetSize(), - PChar->getStorage(LOC_WARDROBE2)->GetSize(), - PChar->getStorage(LOC_WARDROBE3)->GetSize(), - PChar->getStorage(LOC_WARDROBE4)->GetSize(), - PChar->getStorage(LOC_WARDROBE5)->GetSize(), - PChar->getStorage(LOC_WARDROBE6)->GetSize(), - PChar->getStorage(LOC_WARDROBE7)->GetSize(), - PChar->getStorage(LOC_WARDROBE8)->GetSize(), - PChar->id); + PChar->getStorage(LOC_INVENTORY)->GetSize(), + PChar->getStorage(LOC_MOGSAFE)->GetSize(), + PChar->getStorage(LOC_MOGLOCKER)->GetSize(), + PChar->getStorage(LOC_MOGSATCHEL)->GetSize(), + PChar->getStorage(LOC_MOGSACK)->GetSize(), + PChar->getStorage(LOC_MOGCASE)->GetSize(), + PChar->getStorage(LOC_WARDROBE)->GetSize(), + PChar->getStorage(LOC_WARDROBE2)->GetSize(), + PChar->getStorage(LOC_WARDROBE3)->GetSize(), + PChar->getStorage(LOC_WARDROBE4)->GetSize(), + PChar->getStorage(LOC_WARDROBE5)->GetSize(), + PChar->getStorage(LOC_WARDROBE6)->GetSize(), + PChar->getStorage(LOC_WARDROBE7)->GetSize(), + PChar->getStorage(LOC_WARDROBE8)->GetSize(), + PChar->id); } /************************************************************************ @@ -5427,8 +5407,8 @@ namespace charutils "main = VALUES(main), sub = VALUES(sub), ranged = VALUES(ranged)"; _sql->Query(Query, PChar->id, PChar->styleItems[SLOT_HEAD], PChar->styleItems[SLOT_BODY], PChar->styleItems[SLOT_HANDS], - PChar->styleItems[SLOT_LEGS], PChar->styleItems[SLOT_FEET], PChar->styleItems[SLOT_MAIN], PChar->styleItems[SLOT_SUB], - PChar->styleItems[SLOT_RANGED]); + PChar->styleItems[SLOT_LEGS], PChar->styleItems[SLOT_FEET], PChar->styleItems[SLOT_MAIN], PChar->styleItems[SLOT_SUB], + PChar->styleItems[SLOT_RANGED]); } /************************************************************************ @@ -5447,7 +5427,7 @@ namespace charutils "WHERE charid = %u"; _sql->Query(Query, PChar->health.hp, PChar->health.mp, PChar->profile.mhflag, PChar->GetMJob(), PChar->GetSJob(), - PChar->petZoningInfo.petID, static_cast(PChar->petZoningInfo.petType), PChar->petZoningInfo.petHP, PChar->petZoningInfo.petMP, PChar->petZoningInfo.petLevel, PChar->id); + PChar->petZoningInfo.petID, static_cast(PChar->petZoningInfo.petType), PChar->petZoningInfo.petHP, PChar->petZoningInfo.petMP, PChar->petZoningInfo.petLevel, PChar->id); // These two are jug only variables. We should probably move pet char stats into its own table, but in the meantime // we use charvars for jug specific things @@ -5792,7 +5772,7 @@ namespace charutils "ON DUPLICATE KEY UPDATE value = %u, rank = %u"; _sql->Query(Query, PChar->id, SkillID, PChar->RealSkills.skill[SkillID], PChar->RealSkills.rank[SkillID], PChar->RealSkills.skill[SkillID], - PChar->RealSkills.rank[SkillID]); + PChar->RealSkills.rank[SkillID]); } /************************************************************************ @@ -5977,10 +5957,10 @@ namespace charutils int16 weatherReduction = PChar->getMod(Mod::WEATHER_REDUCTION); // As seen on Summoner's Horn (Weather: Avatar perpetuation cost -3) etc. static const Mod strong[8] = { Mod::FIRE_AFFINITY_PERP, Mod::ICE_AFFINITY_PERP, Mod::WIND_AFFINITY_PERP, Mod::EARTH_AFFINITY_PERP, - Mod::THUNDER_AFFINITY_PERP, Mod::WATER_AFFINITY_PERP, Mod::LIGHT_AFFINITY_PERP, Mod::DARK_AFFINITY_PERP }; + Mod::THUNDER_AFFINITY_PERP, Mod::WATER_AFFINITY_PERP, Mod::LIGHT_AFFINITY_PERP, Mod::DARK_AFFINITY_PERP }; static const WEATHER weatherStrong[8] = { WEATHER_HOT_SPELL, WEATHER_SNOW, WEATHER_WIND, WEATHER_DUST_STORM, - WEATHER_THUNDER, WEATHER_RAIN, WEATHER_AURORAS, WEATHER_GLOOM }; + WEATHER_THUNDER, WEATHER_RAIN, WEATHER_AURORAS, WEATHER_GLOOM }; // If you wear a fire staff, you have +2 perp affinity reduction for fire, but -2 for ice as mods. perpReduction += PChar->getMod(strong[petElementIdx]); @@ -6045,8 +6025,7 @@ namespace charutils CItem* PSubslot = PChar->getEquip(SLOT_SUB); // Main or sub job provides H2H skill, and sub slot is empty. - if ((battleutils::GetSkillRank(SKILL_HAND_TO_HAND, PChar->GetMJob()) > 0 || battleutils::GetSkillRank(SKILL_HAND_TO_HAND, PChar->GetSJob()) > 0) && - (!PSubslot || !PSubslot->isType(ITEM_EQUIPMENT))) + if ((battleutils::GetSkillRank(SKILL_HAND_TO_HAND, PChar->GetMJob()) > 0 || battleutils::GetSkillRank(SKILL_HAND_TO_HAND, PChar->GetSJob()) > 0) && (!PSubslot || !PSubslot->isType(ITEM_EQUIPMENT))) { PChar->m_Weapons[SLOT_MAIN] = itemutils::GetUnarmedH2HItem(); PChar->look.main = 21; // The secret to H2H animations. setModelId for UnarmedH2H didn't work. @@ -6133,8 +6112,7 @@ namespace charutils } if ((PAbility->getAddType() & (ADDTYPE_JUGPET | ADDTYPE_CHARMPET)) == (ADDTYPE_JUGPET | ADDTYPE_CHARMPET)) { - if (!PChar->PPet || !(PChar->PPet->objtype == TYPE_MOB || - (PChar->PPet->objtype == TYPE_PET && static_cast(PChar->PPet)->getPetType() == PET_TYPE::JUG_PET))) + if (!PChar->PPet || !(PChar->PPet->objtype == TYPE_MOB || (PChar->PPet->objtype == TYPE_PET && static_cast(PChar->PPet)->getPetType() == PET_TYPE::JUG_PET))) { return false; } @@ -6258,7 +6236,7 @@ namespace charutils int ret = _sql->Query("SELECT partyid, allianceid, partyflag & %d FROM accounts_sessions s JOIN accounts_parties p ON " "s.charid = p.charid WHERE p.charid = %u", - (PARTY_SECOND | PARTY_THIRD), PChar->id); + (PARTY_SECOND | PARTY_THIRD), PChar->id); if (ret != SQL_ERROR && _sql->NumRows() != 0 && _sql->NextRow() == SQL_SUCCESS) { uint32 partyid = _sql->GetUIntData(0); @@ -6279,12 +6257,15 @@ namespace charutils // find if party exists on this server already CParty* PParty = nullptr; zoneutils::ForEachZone([partyid, &PParty](CZone* PZone) - { PZone->ForEachChar([partyid, &PParty](CCharEntity* PChar) - { + { + PZone->ForEachChar([partyid, &PParty](CCharEntity* PChar) + { if (PChar->PParty && PChar->PParty->GetPartyID() == partyid) { PParty = PChar->PParty; - } }); }); + } + }); + }); // create new party if it doesn't exist already if (!PParty) @@ -6296,9 +6277,7 @@ namespace charutils } CBattleEntity* PSyncTarget = PChar->PParty->GetSyncTarget(); - if (PSyncTarget && PChar->getZone() == PSyncTarget->getZone() && !(PChar->StatusEffectContainer->HasStatusEffect(EFFECT_LEVEL_SYNC)) && - PSyncTarget->StatusEffectContainer->HasStatusEffect(EFFECT_LEVEL_SYNC) && - PSyncTarget->StatusEffectContainer->GetStatusEffect(EFFECT_LEVEL_SYNC)->GetDuration() == 0) + if (PSyncTarget && PChar->getZone() == PSyncTarget->getZone() && !(PChar->StatusEffectContainer->HasStatusEffect(EFFECT_LEVEL_SYNC)) && PSyncTarget->StatusEffectContainer->HasStatusEffect(EFFECT_LEVEL_SYNC) && PSyncTarget->StatusEffectContainer->GetStatusEffect(EFFECT_LEVEL_SYNC)->GetDuration() == 0) { PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, 0, PSyncTarget->GetMLevel(), 540)); PChar->StatusEffectContainer->AddStatusEffect(new CStatusEffect(EFFECT_LEVEL_SYNC, EFFECT_LEVEL_SYNC, PSyncTarget->GetMLevel(), 0, 0), true); @@ -6503,7 +6482,7 @@ namespace charutils auto ip = (uint32)ipp; auto port = (uint32)(ipp >> 32); _sql->Query("UPDATE accounts_sessions SET server_addr = %u, server_port = %u WHERE charid = %u", - ip, port, PChar->id); + ip, port, PChar->id); const char* Query = "UPDATE chars " "SET " @@ -6518,8 +6497,8 @@ namespace charutils "WHERE charid = %u"; _sql->Query(Query, PChar->loc.destination, - (PChar->m_moghouseID || PChar->loc.destination == PChar->getZone()) ? PChar->loc.prevzone : PChar->getZone(), PChar->loc.p.rotation, - PChar->loc.p.x, PChar->loc.p.y, PChar->loc.p.z, PChar->m_moghouseID, PChar->loc.boundary, PChar->id); + (PChar->m_moghouseID || PChar->loc.destination == PChar->getZone()) ? PChar->loc.prevzone : PChar->getZone(), PChar->loc.p.rotation, + PChar->loc.p.x, PChar->loc.p.y, PChar->loc.p.z, PChar->m_moghouseID, PChar->loc.boundary, PChar->id); } else { @@ -6616,7 +6595,7 @@ namespace charutils return false; } - int32 GetCharVar(CCharEntity* PChar, std::string const& var) + int32 GetCharVar(CCharEntity* PChar, const std::string& var) { if (PChar == nullptr) { @@ -6626,7 +6605,7 @@ namespace charutils return PChar->getCharVar(var); } - void SetCharVar(uint32 charId, std::string const& var, int32 value, uint32 expiry /* = 0 */) + void SetCharVar(uint32 charId, const std::string& var, int32 value, uint32 expiry /* = 0 */) { if (auto player = zoneutils::GetChar(charId)) { @@ -6638,7 +6617,7 @@ namespace charutils message::send_charvar_update(charId, var, value, expiry); } - void SetCharVar(CCharEntity* PChar, std::string const& var, int32 value, uint32 expiry /* = 0 */) + void SetCharVar(CCharEntity* PChar, const std::string& var, int32 value, uint32 expiry /* = 0 */) { if (PChar == nullptr) { @@ -6648,7 +6627,7 @@ namespace charutils return PChar->setCharVar(var, value, expiry); } - int32 ClearCharVarsWithPrefix(CCharEntity* PChar, std::string const& prefix) + int32 ClearCharVarsWithPrefix(CCharEntity* PChar, const std::string& prefix) { if (PChar == nullptr) { @@ -6659,7 +6638,7 @@ namespace charutils return 0; } - int32 RemoveCharVarsWithTag(CCharEntity* PChar, std::string const& varsTag) + int32 RemoveCharVarsWithTag(CCharEntity* PChar, const std::string& varsTag) { if (PChar == nullptr) { @@ -6670,7 +6649,7 @@ namespace charutils return 0; } - void ClearCharVarFromAll(std::string const& varName, bool localOnly) + void ClearCharVarFromAll(const std::string& varName, bool localOnly) { if (!localOnly) { @@ -6688,7 +6667,7 @@ namespace charutils // clang-format on } - void IncrementCharVar(CCharEntity* PChar, std::string const& var, int32 value) + void IncrementCharVar(CCharEntity* PChar, const std::string& var, int32 value) { if (PChar == nullptr) { @@ -6702,7 +6681,7 @@ namespace charutils PChar->removeFromCharVarCache(var); } - auto FetchCharVar(uint32 charId, std::string const& varName) -> std::pair + auto FetchCharVar(uint32 charId, const std::string& varName) -> std::pair { const char* fmtQuery = "SELECT value, expiry FROM char_vars WHERE charid = %u AND varname = '%s' LIMIT 1"; @@ -6727,7 +6706,7 @@ namespace charutils return { value, expiry }; } - void PersistCharVar(uint32 charId, std::string const& var, int32 value, uint32 expiry /* = 0 */) + void PersistCharVar(uint32 charId, const std::string& var, int32 value, uint32 expiry /* = 0 */) { if (value == 0) { @@ -6996,21 +6975,21 @@ namespace charutils ")"; auto ret = _sql->Query(fmtQuery, - PChar->id, - PChar->m_charHistory.enemiesDefeated, - PChar->m_charHistory.timesKnockedOut, - PChar->m_charHistory.mhEntrances, - PChar->m_charHistory.joinedParties, - PChar->m_charHistory.joinedAlliances, - PChar->m_charHistory.spellsCast, - PChar->m_charHistory.abilitiesUsed, - PChar->m_charHistory.wsUsed, - PChar->m_charHistory.itemsUsed, - PChar->m_charHistory.chatsSent, - PChar->m_charHistory.npcInteractions, - PChar->m_charHistory.battlesFought, - PChar->m_charHistory.gmCalls, - PChar->m_charHistory.distanceTravelled); + PChar->id, + PChar->m_charHistory.enemiesDefeated, + PChar->m_charHistory.timesKnockedOut, + PChar->m_charHistory.mhEntrances, + PChar->m_charHistory.joinedParties, + PChar->m_charHistory.joinedAlliances, + PChar->m_charHistory.spellsCast, + PChar->m_charHistory.abilitiesUsed, + PChar->m_charHistory.wsUsed, + PChar->m_charHistory.itemsUsed, + PChar->m_charHistory.chatsSent, + PChar->m_charHistory.npcInteractions, + PChar->m_charHistory.battlesFought, + PChar->m_charHistory.gmCalls, + PChar->m_charHistory.distanceTravelled); if (ret == SQL_ERROR) { @@ -7136,7 +7115,7 @@ namespace charutils return spawnlist->find(entity->id) != spawnlist->end(); } - uint32 getCharIdFromName(std::string const& name) + uint32 getCharIdFromName(const std::string& name) { TracyZoneScoped; diff --git a/src/map/utils/charutils.h b/src/map/utils/charutils.h index d2b5f4bd8c8..25ad49841ac 100644 --- a/src/map/utils/charutils.h +++ b/src/map/utils/charutils.h @@ -90,7 +90,7 @@ namespace charutils void DistributeGil(CCharEntity* PChar, CMobEntity* PMob); void DistributeItem(CCharEntity* PChar, CBaseEntity* PEntity, uint16 itemid, uint16 droprate); void AddExperiencePoints(bool expFromRaise, CCharEntity* PChar, CBaseEntity* PMob, uint32 exp, EMobDifficulty mobCheck = EMobDifficulty::TooWeak, - bool isexpchain = false); + bool isexpchain = false); uint16 AddCapacityBonus(CCharEntity* PChar, uint16 capacityPoints); void AddCapacityPoints(CCharEntity* PChar, CBaseEntity* PMob, uint32 capacityPoints, int16 levelDiff = 0, bool isCapacityChain = false); @@ -120,7 +120,7 @@ namespace charutils void LoadJobChangeGear(CCharEntity* PChar); void EquipItem(CCharEntity* PChar, uint8 slotID, uint8 equipSlotID, uint8 containerID); void UnequipItem(CCharEntity* PChar, uint8 equipSlotID, - bool update = true); // call with update == false to prevent calls to UpdateHealth() - used for correct handling of stats on armor swaps + bool update = true); // call with update == false to prevent calls to UpdateHealth() - used for correct handling of stats on armor swaps bool hasSlotEquipped(CCharEntity* PChar, uint8 equipSlotID); void RemoveSub(CCharEntity* PChar); bool EquipArmor(CCharEntity* PChar, uint8 slotID, uint8 equipSlotID, uint8 containerID); @@ -243,16 +243,16 @@ namespace charutils void HomePoint(CCharEntity* PChar, bool resetHPMP); bool AddWeaponSkillPoints(CCharEntity*, SLOTTYPE, int); - int32 GetCharVar(CCharEntity* PChar, std::string const& var); - void SetCharVar(uint32 charId, std::string const& var, int32 value, uint32 expiry = 0); - void SetCharVar(CCharEntity* PChar, std::string const& var, int32 value, uint32 expiry = 0); - int32 ClearCharVarsWithPrefix(CCharEntity* PChar, std::string const& prefix); - int32 RemoveCharVarsWithTag(CCharEntity* PChar, std::string const& varsTag); - void ClearCharVarFromAll(std::string const& varName, bool localOnly = false); - void IncrementCharVar(CCharEntity* PChar, std::string const& var, int32 value); + int32 GetCharVar(CCharEntity* PChar, const std::string& var); + void SetCharVar(uint32 charId, const std::string& var, int32 value, uint32 expiry = 0); + void SetCharVar(CCharEntity* PChar, const std::string& var, int32 value, uint32 expiry = 0); + int32 ClearCharVarsWithPrefix(CCharEntity* PChar, const std::string& prefix); + int32 RemoveCharVarsWithTag(CCharEntity* PChar, const std::string& varsTag); + void ClearCharVarFromAll(const std::string& varName, bool localOnly = false); + void IncrementCharVar(CCharEntity* PChar, const std::string& var, int32 value); - auto FetchCharVar(uint32 charId, std::string const& var) -> std::pair; - void PersistCharVar(uint32 charId, std::string const& var, int32 value, uint32 expiry = 0); + auto FetchCharVar(uint32 charId, const std::string& var) -> std::pair; + void PersistCharVar(uint32 charId, const std::string& var, int32 value, uint32 expiry = 0); uint16 getWideScanRange(JOBTYPE job, uint8 level); uint16 getWideScanRange(CCharEntity* PChar); @@ -278,7 +278,7 @@ namespace charutils bool hasEntitySpawned(CCharEntity* PChar, CBaseEntity* entity); - uint32 getCharIdFromName(std::string const& name); + uint32 getCharIdFromName(const std::string& name); void forceSynthCritFail(std::string sourceFunction, CCharEntity* PChar); diff --git a/src/map/utils/fishingcontest.cpp b/src/map/utils/fishingcontest.cpp index 58e61afbc54..1111a11872b 100644 --- a/src/map/utils/fishingcontest.cpp +++ b/src/map/utils/fishingcontest.cpp @@ -302,8 +302,7 @@ namespace fishingcontest { return &FishingContestEntries[position]; } - else if (position >= FishingContestEntries.size() && - !FakeContestEntries.empty()) + else if (position >= FishingContestEntries.size() && !FakeContestEntries.empty()) { // This entire block is used to pad the fishing entries table if there are fewer than 15 entries // Used modulo as a failsafe in case entry number exceeds the number of fake entries (should never happen) @@ -353,11 +352,11 @@ namespace fishingcontest "nextstagetime = (?);"; // Stage Change Time auto ret = db::preparedStmt(Query, static_cast(CurrentFishingContest.status), - static_cast(CurrentFishingContest.criteria), - static_cast(CurrentFishingContest.measure), - CurrentFishingContest.fishId, - CurrentFishingContest.startTime, - CurrentFishingContest.changeTime); + static_cast(CurrentFishingContest.criteria), + static_cast(CurrentFishingContest.measure), + CurrentFishingContest.fishId, + CurrentFishingContest.startTime, + CurrentFishingContest.changeTime); if (!ret) { @@ -387,11 +386,11 @@ namespace fishingcontest "(?));"; // Stage Change Time auto ret = db::preparedStmt(Query, static_cast(CurrentFishingContest.status), - static_cast(CurrentFishingContest.criteria), - static_cast(CurrentFishingContest.measure), - CurrentFishingContest.fishId, - CurrentFishingContest.startTime, - CurrentFishingContest.changeTime); + static_cast(CurrentFishingContest.criteria), + static_cast(CurrentFishingContest.measure), + CurrentFishingContest.fishId, + CurrentFishingContest.startTime, + CurrentFishingContest.changeTime); if (!ret) { @@ -424,18 +423,18 @@ namespace fishingcontest "FROM chars WHERE charname = '{}';"; auto ret = db::query(fmt::format(Query, - entry->mjob, - entry->sjob, - entry->mlvl, - entry->slvl, - entry->race, - entry->allegiance, - entry->fishRank, - entry->score, - entry->submitTime, - entry->contestRank, - entry->share, - entry->name)); + entry->mjob, + entry->sjob, + entry->mlvl, + entry->slvl, + entry->race, + entry->allegiance, + entry->fishRank, + entry->score, + entry->submitTime, + entry->contestRank, + entry->share, + entry->name)); if (!ret) { diff --git a/src/map/utils/fishingcontest.h b/src/map/utils/fishingcontest.h index c3e8b7b0c24..89c691a3fa6 100644 --- a/src/map/utils/fishingcontest.h +++ b/src/map/utils/fishingcontest.h @@ -68,11 +68,7 @@ struct FishingContest bool isValid() { - return status <= FISHING_CONTEST_STATUS::CLOSED && - criteria <= FISHING_CONTEST_CRITERIA::BOTH && - measure <= FISHING_CONTEST_MEASURE::SMALLEST && - startTime > 0 && - fishId != 0; + return status <= FISHING_CONTEST_STATUS::CLOSED && criteria <= FISHING_CONTEST_CRITERIA::BOTH && measure <= FISHING_CONTEST_MEASURE::SMALLEST && startTime > 0 && fishId != 0; } }; diff --git a/src/map/utils/fishingutils.cpp b/src/map/utils/fishingutils.cpp index a06b4fcdcda..08edeb835bb 100644 --- a/src/map/utils/fishingutils.cpp +++ b/src/map/utils/fishingutils.cpp @@ -110,9 +110,9 @@ namespace fishingutils { for (auto& FishingPool : FishingPools) { - for (auto const& a : FishingPool.catchPools) + for (const auto& a : FishingPool.catchPools) { - for (auto const& s : a.second.stock) + for (const auto& s : a.second.stock) { if (s.second.quantity < s.second.maxQuantity) { @@ -128,11 +128,10 @@ namespace fishingutils void CreateFishingPools() { - const char* Query = - "SELECT fc.zoneid,fc.areaid,fg.fishid,fg.pool_size,fg.restock_rate " - "FROM fishing_group fg " - "JOIN fishing_catch fc USING(groupid)"; - int32 ret = _sql->Query(Query); + const char* Query = "SELECT fc.zoneid,fc.areaid,fg.fishid,fg.pool_size,fg.restock_rate " + "FROM fishing_group fg " + "JOIN fishing_catch fc USING(groupid)"; + int32 ret = _sql->Query(Query); if (ret != SQL_ERROR && _sql->NumRows() != 0) { @@ -890,7 +889,7 @@ namespace fishingutils // TODO: figure out how to pass mobs and items and chests here... uint8 CalculateFishSense(CCharEntity* PChar, fishresponse_t* response, uint8 fishingSkill, uint8 catchType, uint8 sizeType, - uint8 maxSkill, bool legendary, uint16 minLength, uint16 maxLength, uint8 ranking, rod_t* rod) + uint8 maxSkill, bool legendary, uint16 minLength, uint16 maxLength, uint8 ranking, rod_t* rod) { uint8 sense = FISHINGSENSETYPE_GOOD; @@ -2497,7 +2496,7 @@ namespace fishingutils response->heal = CalculateHeal(FishSelection->legendary, FishSelection->difficulty, rod); response->timelimit = CalculateHookTime(PChar, FishSelection->legendary, FishSelection->legendary_flags, FishSelection->sizeType, rod, bait); response->sense = CalculateFishSense(PChar, response, fishingSkill, (FISHINGCATCHTYPE)response->catchtype, FishSelection->sizeType, FishSelection->maxSkill, - FishSelection->legendary, FishSelection->minLength, FishSelection->maxLength, FishSelection->ranking, rod); + FishSelection->legendary, FishSelection->minLength, FishSelection->maxLength, FishSelection->ranking, rod); response->hooksense = FishSelection->sizeType == FISHINGSIZETYPE_SMALL ? FISHINGHOOKSENSETYPE_SMALL : FISHINGHOOKSENSETYPE_LARGE; if (response->catchsizeType == FISHINGSIZETYPE_LARGE) @@ -2547,7 +2546,7 @@ namespace fishingutils response->heal = CalculateHeal(ItemSelection->legendary, ItemSelection->difficulty, rod); response->timelimit = CalculateHookTime(PChar, ItemSelection->legendary, ItemSelection->legendary_flags, ItemSelection->sizeType, rod, bait); response->sense = CalculateFishSense(PChar, response, fishingSkill, (FISHINGCATCHTYPE)response->catchtype, ItemSelection->sizeType, - ItemSelection->maxSkill, false, ItemSelection->minLength, ItemSelection->maxLength, ItemSelection->ranking, rod); + ItemSelection->maxSkill, false, ItemSelection->minLength, ItemSelection->maxLength, ItemSelection->ranking, rod); response->hooksense = ItemSelection->sizeType == FISHINGSIZETYPE_SMALL ? FISHINGHOOKSENSETYPE_SMALL : FISHINGHOOKSENSETYPE_LARGE; response->special = CalculateLuckyTiming(PChar, fishingSkill, ItemSelection->maxSkill, ItemSelection->sizeType, rod, bait, false); } @@ -2576,7 +2575,7 @@ namespace fishingutils response->heal = CalculateHeal(false, MobSelection->difficulty, rod); response->timelimit = CalculateHookTime(PChar, 0, 0, response->catchsizeType, rod, bait); response->sense = CalculateFishSense(PChar, response, fishingSkill, FISHINGCATCHTYPE_MOB, FISHINGSIZETYPE_LARGE, MobSelection->level, false, - MobSelection->minLength, MobSelection->maxLength, MobSelection->ranking, rod); + MobSelection->minLength, MobSelection->maxLength, MobSelection->ranking, rod); response->hooksense = FISHINGHOOKSENSETYPE_LARGE; response->special = CalculateLuckyTiming(PChar, fishingSkill, MobSelection->level, FISHINGSIZETYPE_LARGE, rod, bait, false); fishmob_modifiers_t modifiers = CalculateMobModifiers(MobSelection); @@ -3253,7 +3252,8 @@ namespace fishingutils while (_sql->NextRow() == SQL_SUCCESS) { FishingBaitAffinities[(uint16)_sql->GetUIntData(0)] - [_sql->GetUIntData(1)] = (uint8)_sql->GetUIntData(2); + [_sql->GetUIntData(1)] + = (uint8)_sql->GetUIntData(2); } } } @@ -3273,7 +3273,8 @@ namespace fishingutils while (_sql->NextRow() == SQL_SUCCESS) { FishingGroups[(uint16)_sql->GetUIntData(0)] - [_sql->GetUIntData(1)] = (uint16)_sql->GetUIntData(2); + [_sql->GetUIntData(1)] + = (uint16)_sql->GetUIntData(2); } } } @@ -3293,7 +3294,8 @@ namespace fishingutils while (_sql->NextRow() == SQL_SUCCESS) { FishingCatchLists[(uint16)_sql->GetUIntData(0)] - [(uint8)_sql->GetUIntData(1)] = (uint16)_sql->GetUIntData(2); + [(uint8)_sql->GetUIntData(1)] + = (uint16)_sql->GetUIntData(2); } } } diff --git a/src/map/utils/fishingutils.h b/src/map/utils/fishingutils.h index 13628a3224b..c6dcd742175 100644 --- a/src/map/utils/fishingutils.h +++ b/src/map/utils/fishingutils.h @@ -943,18 +943,18 @@ namespace fishingutils uint16 CalculateAttack(bool legendary, uint8 difficulty, rod_t* rod); uint16 CalculateHeal(bool legendary, uint8 difficulty, rod_t* rod); uint8 CalculateRegen(uint8 fishingSkill, rod_t* rod, FISHINGCATCHTYPE catchType, - uint8 sizeType, uint8 catchSkill, bool legendaryCatch, bool NM); + uint8 sizeType, uint8 catchSkill, bool legendaryCatch, bool NM); uint8 CalculateHookTime(CCharEntity* PChar, bool legendary, - uint32 legendary_flags, uint8 sizeType, rod_t* rod, bait_t* bait); + uint32 legendary_flags, uint8 sizeType, rod_t* rod, bait_t* bait); uint8 CalculateLuckyTiming(CCharEntity* PChar, uint8 fishingSkill, - uint8 catchSkill, uint8 sizeType, rod_t* rod, bait_t* bait, bool legendary); + uint8 catchSkill, uint8 sizeType, rod_t* rod, bait_t* bait, bool legendary); uint16 CalculateHookChance(uint8 fishingSkill, fish_t* fish, bait_t* bait, rod_t* rod); uint8 CalculateDelay(CCharEntity* PChar, uint8 baseDelay, uint8 sizeType, rod_t* rod, uint8 count); uint8 CalculateMovement(CCharEntity* PChar, uint8 baseMove, uint8 sizeType, rod_t* rod, uint8 count); uint8 CalculateFishSense(CCharEntity* PChar, fishresponse_t* response, - uint8 fishingSkill, uint8 catchType, uint8 sizeType, - uint8 maxSkill, bool legendary, uint16 minLength, - uint16 maxLength, uint8 ranking, rod_t* rod); + uint8 fishingSkill, uint8 catchType, uint8 sizeType, + uint8 maxSkill, bool legendary, uint16 minLength, + uint16 maxLength, uint8 ranking, rod_t* rod); uint16 CalculateCriticalBite(uint8 fishingSkill, uint8 fishSkill, rod_t* rod); big_fish_stats_t CalculateBigFishStats(uint16 minLength, uint16 maxLength); fishmob_modifiers_t CalculateMobModifiers(fishmob_t* mob); diff --git a/src/map/utils/gardenutils.cpp b/src/map/utils/gardenutils.cpp index 998e54ab12f..0ed31bac362 100644 --- a/src/map/utils/gardenutils.cpp +++ b/src/map/utils/gardenutils.cpp @@ -102,8 +102,7 @@ namespace gardenutils uint32 daysSinceStageChange = (vanatime - PPotItem->getStageTimestamp()) / VANADAY_SECONDS; uint8 wiltTime = VANADAYS_TO_WILT + PChar->getMod(Mod::GARDENING_WILT_BONUS); bool wasExamined = PPotItem->wasExamined(); - if ((!wasExamined && (stageDuration > wiltTime || (stageDuration + daysSinceStageChange > wiltTime))) || - daysSinceStageChange > VANADAYS_TO_GUARANTEE_WILT + wiltTime) + if ((!wasExamined && (stageDuration > wiltTime || (stageDuration + daysSinceStageChange > wiltTime))) || daysSinceStageChange > VANADAYS_TO_GUARANTEE_WILT + wiltTime) { PPotItem->setStage(FLOWERPOT_STAGE_WILTED); PPotItem->setStageTimestamp(vanatime + VANATIME_FOR_WILT_STAGE); diff --git a/src/map/utils/guildutils.cpp b/src/map/utils/guildutils.cpp index d0fb7dce576..f7fbab69ab7 100644 --- a/src/map/utils/guildutils.cpp +++ b/src/map/utils/guildutils.cpp @@ -101,8 +101,7 @@ namespace guildutils PItem->setInitialQuantity(_sql->GetIntData(5)); PItem->setQuantity(PItem->IsDailyIncrease() ? PItem->getInitialQuantity() : 0); - PItem->setBasePrice((uint32)(PItem->getMinPrice() + ((float)(PItem->getStackSize() - PItem->getQuantity()) / PItem->getStackSize()) * - (PItem->getMaxPrice() - PItem->getMinPrice()))); + PItem->setBasePrice((uint32)(PItem->getMinPrice() + ((float)(PItem->getStackSize() - PItem->getQuantity()) / PItem->getStackSize()) * (PItem->getMaxPrice() - PItem->getMinPrice()))); PGuildShop->InsertItem(PItem); } @@ -138,8 +137,7 @@ namespace guildutils if (PItem != nullptr) { - PItem->setBasePrice((uint32)(PItem->getMinPrice() + ((float)(PItem->getStackSize() - PItem->getQuantity()) / PItem->getStackSize()) * - (PItem->getMaxPrice() - PItem->getMinPrice()))); + PItem->setBasePrice((uint32)(PItem->getMinPrice() + ((float)(PItem->getStackSize() - PItem->getQuantity()) / PItem->getStackSize()) * (PItem->getMaxPrice() - PItem->getMinPrice()))); if (PItem->IsDailyIncrease()) { diff --git a/src/map/utils/instanceutils.cpp b/src/map/utils/instanceutils.cpp index 8646cee19d6..f98948b8d0a 100644 --- a/src/map/utils/instanceutils.cpp +++ b/src/map/utils/instanceutils.cpp @@ -34,25 +34,24 @@ namespace instanceutils void LoadInstanceList() { - const char query[] = - "SELECT " - "instanceid," // 0 - "instance_name," // 1 - "instance_zone," // 2 - "entrance_zone," // 3 - "time_limit," // 4 - "start_x," // 5 - "start_y," // 6 - "start_z," // 7 - "start_rot," // 8 - "instance_list.music_day," // 9 - "instance_list.music_night," // 10 - "instance_list.battlesolo," // 11 - "instance_list.battlemulti," // 12 - "zone_settings.name " // 13 - "FROM instance_list INNER JOIN zone_settings " - "ON instance_zone = zone_settings.zoneid " - "WHERE IF(%d <> 0, '%s' = zoneip AND %d = zoneport, TRUE)"; + const char query[] = "SELECT " + "instanceid," // 0 + "instance_name," // 1 + "instance_zone," // 2 + "entrance_zone," // 3 + "time_limit," // 4 + "start_x," // 5 + "start_y," // 6 + "start_z," // 7 + "start_rot," // 8 + "instance_list.music_day," // 9 + "instance_list.music_night," // 10 + "instance_list.battlesolo," // 11 + "instance_list.battlemulti," // 12 + "zone_settings.name " // 13 + "FROM instance_list INNER JOIN zone_settings " + "ON instance_zone = zone_settings.zoneid " + "WHERE IF(%d <> 0, '%s' = zoneip AND %d = zoneport, TRUE)"; char address[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &map_ip, address, INET_ADDRSTRLEN); diff --git a/src/map/utils/mobutils.cpp b/src/map/utils/mobutils.cpp index 388d3bb8d0b..5020845b760 100644 --- a/src/map/utils/mobutils.cpp +++ b/src/map/utils/mobutils.cpp @@ -293,100 +293,7 @@ namespace mobutils bool CheckSubJobZone(CMobEntity* PMob) { auto zoneId = PMob->getZone(); - if (zoneId != 0 && (zoneId == ZONE_WEST_RONFAURE || - zoneId == ZONE_EAST_RONFAURE || - zoneId == ZONE_LA_THEINE_PLATEAU || - zoneId == ZONE_VALKURM_DUNES || - zoneId == ZONE_JUGNER_FOREST || - zoneId == ZONE_BATALLIA_DOWNS || - zoneId == ZONE_NORTH_GUSTABERG || - zoneId == ZONE_SOUTH_GUSTABERG || - zoneId == ZONE_KONSCHTAT_HIGHLANDS || - zoneId == ZONE_PASHHOW_MARSHLANDS || - zoneId == ZONE_ROLANBERRY_FIELDS || - zoneId == ZONE_BEAUCEDINE_GLACIER || - zoneId == ZONE_XARCABARD || - zoneId == ZONE_CAPE_TERIGGAN || - zoneId == ZONE_EASTERN_ALTEPA_DESERT || - zoneId == ZONE_WEST_SARUTABARUTA || - zoneId == ZONE_EAST_SARUTABARUTA || - zoneId == ZONE_TAHRONGI_CANYON || - zoneId == ZONE_BUBURIMU_PENINSULA || - zoneId == ZONE_MERIPHATAUD_MOUNTAINS || - zoneId == ZONE_SAUROMUGUE_CHAMPAIGN || - zoneId == ZONE_THE_SANCTUARY_OF_ZITAH || - zoneId == ZONE_ROMAEVE || - zoneId == ZONE_YUHTUNGA_JUNGLE || - zoneId == ZONE_YHOATOR_JUNGLE || - zoneId == ZONE_WESTERN_ALTEPA_DESERT || - zoneId == ZONE_QUFIM_ISLAND || - zoneId == ZONE_BEHEMOTHS_DOMINION || - zoneId == ZONE_VALLEY_OF_SORROWS || - zoneId == ZONE_HORLAIS_PEAK || - zoneId == ZONE_GHELSBA_OUTPOST || - zoneId == ZONE_FORT_GHELSBA || - zoneId == ZONE_YUGHOTT_GROTTO || - zoneId == ZONE_PALBOROUGH_MINES || - zoneId == ZONE_WAUGHROON_SHRINE || - zoneId == ZONE_GIDDEUS || - zoneId == ZONE_BALGAS_DAIS || - zoneId == ZONE_BEADEAUX || - zoneId == ZONE_QULUN_DOME || - zoneId == ZONE_DAVOI || - zoneId == ZONE_MONASTIC_CAVERN || - zoneId == ZONE_CASTLE_OZTROJA || - zoneId == ZONE_ALTAR_ROOM || - zoneId == ZONE_THE_BOYAHDA_TREE || - zoneId == ZONE_DRAGONS_AERY || - zoneId == ZONE_MIDDLE_DELKFUTTS_TOWER || - zoneId == ZONE_UPPER_DELKFUTTS_TOWER || - zoneId == ZONE_TEMPLE_OF_UGGALEPIH || - zoneId == ZONE_DEN_OF_RANCOR || - zoneId == ZONE_CASTLE_ZVAHL_BAILEYS || - zoneId == ZONE_CASTLE_ZVAHL_KEEP || - zoneId == ZONE_SACRIFICIAL_CHAMBER || - zoneId == ZONE_THRONE_ROOM || - zoneId == ZONE_RANGUEMONT_PASS || - zoneId == ZONE_BOSTAUNIEUX_OUBLIETTE || - zoneId == ZONE_CHAMBER_OF_ORACLES || - zoneId == ZONE_TORAIMARAI_CANAL || - zoneId == ZONE_FULL_MOON_FOUNTAIN || - zoneId == ZONE_ZERUHN_MINES || - zoneId == ZONE_KORROLOKA_TUNNEL || - zoneId == ZONE_KUFTAL_TUNNEL || - zoneId == ZONE_SEA_SERPENT_GROTTO || - zoneId == ZONE_VELUGANNON_PALACE || - zoneId == ZONE_THE_SHRINE_OF_RUAVITAU || - zoneId == ZONE_STELLAR_FULCRUM || - zoneId == ZONE_LALOFF_AMPHITHEATER || - zoneId == ZONE_THE_CELESTIAL_NEXUS || - zoneId == ZONE_LOWER_DELKFUTTS_TOWER || - zoneId == ZONE_KING_RANPERRES_TOMB || - zoneId == ZONE_DANGRUF_WADI || - zoneId == ZONE_INNER_HORUTOTO_RUINS || - zoneId == ZONE_ORDELLES_CAVES || - zoneId == ZONE_OUTER_HORUTOTO_RUINS || - zoneId == ZONE_THE_ELDIEME_NECROPOLIS || - zoneId == ZONE_GUSGEN_MINES || - zoneId == ZONE_CRAWLERS_NEST || - zoneId == ZONE_MAZE_OF_SHAKHRAMI || - zoneId == ZONE_GARLAIGE_CITADEL || - zoneId == ZONE_CLOISTER_OF_GALES || - zoneId == ZONE_CLOISTER_OF_STORMS || - zoneId == ZONE_CLOISTER_OF_FROST || - zoneId == ZONE_FEIYIN || - zoneId == ZONE_IFRITS_CAULDRON || - zoneId == ZONE_QUBIA_ARENA || - zoneId == ZONE_CLOISTER_OF_FLAMES || - zoneId == ZONE_QUICKSAND_CAVES || - zoneId == ZONE_CLOISTER_OF_TREMORS || - zoneId == ZONE_CLOISTER_OF_TIDES || - zoneId == ZONE_GUSTAV_TUNNEL || - zoneId == ZONE_LABYRINTH_OF_ONZOZO || - zoneId == ZONE_SHIP_BOUND_FOR_SELBINA || - zoneId == ZONE_SHIP_BOUND_FOR_MHAURA || - zoneId == ZONE_SHIP_BOUND_FOR_SELBINA_PIRATES || - zoneId == ZONE_SHIP_BOUND_FOR_MHAURA_PIRATES)) + if (zoneId != 0 && (zoneId == ZONE_WEST_RONFAURE || zoneId == ZONE_EAST_RONFAURE || zoneId == ZONE_LA_THEINE_PLATEAU || zoneId == ZONE_VALKURM_DUNES || zoneId == ZONE_JUGNER_FOREST || zoneId == ZONE_BATALLIA_DOWNS || zoneId == ZONE_NORTH_GUSTABERG || zoneId == ZONE_SOUTH_GUSTABERG || zoneId == ZONE_KONSCHTAT_HIGHLANDS || zoneId == ZONE_PASHHOW_MARSHLANDS || zoneId == ZONE_ROLANBERRY_FIELDS || zoneId == ZONE_BEAUCEDINE_GLACIER || zoneId == ZONE_XARCABARD || zoneId == ZONE_CAPE_TERIGGAN || zoneId == ZONE_EASTERN_ALTEPA_DESERT || zoneId == ZONE_WEST_SARUTABARUTA || zoneId == ZONE_EAST_SARUTABARUTA || zoneId == ZONE_TAHRONGI_CANYON || zoneId == ZONE_BUBURIMU_PENINSULA || zoneId == ZONE_MERIPHATAUD_MOUNTAINS || zoneId == ZONE_SAUROMUGUE_CHAMPAIGN || zoneId == ZONE_THE_SANCTUARY_OF_ZITAH || zoneId == ZONE_ROMAEVE || zoneId == ZONE_YUHTUNGA_JUNGLE || zoneId == ZONE_YHOATOR_JUNGLE || zoneId == ZONE_WESTERN_ALTEPA_DESERT || zoneId == ZONE_QUFIM_ISLAND || zoneId == ZONE_BEHEMOTHS_DOMINION || zoneId == ZONE_VALLEY_OF_SORROWS || zoneId == ZONE_HORLAIS_PEAK || zoneId == ZONE_GHELSBA_OUTPOST || zoneId == ZONE_FORT_GHELSBA || zoneId == ZONE_YUGHOTT_GROTTO || zoneId == ZONE_PALBOROUGH_MINES || zoneId == ZONE_WAUGHROON_SHRINE || zoneId == ZONE_GIDDEUS || zoneId == ZONE_BALGAS_DAIS || zoneId == ZONE_BEADEAUX || zoneId == ZONE_QULUN_DOME || zoneId == ZONE_DAVOI || zoneId == ZONE_MONASTIC_CAVERN || zoneId == ZONE_CASTLE_OZTROJA || zoneId == ZONE_ALTAR_ROOM || zoneId == ZONE_THE_BOYAHDA_TREE || zoneId == ZONE_DRAGONS_AERY || zoneId == ZONE_MIDDLE_DELKFUTTS_TOWER || zoneId == ZONE_UPPER_DELKFUTTS_TOWER || zoneId == ZONE_TEMPLE_OF_UGGALEPIH || zoneId == ZONE_DEN_OF_RANCOR || zoneId == ZONE_CASTLE_ZVAHL_BAILEYS || zoneId == ZONE_CASTLE_ZVAHL_KEEP || zoneId == ZONE_SACRIFICIAL_CHAMBER || zoneId == ZONE_THRONE_ROOM || zoneId == ZONE_RANGUEMONT_PASS || zoneId == ZONE_BOSTAUNIEUX_OUBLIETTE || zoneId == ZONE_CHAMBER_OF_ORACLES || zoneId == ZONE_TORAIMARAI_CANAL || zoneId == ZONE_FULL_MOON_FOUNTAIN || zoneId == ZONE_ZERUHN_MINES || zoneId == ZONE_KORROLOKA_TUNNEL || zoneId == ZONE_KUFTAL_TUNNEL || zoneId == ZONE_SEA_SERPENT_GROTTO || zoneId == ZONE_VELUGANNON_PALACE || zoneId == ZONE_THE_SHRINE_OF_RUAVITAU || zoneId == ZONE_STELLAR_FULCRUM || zoneId == ZONE_LALOFF_AMPHITHEATER || zoneId == ZONE_THE_CELESTIAL_NEXUS || zoneId == ZONE_LOWER_DELKFUTTS_TOWER || zoneId == ZONE_KING_RANPERRES_TOMB || zoneId == ZONE_DANGRUF_WADI || zoneId == ZONE_INNER_HORUTOTO_RUINS || zoneId == ZONE_ORDELLES_CAVES || zoneId == ZONE_OUTER_HORUTOTO_RUINS || zoneId == ZONE_THE_ELDIEME_NECROPOLIS || zoneId == ZONE_GUSGEN_MINES || zoneId == ZONE_CRAWLERS_NEST || zoneId == ZONE_MAZE_OF_SHAKHRAMI || zoneId == ZONE_GARLAIGE_CITADEL || zoneId == ZONE_CLOISTER_OF_GALES || zoneId == ZONE_CLOISTER_OF_STORMS || zoneId == ZONE_CLOISTER_OF_FROST || zoneId == ZONE_FEIYIN || zoneId == ZONE_IFRITS_CAULDRON || zoneId == ZONE_QUBIA_ARENA || zoneId == ZONE_CLOISTER_OF_FLAMES || zoneId == ZONE_QUICKSAND_CAVES || zoneId == ZONE_CLOISTER_OF_TREMORS || zoneId == ZONE_CLOISTER_OF_TIDES || zoneId == ZONE_GUSTAV_TUNNEL || zoneId == ZONE_LABYRINTH_OF_ONZOZO || zoneId == ZONE_SHIP_BOUND_FOR_SELBINA || zoneId == ZONE_SHIP_BOUND_FOR_MHAURA || zoneId == ZONE_SHIP_BOUND_FOR_SELBINA_PIRATES || zoneId == ZONE_SHIP_BOUND_FOR_MHAURA_PIRATES)) { return true; } @@ -1185,7 +1092,7 @@ namespace mobutils PMob->defaultMobMod(MOBMOD_SKILL_LIST, PMob->m_MobSkillList); PMob->defaultMobMod(MOBMOD_LINK_RADIUS, 10); PMob->defaultMobMod(MOBMOD_TP_USE_CHANCE, - 92); // 92 = 0.92% chance per 400ms tick (50% chance by 30 seconds) while mob HPP>25 and mob TP >=1000 but <3000 + 92); // 92 = 0.92% chance per 400ms tick (50% chance by 30 seconds) while mob HPP>25 and mob TP >=1000 but <3000 PMob->defaultMobMod(MOBMOD_SIGHT_RANGE, (int16)CMobEntity::sight_range); PMob->defaultMobMod(MOBMOD_SOUND_RANGE, (int16)CMobEntity::sound_range); PMob->defaultMobMod(MOBMOD_MAGIC_RANGE, (int16)CMobEntity::magic_range); diff --git a/src/map/utils/moduleutils.cpp b/src/map/utils/moduleutils.cpp index 6ea6722654e..086532d75cc 100644 --- a/src/map/utils/moduleutils.cpp +++ b/src/map/utils/moduleutils.cpp @@ -158,11 +158,11 @@ namespace moduleutils // Expand out folders std::vector expandedList = list; - for (auto const& entry : list) + for (const auto& entry : list) { if (std::filesystem::is_directory(entry)) { - for (auto const& innerEntry : sorted_directory_iterator(entry)) + for (const auto& innerEntry : sorted_directory_iterator(entry)) { auto path = innerEntry.relative_path(); expandedList.emplace_back(path.generic_string()); @@ -171,14 +171,12 @@ namespace moduleutils } // Load each module file that isn't the helpers.lua file or a directory - for (auto const& entry : expandedList) + for (const auto& entry : expandedList) { auto path = std::filesystem::path(entry).relative_path(); bool isHelpersFile = path.filename() == "module_utils.lua"; - if (!isHelpersFile && - !std::filesystem::is_directory(path) && - path.extension() == ".lua") + if (!isHelpersFile && !std::filesystem::is_directory(path) && path.extension() == ".lua") { std::string filename = path.filename().generic_string(); std::string relPath = path.relative_path().generic_string(); @@ -236,8 +234,8 @@ namespace moduleutils auto currentPort = map_port == 0 ? settings::get("network.MAP_PORT") : map_port; auto ret = _sql->Query(fmt::format("SELECT `name`, zoneport FROM zone_settings WHERE `name` = '{}' AND zoneport = {}", - zoneName, currentPort) - .c_str()); + zoneName, currentPort) + .c_str()); if (ret != SQL_ERROR && _sql->NumRows() == 0) { DebugModules(fmt::format("{} does not appear to exist on this process.", zoneName)); diff --git a/src/map/utils/moduleutils.h b/src/map/utils/moduleutils.h index 3214c0af423..0a989b0aa17 100644 --- a/src/map/utils/moduleutils.h +++ b/src/map/utils/moduleutils.h @@ -52,11 +52,11 @@ class CPPModule virtual void OnInit() = 0; // Optional - virtual void OnZoneTick(CZone* PZone){}; - virtual void OnTimeServerTick(){}; - virtual void OnCharZoneIn(CCharEntity* PChar){}; - virtual void OnCharZoneOut(CCharEntity* PChar){}; - virtual void OnPushPacket(CCharEntity* PChar, CBasicPacket* packet){}; + virtual void OnZoneTick(CZone* PZone) {}; + virtual void OnTimeServerTick() {}; + virtual void OnCharZoneIn(CCharEntity* PChar) {}; + virtual void OnCharZoneOut(CCharEntity* PChar) {}; + virtual void OnPushPacket(CCharEntity* PChar, CBasicPacket* packet) {}; template static T* Register() diff --git a/src/map/utils/petutils.cpp b/src/map/utils/petutils.cpp index ce65856402d..9b34337ec92 100644 --- a/src/map/utils/petutils.cpp +++ b/src/map/utils/petutils.cpp @@ -460,18 +460,14 @@ namespace petutils grade = 4; - raceStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * mainLevelUpTo60) + - (grade::GetHPScale(grade, scaleOver30Column) * mainLevelOver30) + (grade::GetHPScale(grade, scaleOver60Column) * mainLevelOver60To75) + - (grade::GetHPScale(grade, scaleOver75Column) * mainLevelOver75); + raceStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * mainLevelUpTo60) + (grade::GetHPScale(grade, scaleOver30Column) * mainLevelOver30) + (grade::GetHPScale(grade, scaleOver60Column) * mainLevelOver60To75) + (grade::GetHPScale(grade, scaleOver75Column) * mainLevelOver75); // raceStat = (int32)(statScale[grade][baseValueColumn] + statScale[grade][scaleTo60Column] * (mlvl - 1)); // Calculation by main job grade = grade::GetJobGrade(mjob, 0); - jobStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * mainLevelUpTo60) + - (grade::GetHPScale(grade, scaleOver30Column) * mainLevelOver30) + (grade::GetHPScale(grade, scaleOver60Column) * mainLevelOver60To75) + - (grade::GetHPScale(grade, scaleOver75Column) * mainLevelOver75); + jobStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * mainLevelUpTo60) + (grade::GetHPScale(grade, scaleOver30Column) * mainLevelOver30) + (grade::GetHPScale(grade, scaleOver60Column) * mainLevelOver60To75) + (grade::GetHPScale(grade, scaleOver75Column) * mainLevelOver75); // Calculate Bonus HP bonusStat = (mainLevelOver10 + mainLevelOver50andUnder60) * 2; @@ -490,23 +486,20 @@ namespace petutils if (!(grade::GetJobGrade(mjob, 1) == 0 && grade::GetJobGrade(sjob, 1) == 0)) { // calculate normal racial bonus - raceStat = grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * mainLevelUpTo60 + - grade::GetMPScale(grade, scaleOver60) * mainLevelOver60; + raceStat = grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * mainLevelUpTo60 + grade::GetMPScale(grade, scaleOver60) * mainLevelOver60; } // For the main profession grade = grade::GetJobGrade(mjob, 1); if (grade > 0) { - jobStat = grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * mainLevelUpTo60 + - grade::GetMPScale(grade, scaleOver60) * mainLevelOver60; + jobStat = grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * mainLevelUpTo60 + grade::GetMPScale(grade, scaleOver60) * mainLevelOver60; } grade = grade::GetJobGrade(sjob, 1); if (grade > 0) { - sJobStat = grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * mainLevelUpTo60 + - grade::GetMPScale(grade, scaleOver60) * mainLevelOver60; + sJobStat = grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * mainLevelUpTo60 + grade::GetMPScale(grade, scaleOver60) * mainLevelOver60; } PPet->health.maxmp = (int32)((raceStat + jobStat + sJobStat) * petStats->MPscale); @@ -631,18 +624,14 @@ namespace petutils grade = grade::GetRaceGrades(race, 0); - raceStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * mainLevelUpTo60) + - (grade::GetHPScale(grade, scaleOver30Column) * mainLevelOver30) + (grade::GetHPScale(grade, scaleOver60Column) * mainLevelOver60To75) + - (grade::GetHPScale(grade, scaleOver75Column) * mainLevelOver75); + raceStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * mainLevelUpTo60) + (grade::GetHPScale(grade, scaleOver30Column) * mainLevelOver30) + (grade::GetHPScale(grade, scaleOver60Column) * mainLevelOver60To75) + (grade::GetHPScale(grade, scaleOver75Column) * mainLevelOver75); // raceStat = (int32)(statScale[grade][baseValueColumn] + statScale[grade][scaleTo60Column] * (mlvl - 1)); // Bonus HP calculation grade = grade::GetJobGrade(mjob, 0); - jobStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * mainLevelUpTo60) + - (grade::GetHPScale(grade, scaleOver30Column) * mainLevelOver30) + (grade::GetHPScale(grade, scaleOver60Column) * mainLevelOver60To75) + - (grade::GetHPScale(grade, scaleOver75Column) * mainLevelOver75); + jobStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * mainLevelUpTo60) + (grade::GetHPScale(grade, scaleOver30Column) * mainLevelOver30) + (grade::GetHPScale(grade, scaleOver60Column) * mainLevelOver60To75) + (grade::GetHPScale(grade, scaleOver75Column) * mainLevelOver75); // Bonus HP calculation bonusStat = (mainLevelOver10 + mainLevelOver50andUnder60) * 2; @@ -662,16 +651,14 @@ namespace petutils // If the main job does not have an MP rating, calculate the racial bonus based on the level of the subjob's level (assuming it has an MP rating) if (grade::GetJobGrade(mjob, 1) != 0) { - raceStat = grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * mainLevelUpTo60 + - grade::GetMPScale(grade, scaleOver60) * mainLevelOver60; + raceStat = grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * mainLevelUpTo60 + grade::GetMPScale(grade, scaleOver60) * mainLevelOver60; } // For mainjob grade = grade::GetJobGrade(mjob, 1); if (grade > 0) { - jobStat = grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * mainLevelUpTo60 + - grade::GetMPScale(grade, scaleOver60) * mainLevelOver60; + jobStat = grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * mainLevelUpTo60 + grade::GetMPScale(grade, scaleOver60) * mainLevelOver60; } PPet->health.maxmp = (int16)(raceStat + jobStat + sJobStat); @@ -1111,8 +1098,7 @@ namespace petutils return; } - if (PMaster->objtype == TYPE_PC && - (PetID == PETID_HARLEQUINFRAME || PetID == PETID_VALOREDGEFRAME || PetID == PETID_SHARPSHOTFRAME || PetID == PETID_STORMWAKERFRAME)) + if (PMaster->objtype == TYPE_PC && (PetID == PETID_HARLEQUINFRAME || PetID == PETID_VALOREDGEFRAME || PetID == PETID_SHARPSHOTFRAME || PetID == PETID_STORMWAKERFRAME)) { puppetutils::LoadAutomaton(static_cast(PMaster)); PMaster->PPet = static_cast(PMaster)->PAutomaton; diff --git a/src/map/utils/puppetutils.cpp b/src/map/utils/puppetutils.cpp index f6e33975cea..92f54f59d19 100644 --- a/src/map/utils/puppetutils.cpp +++ b/src/map/utils/puppetutils.cpp @@ -94,10 +94,7 @@ namespace puppetutils // If any of this happens then the Automaton failed to load properly and should just reset (Should only occur with older characters or if DB is // missing) - if (tempEquip.Head < HEAD_HARLEQUIN || - tempEquip.Head > HEAD_SPIRITREAVER || - tempEquip.Frame < FRAME_HARLEQUIN || - tempEquip.Frame > FRAME_STORMWAKER) + if (tempEquip.Head < HEAD_HARLEQUIN || tempEquip.Head > HEAD_SPIRITREAVER || tempEquip.Frame < FRAME_HARLEQUIN || tempEquip.Frame > FRAME_STORMWAKER) { PChar->PAutomaton->setHead(HEAD_HARLEQUIN); tempEquip.Head = HEAD_HARLEQUIN; @@ -592,7 +589,7 @@ namespace puppetutils { default: // case FRAME_HARLEQUIN: ShowWarning("puppetutils::LoadAutomatonStats Invalid frame detected for '%s', used Harlequin instead! (%u)", - PChar->getName(), (uint16)PChar->PAutomaton->getFrame()); + PChar->getName(), (uint16)PChar->PAutomaton->getFrame()); case FRAME_HARLEQUIN: petutils::LoadPet(PChar, PETID_HARLEQUINFRAME, false); break; diff --git a/src/map/utils/serverutils.cpp b/src/map/utils/serverutils.cpp index 95d732860c0..aac9239468b 100644 --- a/src/map/utils/serverutils.cpp +++ b/src/map/utils/serverutils.cpp @@ -36,7 +36,7 @@ namespace serverutils std::unordered_map> serverVarCache; std::unordered_set serverVarChanges; - uint32 GetServerVar(std::string const& name) + uint32 GetServerVar(const std::string& name) { int32 ret = _sql->Query("SELECT value, expiry FROM server_variables WHERE name = '%s' LIMIT 1", name); @@ -60,18 +60,18 @@ namespace serverutils return value; } - void SetServerVar(std::string const& name, int32 value, uint32 expiry /* = 0 */) + void SetServerVar(const std::string& name, int32 value, uint32 expiry /* = 0 */) { PersistServerVar(name, value, expiry); } - void SetVolatileServerVar(std::string const& name, int32 value, uint32 expiry /* = 0 */) + void SetVolatileServerVar(const std::string& name, int32 value, uint32 expiry /* = 0 */) { serverVarCache[name] = { value, expiry }; serverVarChanges.insert(name); } - int32 GetVolatileServerVar(std::string const& name) + int32 GetVolatileServerVar(const std::string& name) { if (auto var = serverVarCache.find(name); var != serverVarCache.end()) { @@ -121,7 +121,7 @@ namespace serverutils return 0; } - void PersistServerVar(std::string const& name, int32 value, uint32 expiry /* = 0 */) + void PersistServerVar(const std::string& name, int32 value, uint32 expiry /* = 0 */) { int32 tries = 0; int32 verify = INT_MIN; diff --git a/src/map/utils/serverutils.h b/src/map/utils/serverutils.h index 6913b2bbae2..a6030482f5f 100644 --- a/src/map/utils/serverutils.h +++ b/src/map/utils/serverutils.h @@ -30,12 +30,12 @@ namespace serverutils { - uint32 GetServerVar(std::string const& var); - void SetServerVar(std::string const& var, int32 value, uint32 expiry = 0); - void PersistServerVar(std::string const& var, int32 value, uint32 expiry = 0); + uint32 GetServerVar(const std::string& var); + void SetServerVar(const std::string& var, int32 value, uint32 expiry = 0); + void PersistServerVar(const std::string& var, int32 value, uint32 expiry = 0); - int32 GetVolatileServerVar(std::string const& var); - void SetVolatileServerVar(std::string const& var, int32 value, uint32 expiry = 0); + int32 GetVolatileServerVar(const std::string& var); + void SetVolatileServerVar(const std::string& var, int32 value, uint32 expiry = 0); int32 PersistVolatileServerVars(time_point tick, CTaskMgr::CTask* PTask); } // namespace serverutils diff --git a/src/map/utils/synergyutils.cpp b/src/map/utils/synergyutils.cpp index 28a0fe79199..9fd9e527161 100644 --- a/src/map/utils/synergyutils.cpp +++ b/src/map/utils/synergyutils.cpp @@ -113,14 +113,7 @@ namespace synergyutils // TODO: Use a map instead of a vector for faster lookups for (const auto& recipe : synergyRecipes) { - if (recipe.ingredient1 == ingredient1 && - recipe.ingredient2 == ingredient2 && - recipe.ingredient3 == ingredient3 && - recipe.ingredient4 == ingredient4 && - recipe.ingredient5 == ingredient5 && - recipe.ingredient6 == ingredient6 && - recipe.ingredient7 == ingredient7 && - recipe.ingredient8 == ingredient8) + if (recipe.ingredient1 == ingredient1 && recipe.ingredient2 == ingredient2 && recipe.ingredient3 == ingredient3 && recipe.ingredient4 == ingredient4 && recipe.ingredient5 == ingredient5 && recipe.ingredient6 == ingredient6 && recipe.ingredient7 == ingredient7 && recipe.ingredient8 == ingredient8) { return recipe; } diff --git a/src/map/utils/synthutils.cpp b/src/map/utils/synthutils.cpp index 5097abe1fa5..f27e6bdb485 100644 --- a/src/map/utils/synthutils.cpp +++ b/src/map/utils/synthutils.cpp @@ -81,9 +81,9 @@ namespace synthutils LIMIT 1"; int32 ret = _sql->Query(fmtQuery, PChar->CraftContainer->getItemID(0), PChar->CraftContainer->getItemID(0), - PChar->CraftContainer->getItemID(1), PChar->CraftContainer->getItemID(2), PChar->CraftContainer->getItemID(3), - PChar->CraftContainer->getItemID(4), PChar->CraftContainer->getItemID(5), PChar->CraftContainer->getItemID(6), - PChar->CraftContainer->getItemID(7), PChar->CraftContainer->getItemID(8)); + PChar->CraftContainer->getItemID(1), PChar->CraftContainer->getItemID(2), PChar->CraftContainer->getItemID(3), + PChar->CraftContainer->getItemID(4), PChar->CraftContainer->getItemID(5), PChar->CraftContainer->getItemID(6), + PChar->CraftContainer->getItemID(7), PChar->CraftContainer->getItemID(8)); if (ret != SQL_ERROR && _sql->NumRows() != 0 && _sql->NextRow() == SQL_SUCCESS) { @@ -766,10 +766,7 @@ namespace synthutils // Push "Synthesis failed" messages. uint16 currentZone = PChar->loc.zone->GetID(); - if (currentZone && - currentZone != ZONE_MONORAIL_PRE_RELEASE && - currentZone != ZONE_49 && - currentZone < MAX_ZONEID) + if (currentZone && currentZone != ZONE_MONORAIL_PRE_RELEASE && currentZone != ZONE_49 && currentZone < MAX_ZONEID) { PChar->loc.zone->PushPacket(PChar, CHAR_INRANGE, new CSynthResultMessagePacket(PChar, SYNTH_FAIL)); } @@ -932,8 +929,7 @@ namespace synthutils // Check whether the cheat type action requires us to actively block the cheating attempt // Note: Due to technical reasons jail action also forces us to break the synth // (player cannot be zoned while synth in progress). - bool shouldblock = anticheat::GetCheatPunitiveAction(anticheat::CheatID::CHEAT_ID_FASTSYNTH, nullptr, 0) & - (anticheat::CHEAT_ACTION_BLOCK | anticheat::CHEAT_ACTION_JAIL); + bool shouldblock = anticheat::GetCheatPunitiveAction(anticheat::CheatID::CHEAT_ID_FASTSYNTH, nullptr, 0) & (anticheat::CHEAT_ACTION_BLOCK | anticheat::CHEAT_ACTION_JAIL); if (shouldblock) { // Block the cheat by forcing the synth to fail @@ -943,8 +939,8 @@ namespace synthutils } // And report the incident (will possibly jail the player) anticheat::ReportCheatIncident(PChar, anticheat::CheatID::CHEAT_ID_FASTSYNTH, - (uint32)std::chrono::duration_cast(animationDuration).count(), - "Player attempted to bypass synth animation by injecting synth done packet."); + (uint32)std::chrono::duration_cast(animationDuration).count(), + "Player attempted to bypass synth animation by injecting synth done packet."); if (shouldblock) { // Blocking the cheat also means that the offender should not get any skillups diff --git a/src/map/utils/trustutils.cpp b/src/map/utils/trustutils.cpp index cf297af505d..8e2805ff92d 100644 --- a/src/map/utils/trustutils.cpp +++ b/src/map/utils/trustutils.cpp @@ -428,10 +428,9 @@ namespace trustutils PTrust->m_OwnerID.targid = PMaster->targid; // spawn me randomly around master - PTrust->loc.p = - nearPosition(PMaster->loc.p, CTrustController::SpawnDistance + (PMaster->PTrusts.size() * CTrustController::SpawnDistance), (float)M_PI); - PTrust->look = trustData->look; - PTrust->name = trustData->name; + PTrust->loc.p = nearPosition(PMaster->loc.p, CTrustController::SpawnDistance + (PMaster->PTrusts.size() * CTrustController::SpawnDistance), (float)M_PI); + PTrust->look = trustData->look; + PTrust->name = trustData->name; PTrust->m_Pool = trustData->pool; PTrust->packetName = trustData->packet_name; @@ -532,7 +531,7 @@ namespace trustutils // Helpers to map HP/MPScale around 100 to 1-7 grades // std::clamp doesn't play nice with uint8, so -> unsigned int auto mapRanges = [](unsigned int inputStart, unsigned int inputEnd, unsigned int outputStart, unsigned int outputEnd, - unsigned int inputVal) -> unsigned int + unsigned int inputVal) -> unsigned int { unsigned int inputRange = inputEnd - inputStart; unsigned int outputRange = outputEnd - outputStart; @@ -587,15 +586,11 @@ namespace trustutils grade = scaleToGrade(PTrust->HPscale); - raceStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * mainLevelUpTo60) + - (grade::GetHPScale(grade, scaleOver30Column) * mainLevelOver30) + (grade::GetHPScale(grade, scaleOver60Column) * mainLevelOver60To75) + - (grade::GetHPScale(grade, scaleOver75Column) * mainLevelOver75); + raceStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * mainLevelUpTo60) + (grade::GetHPScale(grade, scaleOver30Column) * mainLevelOver30) + (grade::GetHPScale(grade, scaleOver60Column) * mainLevelOver60To75) + (grade::GetHPScale(grade, scaleOver75Column) * mainLevelOver75); grade = grade::GetJobGrade(mJob, 0); - jobStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * mainLevelUpTo60) + - (grade::GetHPScale(grade, scaleOver30Column) * mainLevelOver30) + (grade::GetHPScale(grade, scaleOver60Column) * mainLevelOver60To75) + - (grade::GetHPScale(grade, scaleOver75Column) * mainLevelOver75); + jobStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * mainLevelUpTo60) + (grade::GetHPScale(grade, scaleOver30Column) * mainLevelOver30) + (grade::GetHPScale(grade, scaleOver60Column) * mainLevelOver60To75) + (grade::GetHPScale(grade, scaleOver75Column) * mainLevelOver75); bonusStat = (mainLevelOver10 + mainLevelOver50andUnder60) * 2; @@ -603,8 +598,7 @@ namespace trustutils { grade = grade::GetJobGrade(sJob, 0); - sJobStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * (sLvl - 1)) + - (grade::GetHPScale(grade, scaleOver30Column) * subLevelOver30) + subLevelOver30 + subLevelOver10; + sJobStat = grade::GetHPScale(grade, baseValueColumn) + (grade::GetHPScale(grade, scaleTo60Column) * (sLvl - 1)) + (grade::GetHPScale(grade, scaleOver30Column) * subLevelOver30) + subLevelOver30 + subLevelOver10; } PTrust->health.maxhp = (int16)(settings::get("map.ALTER_EGO_HP_MULTIPLIER") * (raceStat + jobStat + bonusStat + sJobStat)); @@ -625,16 +619,14 @@ namespace trustutils } else { - raceStat = grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * mainLevelUpTo60 + - grade::GetMPScale(grade, scaleOver60) * mainLevelOver60; + raceStat = grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * mainLevelUpTo60 + grade::GetMPScale(grade, scaleOver60) * mainLevelOver60; } grade = grade::GetJobGrade(mJob, 1); if (grade > 0) { - jobStat = grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * mainLevelUpTo60 + - grade::GetMPScale(grade, scaleOver60) * mainLevelOver60; + jobStat = grade::GetMPScale(grade, 0) + grade::GetMPScale(grade, scaleTo60Column) * mainLevelUpTo60 + grade::GetMPScale(grade, scaleOver60) * mainLevelOver60; } if (sLvl > 0) diff --git a/src/map/utils/zoneutils.cpp b/src/map/utils/zoneutils.cpp index b3a3e72827a..039d56b37eb 100644 --- a/src/map/utils/zoneutils.cpp +++ b/src/map/utils/zoneutils.cpp @@ -135,7 +135,7 @@ namespace zoneutils } } - CCharEntity* GetCharByName(std::string const& name) + CCharEntity* GetCharByName(const std::string& name) { for (auto PZone : g_PZoneList) { diff --git a/src/map/utils/zoneutils.h b/src/map/utils/zoneutils.h index 4c78df97a0a..7048d4d07ae 100644 --- a/src/map/utils/zoneutils.h +++ b/src/map/utils/zoneutils.h @@ -46,7 +46,7 @@ namespace zoneutils CZone* GetZone(uint16 ZoneID); CNpcEntity* GetTrigger(uint16 TargID, uint16 ZoneID); CBaseEntity* GetEntity(uint32 ID, uint8 filter = -1); - CCharEntity* GetCharByName(std::string const& name); + CCharEntity* GetCharByName(const std::string& name); CCharEntity* GetCharFromWorld(uint32 charid, uint16 targid); // returns pointer to character by id and target id CCharEntity* GetChar(uint32 id); // returns pointer to character by id CCharEntity* GetCharToUpdate(uint32 primary, uint32 ternary); // returns pointer to preferred char to update for party changes diff --git a/src/map/zone.cpp b/src/map/zone.cpp index a70e5955c5e..42dc3e2dbd4 100644 --- a/src/map/zone.cpp +++ b/src/map/zone.cpp @@ -271,7 +271,7 @@ void CZone::SetBackgroundMusicNight(uint16 music) * with other methods that perform pattern matching. * E.g: %anto% matches Shantotto and Canto-anto */ -QueryByNameResult_t const& CZone::queryEntitiesByName(std::string const& pattern) +const QueryByNameResult_t& CZone::queryEntitiesByName(const std::string& pattern) { TracyZoneScoped; @@ -706,10 +706,7 @@ void CZone::UpdateWeather() // This check is incorrect, fog is not simply a time of day, though it may consistently happen in SOME zones // (Al'Taieu likely has it every morning, while Atohwa Chasm can have it at random any time of day) - if ((CurrentVanaDate >= StartFogVanaDate) && - (CurrentVanaDate < EndFogVanaDate) && - (Weather < WEATHER_HOT_SPELL) && - !(GetTypeMask() & ZONE_TYPE::CITY)) + if ((CurrentVanaDate >= StartFogVanaDate) && (CurrentVanaDate < EndFogVanaDate) && (Weather < WEATHER_HOT_SPELL) && !(GetTypeMask() & ZONE_TYPE::CITY)) { Weather = WEATHER_FOG; // Force the weather to change by 7 am @@ -721,7 +718,7 @@ void CZone::UpdateWeather() luautils::OnZoneWeatherChange(GetID(), Weather); CTaskMgr::getInstance()->AddTask(new CTaskMgr::CTask("zone_update_weather", server_clock::now() + std::chrono::seconds(WeatherNextUpdate), this, - CTaskMgr::TASK_ONCE, zone_update_weather)); + CTaskMgr::TASK_ONCE, zone_update_weather)); } /************************************************************************ @@ -888,7 +885,7 @@ void CZone::SavePlayTime() m_zoneEntities->SavePlayTime(); } -CCharEntity* CZone::GetCharByName(std::string const& name) +CCharEntity* CZone::GetCharByName(const std::string& name) { return m_zoneEntities->GetCharByName(name); } @@ -951,7 +948,7 @@ void CZone::ZoneServer(time_point tick) } } -void CZone::ForEachChar(std::function const& func) +void CZone::ForEachChar(const std::function& func) { TracyZoneScoped; for (auto PChar : m_zoneEntities->GetCharList()) @@ -960,7 +957,7 @@ void CZone::ForEachChar(std::function const& func) } } -void CZone::ForEachCharInstance(CBaseEntity* PEntity, std::function const& func) +void CZone::ForEachCharInstance(CBaseEntity* PEntity, const std::function& func) { TracyZoneScoped; for (auto PChar : m_zoneEntities->GetCharList()) @@ -969,7 +966,7 @@ void CZone::ForEachCharInstance(CBaseEntity* PEntity, std::function const& func) +void CZone::ForEachMob(const std::function& func) { TracyZoneScoped; for (auto PMob : m_zoneEntities->m_mobList) @@ -978,7 +975,7 @@ void CZone::ForEachMob(std::function const& func) } } -void CZone::ForEachMobInstance(CBaseEntity* PEntity, std::function const& func) +void CZone::ForEachMobInstance(CBaseEntity* PEntity, const std::function& func) { TracyZoneScoped; for (auto PMob : m_zoneEntities->m_mobList) @@ -987,7 +984,7 @@ void CZone::ForEachMobInstance(CBaseEntity* PEntity, std::function const& func) +void CZone::ForEachTrust(const std::function& func) { TracyZoneScoped; for (auto PTrust : m_zoneEntities->m_trustList) @@ -996,7 +993,7 @@ void CZone::ForEachTrust(std::function const& func) } } -void CZone::ForEachTrustInstance(CBaseEntity* PEntity, std::function const& func) +void CZone::ForEachTrustInstance(CBaseEntity* PEntity, const std::function& func) { TracyZoneScoped; for (auto PTrust : m_zoneEntities->m_trustList) @@ -1005,7 +1002,7 @@ void CZone::ForEachTrustInstance(CBaseEntity* PEntity, std::function const& func) +void CZone::ForEachNpc(const std::function& func) { TracyZoneScoped; for (auto PNpc : m_zoneEntities->m_npcList) @@ -1017,13 +1014,11 @@ void CZone::ForEachNpc(std::function const& func) void CZone::createZoneTimers() { TracyZoneScoped; - ZoneTimer = - CTaskMgr::getInstance()->AddTask(m_zoneName, server_clock::now(), this, CTaskMgr::TASK_INTERVAL, zone_server, - std::chrono::milliseconds(static_cast(server_tick_interval))); + ZoneTimer = CTaskMgr::getInstance()->AddTask(m_zoneName, server_clock::now(), this, CTaskMgr::TASK_INTERVAL, zone_server, + std::chrono::milliseconds(static_cast(server_tick_interval))); - ZoneTimerTriggerAreas = - CTaskMgr::getInstance()->AddTask(m_zoneName + "TriggerAreas", server_clock::now(), this, CTaskMgr::TASK_INTERVAL, zone_trigger_area, - std::chrono::milliseconds(static_cast(server_trigger_area_interval))); + ZoneTimerTriggerAreas = CTaskMgr::getInstance()->AddTask(m_zoneName + "TriggerAreas", server_clock::now(), this, CTaskMgr::TASK_INTERVAL, zone_trigger_area, + std::chrono::milliseconds(static_cast(server_trigger_area_interval))); } void CZone::CharZoneIn(CCharEntity* PChar) @@ -1214,7 +1209,7 @@ void CZone::CheckTriggerAreas() { TracyZoneScoped; - for (auto const& [targid, PEntity] : m_zoneEntities->m_charList) + for (const auto& [targid, PEntity] : m_zoneEntities->m_charList) { auto* PChar = static_cast(PEntity); diff --git a/src/map/zone.h b/src/map/zone.h index 9ae19491896..7be7f315d4b 100644 --- a/src/map/zone.h +++ b/src/map/zone.h @@ -497,7 +497,7 @@ struct zoneWeather_t zoneWeather_t(uint8 _normal, uint8 _common, uint8 _rare) : normal(_normal) , common(_common) - , rare(_rare){}; + , rare(_rare) {}; }; /************************************************************************ @@ -564,13 +564,13 @@ class CZone void SetBackgroundMusicDay(uint16 music); void SetBackgroundMusicNight(uint16 music); - auto queryEntitiesByName(std::string const& pattern) -> QueryByNameResult_t const&; + auto queryEntitiesByName(const std::string& pattern) -> const QueryByNameResult_t&; uint32 GetLocalVar(const char* var); void SetLocalVar(const char* var, uint32 val); void ResetLocalVars(); - virtual CCharEntity* GetCharByName(std::string const& name); + virtual CCharEntity* GetCharByName(const std::string& name); virtual CCharEntity* GetCharByID(uint32 id); // Gets an entity - ignores instances (use CBaseEntity->GetEntity if possible) @@ -623,13 +623,13 @@ class CZone virtual void ZoneServer(time_point tick); virtual void CheckTriggerAreas(); - virtual void ForEachChar(std::function const& func); - virtual void ForEachCharInstance(CBaseEntity* PEntity, std::function const& func); - virtual void ForEachMob(std::function const& func); - virtual void ForEachMobInstance(CBaseEntity* PEntity, std::function const& func); - virtual void ForEachTrust(std::function const& func); - virtual void ForEachTrustInstance(CBaseEntity* PEntity, std::function const& func); - virtual void ForEachNpc(std::function const& func); + virtual void ForEachChar(const std::function& func); + virtual void ForEachCharInstance(CBaseEntity* PEntity, const std::function& func); + virtual void ForEachMob(const std::function& func); + virtual void ForEachMobInstance(CBaseEntity* PEntity, const std::function& func); + virtual void ForEachTrust(const std::function& func); + virtual void ForEachTrustInstance(CBaseEntity* PEntity, const std::function& func); + virtual void ForEachNpc(const std::function& func); CZone(ZONEID ZoneID, REGION_TYPE RegionID, CONTINENT_TYPE ContinentID, uint8 levelRestriction); virtual ~CZone(); diff --git a/src/map/zone_entities.cpp b/src/map/zone_entities.cpp index e32a92fdf2a..661abe629f3 100644 --- a/src/map/zone_entities.cpp +++ b/src/map/zone_entities.cpp @@ -286,8 +286,7 @@ void CZoneEntities::FindPartyForMob(CBaseEntity* PEntity) int16 sublink = PMob->getMobMod(MOBMOD_SUBLINK); - if (PCurrentMob->allegiance == PMob->allegiance && - (forceLink || PCurrentMob->m_Family == PMob->m_Family || (sublink && sublink == PCurrentMob->getMobMod(MOBMOD_SUBLINK)))) + if (PCurrentMob->allegiance == PMob->allegiance && (forceLink || PCurrentMob->m_Family == PMob->m_Family || (sublink && sublink == PCurrentMob->getMobMod(MOBMOD_SUBLINK)))) { if (PCurrentMob->PMaster == nullptr || PCurrentMob->PMaster->objtype == TYPE_MOB) { @@ -905,8 +904,7 @@ void CZoneEntities::SpawnPCs(CCharEntity* PChar) auto bonus = bonusIter == scoreBonus.end() ? 0 : bonusIter->second; float totalScore = significanceScore + bonus - charDistance; - if (PChar->SpawnPCList.size() < CHARACTER_SYNC_LIMIT_MAX || - (!spawnedCharacters.empty() && totalScore > spawnedCharacters.top().first)) + if (PChar->SpawnPCList.size() < CHARACTER_SYNC_LIMIT_MAX || (!spawnedCharacters.empty() && totalScore > spawnedCharacters.top().first)) { // Is nearby and should be considered as a candidate to be spawned candidateCharacters.push(std::make_pair(totalScore, PCurrentChar)); diff --git a/src/map/zone_instance.cpp b/src/map/zone_instance.cpp index 3f300bb2365..96a009a1bd4 100644 --- a/src/map/zone_instance.cpp +++ b/src/map/zone_instance.cpp @@ -247,8 +247,8 @@ void CZoneInstance::IncreaseZoneCounter(CCharEntity* PChar) else { ShowWarning(fmt::format("Failed to place {} in {} ({}). Placing them in that zone's instance exit area.", - PChar->name, this->getName(), this->GetID()) - .c_str()); + PChar->name, this->getName(), this->GetID()) + .c_str()); // instance no longer exists: put them outside (at exit) uint16 zoneid = luautils::OnInstanceLoadFailed(this); diff --git a/src/search/data_loader.cpp b/src/search/data_loader.cpp index e0dae392579..304ffc9e8d2 100644 --- a/src/search/data_loader.cpp +++ b/src/search/data_loader.cpp @@ -110,7 +110,7 @@ std::vector CDataLoader::GetAHItemsToCategory(uint8 AHCategoryID, const "WHERE aH = %u " "GROUP BY item_basic.itemid " "%s", - selectFrom, AHCategoryID, OrderByString); + selectFrom, AHCategoryID, OrderByString); auto rset = db::query(fmtQuery); if (rset && rset->rowsCount()) @@ -242,17 +242,16 @@ std::list CDataLoader::GetPlayersList(search_req sr, int* count) filterQry.append(fmt::sprintf(" AND (seacom_type & 0xF0) = %u", sr.commentType, sr.commentType)); } - std::string fmtQuery = - "SELECT charid, partyid, charname, pos_zone, pos_prevzone, nation, rank_sandoria, rank_bastok, " - "rank_windurst, race, mjob, sjob, mlvl, slvl, languages, settings, seacom_type, disconnecting, gmHiddenEnabled " - "FROM accounts_sessions " - "LEFT JOIN accounts_parties USING (charid) " - "LEFT JOIN chars USING (charid) " - "LEFT JOIN char_look USING (charid) " - "LEFT JOIN char_stats USING (charid) " - "LEFT JOIN char_profile USING(charid) " - "LEFT JOIN char_flags USING(charid) " - "WHERE charname IS NOT NULL "; + std::string fmtQuery = "SELECT charid, partyid, charname, pos_zone, pos_prevzone, nation, rank_sandoria, rank_bastok, " + "rank_windurst, race, mjob, sjob, mlvl, slvl, languages, settings, seacom_type, disconnecting, gmHiddenEnabled " + "FROM accounts_sessions " + "LEFT JOIN accounts_parties USING (charid) " + "LEFT JOIN chars USING (charid) " + "LEFT JOIN char_look USING (charid) " + "LEFT JOIN char_stats USING (charid) " + "LEFT JOIN char_profile USING(charid) " + "LEFT JOIN char_flags USING(charid) " + "WHERE charname IS NOT NULL "; fmtQuery.append(filterQry); fmtQuery.append(" ORDER BY charname ASC"); @@ -481,18 +480,17 @@ std::list CDataLoader::GetPartyList(uint32 PartyID, uint32 Allian { std::list PartyList; - const char* query = - "SELECT charid, partyid, charname, pos_zone, nation, rank_sandoria, rank_bastok, rank_windurst, race, settings, mjob, sjob, mlvl, slvl, languages, seacom_type, disconnecting " - "FROM accounts_sessions " - "LEFT JOIN accounts_parties USING(charid) " - "LEFT JOIN chars USING(charid) " - "LEFT JOIN char_look USING(charid) " - "LEFT JOIN char_stats USING(charid) " - "LEFT JOIN char_profile USING(charid) " - "LEFT JOIN char_flags USING(charid) " - "WHERE IF (allianceid <> 0, allianceid IN (SELECT allianceid FROM accounts_parties WHERE charid = %u) , partyid = %u) " - "ORDER BY charname ASC " - "LIMIT 64"; + const char* query = "SELECT charid, partyid, charname, pos_zone, nation, rank_sandoria, rank_bastok, rank_windurst, race, settings, mjob, sjob, mlvl, slvl, languages, seacom_type, disconnecting " + "FROM accounts_sessions " + "LEFT JOIN accounts_parties USING(charid) " + "LEFT JOIN chars USING(charid) " + "LEFT JOIN char_look USING(charid) " + "LEFT JOIN char_stats USING(charid) " + "LEFT JOIN char_profile USING(charid) " + "LEFT JOIN char_flags USING(charid) " + "WHERE IF (allianceid <> 0, allianceid IN (SELECT allianceid FROM accounts_parties WHERE charid = %u) , partyid = %u) " + "ORDER BY charname ASC " + "LIMIT 64"; auto rset = db::query(fmt::sprintf(query, (!AllianceID ? PartyID : AllianceID), (!PartyID ? AllianceID : PartyID))); if (rset && rset->rowsCount()) @@ -745,7 +743,7 @@ void CDataLoader::ExpireAHItems(uint16 expireAgeInDays) qStr = fmt::format("INSERT INTO delivery_box (charid, charname, box, itemid, itemsubid, quantity, senderid, sender) VALUES " "({}, '{}', 1, {}, 0, {}, 0, 'AH-Jeuno');", - listing.sellerID, listing.sellerName, listing.itemID, listing.ahStack == 1 ? listing.itemStack : 1); + listing.sellerID, listing.sellerName, listing.itemID, listing.ahStack == 1 ? listing.itemStack : 1); ret = sql2->Query(qStr.c_str()); diff --git a/src/search/packets/search_comment.cpp b/src/search/packets/search_comment.cpp index ccf4a54f5d7..b572e8aea76 100644 --- a/src/search/packets/search_comment.cpp +++ b/src/search/packets/search_comment.cpp @@ -1,11 +1,10 @@ - -#include "search_comment.h" +#include "search_comment.h" #include "common/logging.h" #include "common/socket.h" #include "common/utils.h" -SearchCommentPacket::SearchCommentPacket(uint32 playerId, std::string const& comment) +SearchCommentPacket::SearchCommentPacket(uint32 playerId, const std::string& comment) { ref(data, 0x08) = 154; // Search comment packet size ref(data, 0x0A) = 0x80; // Search server packet diff --git a/src/search/packets/search_comment.h b/src/search/packets/search_comment.h index 7f8dffae613..bb3d2e5b3af 100644 --- a/src/search/packets/search_comment.h +++ b/src/search/packets/search_comment.h @@ -1,5 +1,4 @@ - -#ifndef _SEARCH_COMMENT_PACKET_H_ +#ifndef _SEARCH_COMMENT_PACKET_H_ #define _SEARCH_COMMENT_PACKET_H_ #include "common/cbasetypes.h" @@ -8,7 +7,7 @@ class SearchCommentPacket { public: - SearchCommentPacket(uint32 playerId, std::string const& comment); + SearchCommentPacket(uint32 playerId, const std::string& comment); uint8* GetData(); uint16 GetSize(); diff --git a/src/search/search.cpp b/src/search/search.cpp index ff614ccf762..ffd51f97a8e 100755 --- a/src/search/search.cpp +++ b/src/search/search.cpp @@ -95,7 +95,7 @@ struct SearchCommInfo uint16 port; }; -void TaskManagerThread(bool const& requestExit); +void TaskManagerThread(const bool& requestExit); int32 ah_cleanup(time_point tick, CTaskMgr::CTask* PTask); @@ -132,7 +132,7 @@ std::string socketToString(SOCKET socket) return std::string(ipstr); } -bool isSocketInUse(std::string const& ipAddressStr) +bool isSocketInUse(const std::string& ipAddressStr) { // clang-format off if (gIPAddressWhitelist.read([ipAddressStr](auto const& ipWhitelist) @@ -153,7 +153,7 @@ bool isSocketInUse(std::string const& ipAddressStr) // clang-format on } -void removeSocketFromSet(std::string const& ipAddressStr) +void removeSocketFromSet(const std::string& ipAddressStr) { // clang-format off if (gIPAddressWhitelist.read([ipAddressStr](auto const& ipWhitelist) @@ -174,7 +174,7 @@ void removeSocketFromSet(std::string const& ipAddressStr) // clang-format on } -void addSocketToSet(std::string const& ipAddressStr) +void addSocketToSet(const std::string& ipAddressStr) { // clang-format off if (gIPAddressWhitelist.read([ipAddressStr](auto const& ipWhitelist) @@ -263,9 +263,7 @@ int32 main(int32 argc, char** argv) SOCKET ClientSocket = INVALID_SOCKET; struct addrinfo* result = nullptr; - struct addrinfo hints - { - }; + struct addrinfo hints{}; #ifdef WIN32 // Initialize Winsock @@ -375,11 +373,11 @@ int32 main(int32 argc, char** argv) { ShowInfo("AH task to return items older than %u days is running", expireDays); CTaskMgr::getInstance()->AddTask("ah_cleanup", server_clock::now(), nullptr, CTaskMgr::TASK_INTERVAL, ah_cleanup, - std::chrono::seconds(settings::get("search.EXPIRE_INTERVAL"))); + std::chrono::seconds(settings::get("search.EXPIRE_INTERVAL"))); } sol::table accessWhitelist = lua["xi"]["settings"]["search"]["ACCESS_WHITELIST"].get_or_create(); - for (auto const& [_, value] : accessWhitelist) + for (const auto& [_, value] : accessWhitelist) { // clang-format off auto str = value.as(); @@ -616,7 +614,7 @@ void TCPComm(SOCKET socket) } ShowInfo("Search Request: %s (%u), size: %u, ip: %s", - searchTypeToString(PTCPRequest.getPacketType()), PTCPRequest.getPacketType(), PTCPRequest.getSize(), clientIP); + searchTypeToString(PTCPRequest.getPacketType()), PTCPRequest.getPacketType(), PTCPRequest.getSize(), clientIP); switch (PTCPRequest.getPacketType()) { @@ -1117,7 +1115,7 @@ search_req _HandleSearchRequest(CTCPRequestPacket& PTCPRequest) * * ************************************************************************/ -void TaskManagerThread(bool const& requestExit) +void TaskManagerThread(const bool& requestExit) { duration next; while (!requestExit) diff --git a/src/search/tcp_request.cpp b/src/search/tcp_request.cpp index 7f111df30ad..2251ebe0bdb 100644 --- a/src/search/tcp_request.cpp +++ b/src/search/tcp_request.cpp @@ -55,7 +55,7 @@ CTCPRequestPacket::CTCPRequestPacket(SOCKET* socket) , blowfish(blowfish_t()) { uint8 keys[24] = { 0x30, 0x73, 0x3D, 0x6D, 0x3C, 0x31, 0x49, 0x5A, 0x32, 0x7A, 0x42, 0x43, - 0x63, 0x38, 0x7B, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + 0x63, 0x38, 0x7B, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; memcpy(&key[0], &keys[0], 24); } diff --git a/src/world/conquest_system.cpp b/src/world/conquest_system.cpp index 9b4c3f10f9f..a889eb05142 100644 --- a/src/world/conquest_system.cpp +++ b/src/world/conquest_system.cpp @@ -70,9 +70,9 @@ bool ConquestSystem::handleMessage(HandleableMessage&& message) default: { ShowDebug(fmt::format("Message: unknown conquest type received: {} from {}:{}", - static_cast(conquestMsgType), - message.from_addr.s_addr, - message.from_port)); + static_cast(conquestMsgType), + message.from_addr.s_addr, + message.from_port)); } break; } @@ -223,7 +223,7 @@ bool ConquestSystem::updateInfluencePoints(int points, unsigned int nation, REGI auto rset2 = db::query(fmt::sprintf("UPDATE conquest_system SET sandoria_influence = %d, bastok_influence = %d, " "windurst_influence = %d, beastmen_influence = %d WHERE region_id = %u", - influences[0], influences[1], influences[2], influences[3], static_cast(region))); + influences[0], influences[1], influences[2], influences[3], static_cast(region))); return !rset2; } diff --git a/src/world/conquest_system.h b/src/world/conquest_system.h index 13d521d73ee..4bd6487a90e 100644 --- a/src/world/conquest_system.h +++ b/src/world/conquest_system.h @@ -61,8 +61,8 @@ class ConquestSystem : public IMessageHandler private: bool updateInfluencePoints(int points, unsigned int nation, REGION_TYPE region); - auto getRegionalInfluences() -> std::vector const; - auto getRegionControls() -> std::vector const; + auto getRegionalInfluences() -> const std::vector; + auto getRegionControls() -> const std::vector; void sendTallyStartMsg(); void sendInfluencesMsg(bool shouldUpdateZones, uint64 ipp = 0xFFFF); diff --git a/src/world/message_server.cpp b/src/world/message_server.cpp index 34b30991998..c466d867345 100644 --- a/src/world/message_server.cpp +++ b/src/world/message_server.cpp @@ -140,7 +140,7 @@ void message_server_parse(MSGSERVTYPE type, zmq::message_t* extra, zmq::message_ } ShowDebug(fmt::format("Message: Received message {} ({}) from {}:{}", - msgTypeToStr(type), static_cast(type), str(from_address), from_port)); + msgTypeToStr(type), static_cast(type), str(from_address), from_port)); while (rset->next()) { @@ -315,7 +315,7 @@ void message_server_parse(MSGSERVTYPE type, zmq::message_t* extra, zmq::message_ } } -void message_server_listen(bool const& requestExit) +void message_server_listen(const bool& requestExit) { while (!requestExit) { @@ -396,7 +396,7 @@ void cache_zone_settings() std::copy(yellMapEndpointSet.begin(), yellMapEndpointSet.end(), std::back_inserter(yellMapEndpoints)); } -void message_server_init(bool const& requestExit) +void message_server_init(const bool& requestExit) { TracySetThreadName("Message Server (ZMQ)"); @@ -409,8 +409,8 @@ void message_server_init(bool const& requestExit) zSocket->set(zmq::sockopt::rcvtimeo, 500); auto server = fmt::format("tcp://{}:{}", - settings::get("network.ZMQ_IP"), - settings::get("network.ZMQ_PORT")); + settings::get("network.ZMQ_IP"), + settings::get("network.ZMQ_PORT")); ShowInfo("Starting ZMQ Server on %s", server.c_str()); diff --git a/src/world/message_server.h b/src/world/message_server.h index 27468e632c7..e3a18828912 100644 --- a/src/world/message_server.h +++ b/src/world/message_server.h @@ -35,12 +35,12 @@ void queue_message_broadcast(MSGSERVTYPE type, zmq::message_t* extra, zmq::messa auto pop_external_processing_message() -> std::optional; -void message_server_init(bool const& requestExit); +void message_server_init(const bool& requestExit); void message_server_close(); struct message_server_wrapper_t { - message_server_wrapper_t(std::atomic_bool const& requestExit) + message_server_wrapper_t(const std::atomic_bool& requestExit) : m_thread(std::make_unique(std::bind(message_server_init, std::ref(requestExit)))) { }