Address players leaving Battle of Nimbus Station causing a crash that wont save (#600)

This commit is contained in:
Aaron Kimbrell 2022-06-24 15:26:09 -05:00 committed by GitHub
parent 06dc18fb49
commit 94e161df55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,8 +60,11 @@ void BaseWavesServer::BaseStartup(Entity* self) {
// Done // Done
void BaseWavesServer::BasePlayerExit(Entity* self, Entity* player) { void BaseWavesServer::BasePlayerExit(Entity* self, Entity* player) {
state.waitingPlayers.erase(std::find(state.waitingPlayers.begin(), state.waitingPlayers.end(), player->GetObjectID())); auto waitingPlayerToErase = std::find(state.waitingPlayers.begin(), state.waitingPlayers.end(), player->GetObjectID());
state.players.erase(std::find(state.players.begin(), state.players.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<bool>(WavesStartedVariable)) { if (!self->GetNetworkVar<bool>(WavesStartedVariable)) {
PlayerConfirmed(self); PlayerConfirmed(self);