Skip to content

Commit

Permalink
fix: crash on try gem grade upgrade greater than 3
Browse files Browse the repository at this point in the history
  • Loading branch information
phacUFPE committed Nov 24, 2024
1 parent 419ce43 commit 4a4f3e2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/creatures/players/wheel/player_wheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1448,8 +1448,13 @@ void PlayerWheel::improveGemGrade(WheelFragmentType_t fragmentType, uint8_t pos)
return;
}

if (value == 0 && quantity == 0) {
g_logger().error("[{}] Player {} trying to upgrade gem to grade greater than 3", std::source_location::current().function_name(), m_player.getName());
return;
}

if (!m_player.hasItemCountById(fragmentId, quantity, true)) {
g_logger().error("[{}] Player {} does not have the required {} fragments with id {}", __FUNCTION__, m_player.getName(), quantity, fragmentId);
g_logger().error("[{}] Player {} does not have the required {} fragments with id {}", std::source_location::current().function_name(), m_player.getName(), quantity, fragmentId);
return;
}

Expand Down Expand Up @@ -1477,7 +1482,7 @@ std::tuple<int, int> PlayerWheel::getLesserGradeCost(uint8_t grade) const {
case 3:
return std::make_tuple(30000000, 30);
default:
throw std::invalid_argument("Invalid level for Lesser Fragment.");
return {};
}
}

Expand All @@ -1490,7 +1495,7 @@ std::tuple<int, int> PlayerWheel::getGreaterGradeCost(uint8_t grade) const {
case 3:
return std::make_tuple(75000000, 30);
default:
throw std::invalid_argument("Invalid level for Greater Fragment.");
return {};
}
}

Expand Down

0 comments on commit 4a4f3e2

Please sign in to comment.