From d4931755eaa79d6c4dadb78adb8aff15f5a2424e Mon Sep 17 00:00:00 2001 From: Dan <83884799+elthehablo@users.noreply.github.com> Date: Fri, 24 Nov 2023 01:20:09 +0100 Subject: [PATCH] fix(Scripts/Commands): make sure no invalid IDs can be passed in map creation for `.go xyz` (#17836) * handle wrong ID * remove enum * white line at end got removed for some reason idk * a tab --- src/server/scripts/Commands/cs_go.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp index e840f77a5..b5e3f7962 100644 --- a/src/server/scripts/Commands/cs_go.cpp +++ b/src/server/scripts/Commands/cs_go.cpp @@ -337,10 +337,19 @@ public: Player* player = handler->GetSession()->GetPlayer(); uint32 mapId = locationValues.size() >= 4 ? uint32(locationValues[3]) : player->GetMapId(); - Map const* map = sMapMgr->CreateBaseMap(mapId); float x = locationValues[0]; float y = locationValues[1]; + + if (mapId == MAPID_INVALID) + { + handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId); + handler->SetSentErrorMessage(true); + return false; + } + + Map const* map = sMapMgr->CreateBaseMap(mapId); + float z = locationValues.size() >= 3 ? locationValues[2] : std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); // map ID (locationValues[3]) already handled above float o = locationValues.size() >= 5 ? locationValues[4] : player->GetOrientation();