Removed the Player pointer from CNSocket

It was a leak in the abstraction that we weren't even using that much.
This is technically a de-optimization, but it's okay since it's not a
hot code path.
This commit is contained in:
2020-12-01 19:58:34 +01:00
parent 7c5d7a70cc
commit c43a3d64fb
4 changed files with 25 additions and 25 deletions

View File

@@ -57,8 +57,6 @@ void PlayerManager::addPlayer(CNSocket* key, Player plr) {
p->viewableChunks = new std::set<Chunk*>();
p->lastHeartbeat = 0;
key->plr = p;
std::cout << getPlayerName(p) << " has joined!" << std::endl;
std::cout << players.size() << " players" << std::endl;
}
@@ -79,10 +77,9 @@ void PlayerManager::removePlayer(CNSocket* key) {
ChunkManager::removePlayerFromChunks(ChunkManager::getViewableChunks(plr->chunkPos), key);
ChunkManager::untrackPlayer(plr->chunkPos, key);
std::cout << getPlayerName(key->plr) << " has left!" << std::endl;
std::cout << getPlayerName(plr) << " has left!" << std::endl;
delete plr->viewableChunks;
key->plr = nullptr;
delete plr;
players.erase(key);
@@ -872,7 +869,8 @@ Player *PlayerManager::getPlayer(CNSocket* key) {
if (players.find(key) != players.end())
return players[key];
return nullptr;
// this should never happen
assert(false);
}
std::string PlayerManager::getPlayerName(Player *plr, bool id) {