From 12c69f8e04fb44afb43799398d4ab8d8facda586 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sat, 23 Dec 2023 18:11:48 +0200 Subject: [PATCH] Fix crash on accessing non-existing player ID --- server/CGameHandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 68bccfaf6..d6cdbe0e2 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -2223,12 +2223,12 @@ bool CGameHandler::arrangeStacks(ObjectInstanceID id1, ObjectInstanceID id2, ui8 bool CGameHandler::hasPlayerAt(PlayerColor player, std::shared_ptr c) const { - return connections.at(player).count(c); + return connections.count(player) && connections.at(player).count(c); } bool CGameHandler::hasBothPlayersAtSameConnection(PlayerColor left, PlayerColor right) const { - return connections.at(left) == connections.at(right); + return connections.count(left) && connections.count(right) && connections.at(left) == connections.at(right); } bool CGameHandler::disbandCreature(ObjectInstanceID id, SlotID pos)