1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fix crash on accessing non-existing player ID

This commit is contained in:
Ivan Savenko 2023-12-23 18:11:48 +02:00
parent cd526a5e15
commit 12c69f8e04

View File

@ -2223,12 +2223,12 @@ bool CGameHandler::arrangeStacks(ObjectInstanceID id1, ObjectInstanceID id2, ui8
bool CGameHandler::hasPlayerAt(PlayerColor player, std::shared_ptr<CConnection> 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)