Show
Ignore:
Timestamp:
11/19/08 13:38:01 (17 years ago)
Author:
yumileroy
Message:

[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.

Original author: w12x
Date: 2008-10-27 08:41:55-05:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/Object.cpp

    r119 r120  
    975975 
    976976    mSemaphoreTeleport  = false; 
     977 
     978    m_isActive          = false; 
     979} 
     980 
     981WorldObject::~WorldObject() 
     982{ 
     983    if(m_isActive && IsInWorld()) 
     984        ObjectAccessor::Instance().RemoveActiveObject(this); 
     985} 
     986 
     987void WorldObject::setActive(bool isActive) 
     988{ 
     989    // if already in the same activity state as we try to set, do nothing 
     990    if(isActive == m_isActive) 
     991        return; 
     992    m_isActive = isActive; 
     993    if(IsInWorld()) 
     994    { 
     995        if(isActive) 
     996            ObjectAccessor::Instance().AddActiveObject(this); 
     997        else 
     998            ObjectAccessor::Instance().RemoveActiveObject(this); 
     999    } 
     1000} 
     1001 
     1002void WorldObject::AddToWorld() 
     1003{ 
     1004    Object::AddToWorld(); 
     1005    if(m_isActive) 
     1006        ObjectAccessor::Instance().AddActiveObject(this); 
     1007} 
     1008 
     1009void WorldObject::RemoveFromWorld() 
     1010{ 
     1011    if(m_isActive) 
     1012        ObjectAccessor::Instance().RemoveActiveObject(this); 
     1013    Object::RemoveFromWorld(); 
    9771014} 
    9781015