From 87a23fb708dd7b428e88846c5985b01076293364 Mon Sep 17 00:00:00 2001 From: tetektoza Date: Wed, 11 Oct 2023 23:26:21 +0200 Subject: [PATCH] Clip parsed level from debug console to 50 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. --- Source/debug.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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());