aboutsummaryrefslogtreecommitdiff
path: root/src/game/Object.cpp
diff options
context:
space:
mode:
authorw12x <none@none>2008-10-27 08:41:55 -0500
committerw12x <none@none>2008-10-27 08:41:55 -0500
commite72a13c3dd10922a18d9ee59a7f62fbfb6b69c03 (patch)
treeddc7ef24aa60c78b749a6e7e4e8880f56c42e618 /src/game/Object.cpp
parent0e18e4330c0ab109080d5b7f18a3f9f83412e65a (diff)
[svn] * Allow WorldObjects to keep the grid active, and prevent it from being unloaded. This can be done through calling WorldObject::setActive(bool) from the scripting library. Note that entire instances are still unloaded if no player is present on that map to save resources. This behavior can be changed if the need arises.
--HG-- branch : trunk
Diffstat (limited to 'src/game/Object.cpp')
-rw-r--r--src/game/Object.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index 304320f8acf..4486b03d80f 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -974,6 +974,43 @@ WorldObject::WorldObject()
m_name = "";
mSemaphoreTeleport = false;
+
+ m_isActive = false;
+}
+
+WorldObject::~WorldObject()
+{
+ if(m_isActive && IsInWorld())
+ ObjectAccessor::Instance().RemoveActiveObject(this);
+}
+
+void WorldObject::setActive(bool isActive)
+{
+ // if already in the same activity state as we try to set, do nothing
+ if(isActive == m_isActive)
+ return;
+ m_isActive = isActive;
+ if(IsInWorld())
+ {
+ if(isActive)
+ ObjectAccessor::Instance().AddActiveObject(this);
+ else
+ ObjectAccessor::Instance().RemoveActiveObject(this);
+ }
+}
+
+void WorldObject::AddToWorld()
+{
+ Object::AddToWorld();
+ if(m_isActive)
+ ObjectAccessor::Instance().AddActiveObject(this);
+}
+
+void WorldObject::RemoveFromWorld()
+{
+ if(m_isActive)
+ ObjectAccessor::Instance().RemoveActiveObject(this);
+ Object::RemoveFromWorld();
}
void WorldObject::_Create( uint32 guidlow, HighGuid guidhigh, uint32 mapid )