diff options
author | megamage <none@none> | 2009-03-25 21:32:34 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-03-25 21:32:34 -0600 |
commit | 1c2eab41105ab48670228c6cd1630ee6eab15815 (patch) | |
tree | e2ef0969ed3db851881c8db524695dd249ddaf5f /src/game/Object.cpp | |
parent | ebf53a4820de1978a9ad8a6743255d72ae7592e0 (diff) |
*Fix a crash caused by pet.
*Make pet class derived from guardian class.
--HG--
branch : trunk
Diffstat (limited to 'src/game/Object.cpp')
-rw-r--r-- | src/game/Object.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 2b15fb523b8..20b2cf9eb12 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1156,33 +1156,35 @@ void WorldObject::SetWorldObject(bool on) void WorldObject::setActive( bool on ) { - if(m_isActive==on) + if(m_isActive == on) return; if(GetTypeId() == TYPEID_PLAYER) return; - bool world = IsInWorld(); + m_isActive = on; - Map* map; - if(world) - { - map = GetMap(); - if(GetTypeId() == TYPEID_UNIT) - map->RemoveFromActive((Creature*)this); - else if(GetTypeId() == TYPEID_DYNAMICOBJECT) - map->RemoveFromActive((DynamicObject*)this); - } + if(!IsInWorld()) + return; - m_isActive = on; + Map *map = FindMap(); + if(!map) + return; - if(world) + if(on) { if(GetTypeId() == TYPEID_UNIT) map->AddToActive((Creature*)this); else if(GetTypeId() == TYPEID_DYNAMICOBJECT) map->AddToActive((DynamicObject*)this); } + else + { + if(GetTypeId() == TYPEID_UNIT) + map->RemoveFromActive((Creature*)this); + else if(GetTypeId() == TYPEID_DYNAMICOBJECT) + map->RemoveFromActive((DynamicObject*)this); + } } void WorldObject::_Create( uint32 guidlow, HighGuid guidhigh, uint32 mapid, uint32 phaseMask ) @@ -1767,7 +1769,7 @@ Vehicle* WorldObject::SummonVehicle(uint32 entry, float x, float y, float z, flo Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 duration) { - Pet* pet = new Pet(petType); + Pet* pet = new Pet(this, petType); if(petType == SUMMON_PET && pet->LoadPetFromDB(this, entry)) { |