Skip to content

Commit

Permalink
fix: add source location to combatTypeToIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Nov 10, 2024
1 parent beed45b commit 0ea9562
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8822,8 +8822,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);
Expand Down
4 changes: 2 additions & 2 deletions src/utils/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/tools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0ea9562

Please sign in to comment.