diff --git a/Source/debug.cpp b/Source/debug.cpp index 7a66309d6cfc..7c225962a611 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -11,7 +11,6 @@ #include #include "debug.h" - #include "automap.h" #include "control.h" #include "cursor.h" @@ -565,7 +564,7 @@ std::string DebugCmdLevelUp(const std::string_view parameter) Player &myPlayer = *MyPlayer; std::string cmdLabel = "[givelvl] "; - const int levels = ParseInt(parameter, /*min=*/1).value_or(1); + const int levels = std::min(ParseInt(parameter, /*min=*/1).value_or(1), GetMaximumCharacterLevel()); for (int i = 0; i < levels; i++) NetSendCmd(true, CMD_CHEAT_EXPERIENCE); return StrCat(cmdLabel, "New character level: ", myPlayer.getCharacterLevel());