mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
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:
parent
600c26024b
commit
4fe4aeb0d3
@ -56,7 +56,8 @@ void CNShardServer::newConnection(CNSocket* cns) {
|
|||||||
cns->setActiveKey(SOCKETKEY_E); // by default they accept keys encrypted with the default key
|
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
|
// check if the player ever sent a REQ_PC_ENTER
|
||||||
if (PlayerManager::players.find(cns) == PlayerManager::players.end())
|
if (PlayerManager::players.find(cns) == PlayerManager::players.end())
|
||||||
return;
|
return;
|
||||||
@ -76,6 +77,10 @@ void CNShardServer::killConnection(CNSocket* cns) {
|
|||||||
CNSharedData::erasePlayer(key);
|
CNSharedData::erasePlayer(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CNShardServer::killConnection(CNSocket *cns) {
|
||||||
|
_killConnection(cns);
|
||||||
|
}
|
||||||
|
|
||||||
void CNShardServer::onStep() {
|
void CNShardServer::onStep() {
|
||||||
time_t currTime = getTime();
|
time_t currTime = getTime();
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@ public:
|
|||||||
|
|
||||||
CNShardServer(uint16_t p);
|
CNShardServer(uint16_t p);
|
||||||
|
|
||||||
|
static void _killConnection(CNSocket *cns);
|
||||||
|
|
||||||
void newConnection(CNSocket* cns);
|
void newConnection(CNSocket* cns);
|
||||||
void killConnection(CNSocket* cns);
|
void killConnection(CNSocket* cns);
|
||||||
void onStep();
|
void onStep();
|
||||||
|
@ -885,6 +885,7 @@ WarpLocation PlayerManager::getRespawnPoint(Player *plr) {
|
|||||||
|
|
||||||
return best;
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerManager::isAccountInUse(int accountId) {
|
bool PlayerManager::isAccountInUse(int accountId) {
|
||||||
std::map<CNSocket*, PlayerView>::iterator it;
|
std::map<CNSocket*, PlayerView>::iterator it;
|
||||||
for (it = PlayerManager::players.begin(); it != PlayerManager::players.end(); it++)
|
for (it = PlayerManager::players.begin(); it != PlayerManager::players.end(); it++)
|
||||||
@ -897,15 +898,18 @@ bool PlayerManager::isAccountInUse(int accountId) {
|
|||||||
|
|
||||||
void PlayerManager::exitDuplicate(int accountId) {
|
void PlayerManager::exitDuplicate(int accountId) {
|
||||||
std::map<CNSocket*, PlayerView>::iterator it;
|
std::map<CNSocket*, PlayerView>::iterator it;
|
||||||
for (it = PlayerManager::players.begin(); it != PlayerManager::players.end(); it++)
|
|
||||||
{
|
// disconnect any duplicate players
|
||||||
if (it->second.plr->accountId == accountId)
|
for (it = players.begin(); it != players.end(); it++) {
|
||||||
{
|
if (it->second.plr->accountId == accountId) {
|
||||||
CNSocket* sock = it->first;
|
CNSocket* sock = it->first;
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_EXIT_DUPLICATE, resp);
|
INITSTRUCT(sP_FE2CL_REP_PC_EXIT_DUPLICATE, resp);
|
||||||
resp.iErrorCode = 0;
|
resp.iErrorCode = 0;
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_EXIT_DUPLICATE, sizeof(sP_FE2CL_REP_PC_EXIT_DUPLICATE));
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_EXIT_DUPLICATE, sizeof(sP_FE2CL_REP_PC_EXIT_DUPLICATE));
|
||||||
|
|
||||||
sock->kill();
|
sock->kill();
|
||||||
|
CNShardServer::_killConnection(sock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user