From 10b19dfceb0dc97f930503303165e17c3e1e1a04 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Tue, 12 Nov 2024 22:05:25 -0300 Subject: [PATCH] fix: add source location to combatTypeToIndex (#3095) --- src/creatures/players/player.cpp | 2 -- src/utils/tools.cpp | 4 ++-- src/utils/tools.hpp | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/creatures/players/player.cpp b/src/creatures/players/player.cpp index a8ef732b900..b538d042367 100644 --- a/src/creatures/players/player.cpp +++ b/src/creatures/players/player.cpp @@ -8820,8 +8820,6 @@ void Player::triggerTranscendance() { } // Forge system -// Forge system - void Player::forgeFuseItems(ForgeAction_t actionType, uint16_t firstItemId, uint8_t tier, uint16_t secondItemId, bool success, bool reduceTierLoss, bool convergence, uint8_t bonus, uint8_t coreCount) { if (getFreeBackpackSlots() == 0) { sendCancelMessage(RETURNVALUE_NOTENOUGHROOM); diff --git a/src/utils/tools.cpp b/src/utils/tools.cpp index f393f5332ae..fff20962d15 100644 --- a/src/utils/tools.cpp +++ b/src/utils/tools.cpp @@ -1145,12 +1145,12 @@ CombatType_t getCombatTypeByName(const std::string &combatname) { return it != combatTypeNames.end() ? it->first : COMBAT_NONE; } -size_t combatTypeToIndex(CombatType_t combatType) { +size_t combatTypeToIndex(CombatType_t combatType, std::source_location location) { const auto enum_index_opt = magic_enum::enum_index(combatType); if (enum_index_opt.has_value() && enum_index_opt.value() < COMBAT_COUNT) { return enum_index_opt.value(); } else { - g_logger().error("[{}] Combat type {} is out of range", __FUNCTION__, fmt::underlying(combatType)); + g_logger().error("[{}] Combat type {} is out of range, called line '{}:{}' in '{}'", __FUNCTION__, fmt::underlying(combatType), location.line(), location.column(), location.function_name()); // Uncomment for catch the function call with debug // throw std::out_of_range("Combat is out of range"); } diff --git a/src/utils/tools.hpp b/src/utils/tools.hpp index 7a7d4a22bdd..9f7f15dfb5d 100644 --- a/src/utils/tools.hpp +++ b/src/utils/tools.hpp @@ -137,7 +137,7 @@ CombatType_t getCombatTypeByName(const std::string &combatname); * @return The corresponding index of the CombatType_t enumeration. * If the CombatType_t is out of range, this function will log an error and return an empty size_t. */ -size_t combatTypeToIndex(CombatType_t combatType); +size_t combatTypeToIndex(CombatType_t combatType, std::source_location location = std::source_location::current()); /** * @brief Convert the CombatType_t enumeration to its corresponding string representation.