aboutsummaryrefslogtreecommitdiff
path: root/src/game/Object.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/Object.cpp')
-rw-r--r--src/game/Object.cpp30
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))
{