diff options
author | megamage <none@none> | 2008-12-04 10:56:50 -0600 |
---|---|---|
committer | megamage <none@none> | 2008-12-04 10:56:50 -0600 |
commit | bd25d2a33b847cbf4fa3a5d3afb381da8baa3802 (patch) | |
tree | ded50bcef953cdbcc6a025ce1a2bacbff2186fd5 /src/game/Player.cpp | |
parent | 2d1905c887ba9eaa139dd450a484ed53868ec627 (diff) |
*Fix the bug that creating new instance during login causes crash.
--HG--
branch : trunk
Diffstat (limited to 'src/game/Player.cpp')
-rw-r--r-- | src/game/Player.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 278d43ebc30..184e4ae697c 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -13914,6 +13914,37 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) // load the player's map here if it's not already loaded Map *map = GetMap(); + if (!map) + { + AreaTrigger const* at = objmgr.GetGoBackTrigger(GetMapId()); + if(at) + { + SetMapId(at->target_mapId); + Relocate(at->target_X, at->target_Y, at->target_Z, GetOrientation()); + } + else + { + SetMapId(m_homebindMapId); + Relocate(m_homebindX, m_homebindY, m_homebindZ, GetOrientation()); + } + + map = GetMap(); + if(!map) + { + sLog.outError("ERROR: Player (guidlow %d) have invalid coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.",guid,GetPositionX(),GetPositionY(),GetPositionZ(),GetOrientation()); + + SetMapId(info->mapId); + Relocate(info->positionX,info->positionY,info->positionZ,0.0f); + + map = GetMap(); + if(!map) + { + sLog.outError("ERROR: Player (guidlow %d) have invalid coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.",guid,GetPositionX(),GetPositionY(),GetPositionZ(),GetOrientation()); + sLog.outError("CRASH."); + assert(false); + } + } + } // since the player may not be bound to the map yet, make sure subsequent // getmap calls won't create new maps SetInstanceId(map->GetInstanceId()); |