[11323] Avoid explicit use HIGHGUID_UNIT as creature high guid in guids or creature creating.

This helper change for allow have in future static spawned vehicles as `creature` table data.

Added CreatureInfo::GetHighGuid() high guid selector, and wrapper CreatureData::GetHighGuid()
for most real cases of usage. Also easy get expected guid form by CreatureData::GetObjectGuid(lowguid).

Also fixed some memory lost cases at creature spawn fail.
This commit is contained in:
VladimirMangos 2011-04-07 19:22:30 +04:00
parent 0dfcbf8051
commit ba77d85a30
16 changed files with 156 additions and 81 deletions

View file

@ -269,7 +269,7 @@ void PoolGroup<Creature>::Despawn1Object(MapPersistentState& mapState, uint32 gu
dataMapState->RemoveCreatureFromGrid(guid, data);
if (Map* dataMap = dataMapState->GetMap())
if (Creature* pCreature = dataMap->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, guid)))
if (Creature* pCreature = dataMap->GetCreature(data->GetObjectGuid(guid)))
pCreature->AddObjectToRemoveList();
}
}
@ -485,7 +485,7 @@ void PoolGroup<Creature>::ReSpawn1Object(MapPersistentState& mapState, PoolObjec
// for non-instanceable maps pool spawn can be at different map from provided mapState
if (MapPersistentState* dataMapState = mapState.GetMapId() == data->mapid ? &mapState : sMapPersistentStateMgr.GetPersistentState(data->mapid, 0))
if (Map* dataMap = dataMapState->GetMap())
if (Creature* pCreature = dataMap->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, obj->guid)))
if (Creature* pCreature = dataMap->GetCreature(data->GetObjectGuid(obj->guid)))
pCreature->GetMap()->Add(pCreature);
}
}