diff options
author | megamage <none@none> | 2009-02-25 20:52:20 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-02-25 20:52:20 -0600 |
commit | bf66375bc73c2b9dd7c2d26d7af25b111734c622 (patch) | |
tree | 67c3cf601faf32a03d16dfe7b02b2a938ec76ae7 /src/game/Object.cpp | |
parent | ccde296fd3822898e8959c009211fe880a0429f7 (diff) |
*Update active object code. By VladimirMangos.
--HG--
branch : trunk
Diffstat (limited to 'src/game/Object.cpp')
-rw-r--r-- | src/game/Object.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 2d19e51e76e..5551f844376 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1070,19 +1070,31 @@ WorldObject::WorldObject() m_isActive = false; } -void WorldObject::setActive(bool isActive) +void WorldObject::setActive( bool on ) { - // if already in the same activity state as we try to set, do nothing - if(isActive == m_isActive || isType(TYPEMASK_PLAYER)) + if(m_isActive==on) return; - m_isActive = isActive; - if(IsInWorld()) + bool world = IsInWorld(); + + Map* map; + if(world) { - if(isActive) - GetMap()->AddActiveObject(this); - else - GetMap()->RemoveActiveObject(this); + map = GetMap(); + if(GetTypeId() == TYPEID_UNIT) + map->Remove((Creature*)this,false); + else if(GetTypeId() == TYPEID_DYNAMICOBJECT) + map->Remove((DynamicObject*)this,false); + } + + m_isActive = on; + + if(world) + { + if(GetTypeId() == TYPEID_UNIT) + map->Add((Creature*)this); + else if(GetTypeId() == TYPEID_DYNAMICOBJECT) + map->Add((DynamicObject*)this); } } |