From d1169aa48bcb43e199438e52e9569ce5f6a0c39b Mon Sep 17 00:00:00 2001 From: megamage Date: Tue, 24 Mar 2009 09:06:49 -0600 Subject: *Fix a crash caused by summoncreature. --HG-- branch : trunk --- src/game/Object.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/game/Object.cpp') diff --git a/src/game/Object.cpp b/src/game/Object.cpp index d84e2b7c07e..eeedcc05188 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1623,6 +1623,11 @@ Map* WorldObject::GetMap() const return MapManager::Instance().GetMap(GetMapId(), this); } +Map* WorldObject::FindMap() const +{ + return MapManager::Instance().FindMap(GetMapId(), GetInstanceId()); +} + Map const* WorldObject::GetBaseMap() const { return MapManager::Instance().GetBaseMap(GetMapId()); @@ -1694,13 +1699,14 @@ TempSummon *Map::SummonCreature(uint32 entry, float x, float y, float z, float a TempSummon* WorldObject::SummonCreature(uint32 entry, float x, float y, float z, float ang, TempSummonType spwtype, uint32 duration) { - if(!IsInWorld()) + Map *map = FindMap(); + if(!map) return NULL; if (x == 0.0f && y == 0.0f && z == 0.0f) GetClosePoint(x, y, z, GetObjectSize()); - TempSummon *pCreature = GetMap()->SummonCreature(entry, x, y, z, ang, NULL, duration, GetTypeId() == TYPEID_UNIT ? (Unit*)this : NULL); + TempSummon *pCreature = map->SummonCreature(entry, x, y, z, ang, NULL, duration, GetTypeId() == TYPEID_UNIT ? (Unit*)this : NULL); if(!pCreature) return NULL; @@ -1817,7 +1823,6 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy pet->GetCharmInfo()->SetPetNumber(pet_number, false); pet->AIM_Initialize(); - map->Add((Creature*)pet); pet->setPowerType(POWER_MANA); -- cgit v1.2.3