Make sure the current race is cleared when leaving an IZ

This commit is contained in:
2020-12-28 17:51:57 +01:00
parent 07a930fe1c
commit 55431362a7
2 changed files with 14 additions and 0 deletions

View File

@@ -101,6 +101,10 @@ void PlayerManager::removePlayer(CNSocket* key) {
it++;
}
// remove the player's ongoing race, if any
if (RacingManager::EPRaces.find(key) != RacingManager::EPRaces.end())
RacingManager::EPRaces.erase(key);
std::cout << players.size() << " players" << std::endl;
}
@@ -171,6 +175,10 @@ void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z, uint64_t I
// post-warp: check if the source instance has no more players in it and delete it if so
ChunkManager::destroyInstanceIfEmpty(fromInstance);
// clean up EPRaces if we were likely in an IZ
if (fromInstance != INSTANCE_OVERWORLD
&& RacingManager::EPRaces.find(sock) != RacingManager::EPRaces.end())
RacingManager::EPRaces.erase(sock);
}
void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z) {