Properly clean up players that have been kicked as duplicates.

This should fix the issue with null pointers in PlayerManager::players.
This commit is contained in:
2020-10-02 01:37:50 +02:00
parent 600c26024b
commit 4fe4aeb0d3
3 changed files with 16 additions and 5 deletions

View File

@@ -56,7 +56,8 @@ void CNShardServer::newConnection(CNSocket* cns) {
cns->setActiveKey(SOCKETKEY_E); // by default they accept keys encrypted with the default key
}
void CNShardServer::killConnection(CNSocket* cns) {
// must be static to be called from PlayerManager::exitDuplicate()
void CNShardServer::_killConnection(CNSocket* cns) {
// check if the player ever sent a REQ_PC_ENTER
if (PlayerManager::players.find(cns) == PlayerManager::players.end())
return;
@@ -76,6 +77,10 @@ void CNShardServer::killConnection(CNSocket* cns) {
CNSharedData::erasePlayer(key);
}
void CNShardServer::killConnection(CNSocket *cns) {
_killConnection(cns);
}
void CNShardServer::onStep() {
time_t currTime = getTime();