Dynamically allocate the Player struct in PlayerView.

This way we're not always passing it around by value.
Note that the Player structs in CNSharedData are still
pass-by-reference. Will probably change this later.
This commit is contained in:
2020-08-25 00:02:07 +02:00
parent c5dacb4958
commit 14bc368073
7 changed files with 118 additions and 127 deletions

View File

@@ -48,11 +48,15 @@ void CNShardServer::newConnection(CNSocket* cns) {
}
void CNShardServer::killConnection(CNSocket* cns) {
// check if the player ever sent a REQ_PC_ENTER
if (PlayerManager::players.find(cns) == PlayerManager::players.end())
return;
// remove from CNSharedData
Player cachedPlr = PlayerManager::getPlayer(cns);
int64_t key = PlayerManager::getPlayer(cns)->SerialKey;
PlayerManager::removePlayer(cns);
CNSharedData::erasePlayer(cachedPlr.SerialKey);
CNSharedData::erasePlayer(key);
}
void CNShardServer::onStep() {