aboutsummaryrefslogtreecommitdiff
path: root/src/game/Player.cpp
diff options
context:
space:
mode:
authormegamage <none@none>2009-06-27 16:18:08 -0500
committermegamage <none@none>2009-06-27 16:18:08 -0500
commita363df18368dfa28412e51f40d71954f9d7a20fe (patch)
treed312c6144f92b61a9f12ab29a55281a779336b99 /src/game/Player.cpp
parent77cd4a8cb006cf80b6410523ce120b68a12ef550 (diff)
*Fix a crash caused by player saves with incorrect instance id.
--HG-- branch : trunk
Diffstat (limited to 'src/game/Player.cpp')
-rw-r--r--src/game/Player.cpp19
1 files changed, 19 insertions, 0 deletions
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);