[11017] Finaly restore non-crashing non-in-world logout.

For example at close client with far teleport loading screen.
This commit is contained in:
VladimirMangos 2011-01-16 19:57:53 +03:00
parent 805d62bef1
commit 784c0ca781
6 changed files with 21 additions and 17 deletions

View file

@ -476,9 +476,18 @@ void WorldSession::LogoutPlayer(bool Save)
// the player may not be in the world when logging out
// e.g if he got disconnected during a transfer to another map
// calls to GetMap in this case may cause crashes
Map* _map = _player->GetMap();
_map->Remove(_player, true);
SetPlayer(NULL); // deleted in Remove call
if (_player->IsInWorld())
{
Map* _map = _player->GetMap();
_map->Remove(_player, true);
}
else
{
_player->CleanupsBeforeDelete();
Map::DeleteFromWorld(_player);
}
SetPlayer(NULL); // deleted in Remove/DeleteFromWorld call
///- Send the 'logout complete' packet to the client
WorldPacket data( SMSG_LOGOUT_COMPLETE, 0 );