diff --git a/src/game/Map.cpp b/src/game/Map.cpp index dffa23cb8..4a5b50a1b 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -182,14 +182,6 @@ void Map::RemoveFromGrid(Creature* obj, NGridType *grid, Cell const& cell) } } -template -void Map::DeleteFromWorld(T* obj) -{ - // Note: In case resurrectable corpse and pet its removed from global lists in own destructor - delete obj; -} - -template<> void Map::DeleteFromWorld(Player* pl) { sObjectAccessor.RemoveObject(pl); @@ -660,7 +652,9 @@ Map::Remove(T *obj, bool remove) // if option set then object already saved at this moment if(!sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATLY)) obj->SaveRespawnTime(); - DeleteFromWorld(obj); + + // Note: In case resurrectable corpse and pet its removed from global lists in own destructor + delete obj; } } diff --git a/src/game/Map.h b/src/game/Map.h index 91a0285ed..30816e9c5 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -103,6 +103,8 @@ class MANGOS_DLL_SPEC Map : public GridRefManager template void Add(T *); template void Remove(T *, bool); + static void DeleteFromWorld(Player* player); // player object will deleted at call + virtual void Update(const uint32&); void MessageBroadcast(Player *, WorldPacket *, bool to_self); @@ -320,9 +322,6 @@ class MANGOS_DLL_SPEC Map : public GridRefManager template void RemoveFromGrid(T*, NGridType *, Cell const&); - - template - void DeleteFromWorld(T*); }; class MANGOS_DLL_SPEC InstanceMap : public Map diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index 9b69675c0..f7b06033f 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -81,6 +81,8 @@ void WorldSession::HandleMoveWorldportAckOpcode() " (map:%u, x:%f, y:%f, z:%f) Trying to port him to his previous place..", GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z); + GetPlayer()->SetSemaphoreTeleportFar(false); + // Teleport to previous place, if cannot be ported back TP to homebind place if (!GetPlayer()->TeleportTo(old_loc)) { diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 27a83d88c..b89de5e3e 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -17049,7 +17049,7 @@ void Player::SaveToDB() ss << uint32(m_atLoginFlags) << ", "; - ss << GetZoneId() << ", "; + ss << (IsInWorld() ? GetZoneId() : GetCachedZoneId()) << ", "; ss << (uint64)m_deathExpireTime << ", '"; diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 2f52e684a..f7063d554 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -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 ); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 743d481ed..fedce96d4 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11016" + #define REVISION_NR "11017" #endif // __REVISION_NR_H__