Skip to content

Commit

Permalink
Don't dereference nullopt in DebugCmdLevelUp()
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenCWills authored and AJenbo committed May 9, 2024
1 parent 15791ee commit 2215001
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Source/lua/modules/dev/player/stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ namespace {

std::string DebugCmdLevelUp(std::optional<int> levels)
{
if (!levels.has_value()) *levels = 1;
if (*levels <= 0) return "amount must be positive";
const int levelsToAdd = levels.value_or(1);
if (levelsToAdd <= 0) return "amount must be positive";
Player &myPlayer = *MyPlayer;
for (int i = 0; i < *levels; i++)
for (int i = 0; i < levelsToAdd; i++)
NetSendCmd(true, CMD_CHEAT_EXPERIENCE);
return StrCat("New character level: ", myPlayer.getCharacterLevel() + *levels);
return StrCat("New character level: ", myPlayer.getCharacterLevel() + levelsToAdd);
}

std::string DebugCmdMaxStats()
Expand Down

0 comments on commit 2215001

Please sign in to comment.