diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index a9e137e91..cd3cd96e6 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -784,8 +784,8 @@ void CCharacter::Die(int Killer, int Weapon) // reset switches if we are the last player in team to prevent door opening cheat: // https://github.com/DDRace/teeworlds/issues/190 - if (Teams()->Count(Team()) == 1) { - for (int i = 0; i <= GameServer()->Collision()->m_NumSwitchers; ++i) { + if (Teams()->Count(Team()) == 1 && GameServer()->Collision()->m_NumSwitchers > 0) { + for (int i = 0; i < GameServer()->Collision()->m_NumSwitchers+1; ++i) { GameServer()->Collision()->m_pSwitchers[i].m_Status[Team()] = true; } }