*Update active object code. By VladimirMangos.
--HG-- branch : trunk
This commit is contained in:
@@ -105,7 +105,7 @@ class TRINITY_DLL_DECL Grid
|
||||
|
||||
/** Returns the number of object within the grid.
|
||||
*/
|
||||
unsigned int ActiveObjectsInGrid(void) const { return i_objects.template Count<ACTIVE_OBJECT>(); }
|
||||
unsigned int ActiveObjectsInGrid(void) const { return m_activeGridObjects.size()+i_objects.template Count<ACTIVE_OBJECT>(); }
|
||||
|
||||
/** Accessors: Returns a specific type of object in the GRID_OBJECT_TYPES
|
||||
*/
|
||||
@@ -114,11 +114,21 @@ class TRINITY_DLL_DECL Grid
|
||||
|
||||
/** Inserts a container type object into the grid.
|
||||
*/
|
||||
template<class SPECIFIC_OBJECT> bool AddGridObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) { return i_container.template insert<SPECIFIC_OBJECT>(hdl, obj); }
|
||||
template<class SPECIFIC_OBJECT> bool AddGridObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl)
|
||||
{
|
||||
if(obj->isActiveObject())
|
||||
m_activeGridObjects.insert(obj);
|
||||
return i_container.template insert<SPECIFIC_OBJECT>(hdl, obj);
|
||||
}
|
||||
|
||||
/** Removes a containter type object from the grid
|
||||
*/
|
||||
template<class SPECIFIC_OBJECT> bool RemoveGridObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) { return i_container.template remove<SPECIFIC_OBJECT>(obj, hdl); }
|
||||
template<class SPECIFIC_OBJECT> bool RemoveGridObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl)
|
||||
{
|
||||
if(obj->isActiveObject())
|
||||
m_activeGridObjects.erase(obj);
|
||||
return i_container.template remove<SPECIFIC_OBJECT>(obj, hdl);
|
||||
}
|
||||
|
||||
bool NoWorldObjectInGrid() const
|
||||
{
|
||||
@@ -136,6 +146,8 @@ class TRINITY_DLL_DECL Grid
|
||||
|
||||
TypeMapContainer<GRID_OBJECT_TYPES> i_container;
|
||||
TypeMapContainer<WORLD_OBJECT_TYPES> i_objects;
|
||||
typedef std::set<void*> ActiveGridObjects;
|
||||
ActiveGridObjects m_activeGridObjects;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -32,17 +32,23 @@ class GridInfo
|
||||
{
|
||||
public:
|
||||
GridInfo() : i_timer(0) {}
|
||||
GridInfo(time_t expiry, bool unload = true ) : i_timer(expiry), i_unloadflag(unload) {}
|
||||
GridInfo(time_t expiry, bool unload = true ) : i_timer(expiry), i_unloadExplicitLock(!unload) {}
|
||||
const TimeTracker& getTimeTracker() const { return i_timer; }
|
||||
bool getUnloadFlag() const { return i_unloadflag; }
|
||||
void setUnloadFlag( bool pFlag) { i_unloadflag = pFlag; }
|
||||
bool getUnloadLock() const { return i_unloadActiveLockCount || i_unloadExplicitLock || i_unloadReferenceLock; }
|
||||
void setUnloadExplicitLock( bool on ) { i_unloadExplicitLock = on; }
|
||||
void setUnloadReferenceLock( bool on ) { i_unloadReferenceLock = on; }
|
||||
void incUnloadActiveLock() { ++i_unloadActiveLockCount; }
|
||||
void decUnloadActiveLock() { if(i_unloadActiveLockCount) --i_unloadActiveLockCount; }
|
||||
|
||||
void setTimer(const TimeTracker& pTimer) { i_timer = pTimer; }
|
||||
void ResetTimeTracker(time_t interval) { i_timer.Reset(interval); }
|
||||
void UpdateTimeTracker(time_t diff) { i_timer.Update(diff); }
|
||||
|
||||
private:
|
||||
TimeTracker i_timer;
|
||||
bool i_unloadflag;
|
||||
uint16 i_unloadActiveLockCount : 16; // lock from active object spawn points (prevent clone loading)
|
||||
bool i_unloadExplicitLock : 1; // explicit manual lock or config setting
|
||||
bool i_unloadReferenceLock : 1; // lock from instance map copy
|
||||
};
|
||||
|
||||
typedef enum
|
||||
@@ -92,8 +98,11 @@ class TRINITY_DLL_DECL NGrid
|
||||
|
||||
GridInfo* getGridInfoRef() { return &i_GridInfo; }
|
||||
const TimeTracker& getTimeTracker() const { return i_GridInfo.getTimeTracker(); }
|
||||
bool getUnloadFlag() const { return i_GridInfo.getUnloadFlag(); }
|
||||
void setUnloadFlag( bool pFlag) { i_GridInfo.setUnloadFlag(pFlag); }
|
||||
bool getUnloadLock() const { return i_GridInfo.getUnloadLock(); }
|
||||
void setUnloadExplicitLock( bool on ) { i_GridInfo.setUnloadExplicitLock(on); }
|
||||
void setUnloadReferenceLock( bool on ) { i_GridInfo.setUnloadReferenceLock(on); }
|
||||
void incUnloadActiveLock() { i_GridInfo.incUnloadActiveLock(); }
|
||||
void decUnloadActiveLock() { i_GridInfo.decUnloadActiveLock(); }
|
||||
void ResetTimeTracker(time_t interval) { i_GridInfo.ResetTimeTracker(interval); }
|
||||
void UpdateTimeTracker(time_t diff) { i_GridInfo.UpdateTimeTracker(diff); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user