[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

@ -1647,6 +1647,13 @@ void WorldObject::AddObjectToRemoveList()
Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime, bool asActiveObject)
{
CreatureInfo const *cinfo = ObjectMgr::GetCreatureTemplate(id);
if(!cinfo)
{
sLog.outErrorDb("WorldObject::SummonCreature: Creature (Entry: %u) not existed for summoner: %s. ", id, GetGuidStr().c_str());
return NULL;
}
TemporarySummon* pCreature = new TemporarySummon(GetObjectGuid());
Team team = TEAM_NONE;
@ -1658,7 +1665,7 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
if (x == 0.0f && y == 0.0f && z == 0.0f)
pos = CreatureCreatePos(this, GetOrientation(), CONTACT_DISTANCE, ang);
if (!pCreature->Create(GetMap()->GenerateLocalLowGuid(HIGHGUID_UNIT), pos, id, team))
if (!pCreature->Create(GetMap()->GenerateLocalLowGuid(HIGHGUID_UNIT), pos, cinfo, team))
{
delete pCreature;
return NULL;