mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-04 22:40:05 +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
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
|
@ -21,6 +21,8 @@ public:
|
||||
|
||||
CNShardServer(uint16_t p);
|
||||
|
||||
static void _killConnection(CNSocket *cns);
|
||||
|
||||
void newConnection(CNSocket* cns);
|
||||
void killConnection(CNSocket* cns);
|
||||
void onStep();
|
||||
|
@ -885,6 +885,7 @@ WarpLocation PlayerManager::getRespawnPoint(Player *plr) {
|
||||
|
||||
return best;
|
||||
}
|
||||
|
||||
bool PlayerManager::isAccountInUse(int accountId) {
|
||||
std::map<CNSocket*, PlayerView>::iterator 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) {
|
||||
std::map<CNSocket*, PlayerView>::iterator it;
|
||||
for (it = PlayerManager::players.begin(); it != PlayerManager::players.end(); it++)
|
||||
{
|
||||
if (it->second.plr->accountId == accountId)
|
||||
{
|
||||
|
||||
// disconnect any duplicate players
|
||||
for (it = players.begin(); it != players.end(); it++) {
|
||||
if (it->second.plr->accountId == accountId) {
|
||||
CNSocket* sock = it->first;
|
||||
|
||||
INITSTRUCT(sP_FE2CL_REP_PC_EXIT_DUPLICATE, resp);
|
||||
resp.iErrorCode = 0;
|
||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_EXIT_DUPLICATE, sizeof(sP_FE2CL_REP_PC_EXIT_DUPLICATE));
|
||||
|
||||
sock->kill();
|
||||
CNShardServer::_killConnection(sock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user