Skip to content

Commit

Permalink
Clip parsed level from debug console to 50
Browse files Browse the repository at this point in the history
Currently, in givelvl command user can type lvl above 50, which is a
level cap. This patch clips it to 50, so we can prevent an accidential
freeze of the game caused by NetSendCmd loop if user types a really big
number.
  • Loading branch information
tetektoza authored and StephenCWills committed Oct 11, 2023
1 parent 706010e commit 41c5175
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,10 +565,10 @@ std::string DebugCmdLevelUp(const std::string_view parameter)
Player &myPlayer = *MyPlayer;
std::string cmdLabel = "[givelvl] ";

const int levels = ParseInt<int>(parameter, /*min=*/1).value_or(1);
const int levels = std::min<int>(ParseInt<int>(parameter, /*min=*/1).value_or(1), GetMaximumCharacterLevel() - myPlayer.getCharacterLevel());
for (int i = 0; i < levels; i++)
NetSendCmd(true, CMD_CHEAT_EXPERIENCE);
return StrCat(cmdLabel, "New character level: ", myPlayer.getCharacterLevel());
return StrCat(cmdLabel, "New character level: ", myPlayer.getCharacterLevel() + levels);
}

std::string DebugCmdMaxStats(const std::string_view parameter)
Expand Down

0 comments on commit 41c5175

Please sign in to comment.