mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 09:17:36 +01:00
*Fix a crash caused by player saves with incorrect instance id.
--HG-- branch : trunk
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user