diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/MapInstanced.cpp | 11 | ||||
-rw-r--r-- | src/game/Player.cpp | 19 | ||||
-rw-r--r-- | src/game/Player.h | 1 |
3 files changed, 21 insertions, 10 deletions
diff --git a/src/game/MapInstanced.cpp b/src/game/MapInstanced.cpp index ca106d6506c..ee668e9080a 100644 --- a/src/game/MapInstanced.cpp +++ b/src/game/MapInstanced.cpp @@ -146,16 +146,7 @@ Map* MapInstanced::GetInstance(const WorldObject* obj) return NULL; } - InstancePlayerBind *pBind = player->GetBoundInstance(GetId(), player->GetDifficulty()); - InstanceSave *pSave = pBind ? pBind->save : NULL; - if(!pBind || !pBind->perm) - { - if(Group *group = player->GetGroup()) - if(InstanceGroupBind *groupBind = group->GetBoundInstance(GetId(), player->GetDifficulty())) - pSave = groupBind->save; - } - - if(pSave) + if(InstanceSave *pSave = player->GetInstanceSave(GetId())) { if(!instanceId) { diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 7f3d173015f..55946030206 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -14565,6 +14565,12 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) } } + // In some old saves players' instance id are not correctly ordered + // This fixes the crash. But it is not needed for a new db + if(InstanceSave *pSave = GetInstanceSave(GetMapId())) + if(pSave->GetInstanceId() != GetInstanceId()) + SetInstanceId(pSave->GetInstanceId()); + // NOW player must have valid map // load the player's map here if it's not already loaded Map *map = GetMap(); @@ -15594,6 +15600,19 @@ InstancePlayerBind* Player::GetBoundInstance(uint32 mapid, uint8 difficulty) return NULL; } +InstanceSave * Player::GetInstanceSave(uint32 mapid) +{ + InstancePlayerBind *pBind = GetBoundInstance(mapid, GetDifficulty()); + InstanceSave *pSave = pBind ? pBind->save : NULL; + if(!pBind || !pBind->perm) + { + if(Group *group = GetGroup()) + if(InstanceGroupBind *groupBind = group->GetBoundInstance(mapid, GetDifficulty())) + pSave = groupBind->save; + } + return pSave; +} + void Player::UnbindInstance(uint32 mapid, uint8 difficulty, bool unload) { BoundInstancesMap::iterator itr = m_boundInstances[difficulty].find(mapid); diff --git a/src/game/Player.h b/src/game/Player.h index 6ed6a296094..7826ab7495b 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -2028,6 +2028,7 @@ class TRINITY_DLL_SPEC Player : public Unit BoundInstancesMap m_boundInstances[TOTAL_DIFFICULTIES]; InstancePlayerBind* GetBoundInstance(uint32 mapid, uint8 difficulty); BoundInstancesMap& GetBoundInstances(uint8 difficulty) { return m_boundInstances[difficulty]; } + InstanceSave * GetInstanceSave(uint32 mapid); void UnbindInstance(uint32 mapid, uint8 difficulty, bool unload = false); void UnbindInstance(BoundInstancesMap::iterator &itr, uint8 difficulty, bool unload = false); InstancePlayerBind* BindToInstance(InstanceSave *save, bool permanent, bool load = false); |