diff --git a/dScripts/BaseWavesServer.cpp b/dScripts/BaseWavesServer.cpp index ac8da8a7..29706f52 100644 --- a/dScripts/BaseWavesServer.cpp +++ b/dScripts/BaseWavesServer.cpp @@ -60,8 +60,11 @@ void BaseWavesServer::BaseStartup(Entity* self) { // Done void BaseWavesServer::BasePlayerExit(Entity* self, Entity* player) { - state.waitingPlayers.erase(std::find(state.waitingPlayers.begin(), state.waitingPlayers.end(), player->GetObjectID())); - state.players.erase(std::find(state.players.begin(), state.players.end(), player->GetObjectID())); + auto waitingPlayerToErase = std::find(state.waitingPlayers.begin(), state.waitingPlayers.end(), player->GetObjectID()); + if (waitingPlayerToErase != state.waitingPlayers.end()) state.waitingPlayers.erase(waitingPlayerToErase); + + auto playerToErase = std::find(state.players.begin(), state.players.end(), player->GetObjectID()); + if (playerToErase != state.players.end()) state.players.erase(playerToErase); if (!self->GetNetworkVar(WavesStartedVariable)) { PlayerConfirmed(self);