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/framework/GameSystem/Grid.h | |
parent | ccde296fd3822898e8959c009211fe880a0429f7 (diff) |
*Update active object code. By VladimirMangos.
--HG--
branch : trunk
Diffstat (limited to 'src/framework/GameSystem/Grid.h')
-rw-r--r-- | src/framework/GameSystem/Grid.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/framework/GameSystem/Grid.h b/src/framework/GameSystem/Grid.h index fffa8120883..24d7634154d 100644 --- a/src/framework/GameSystem/Grid.h +++ b/src/framework/GameSystem/Grid.h @@ -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 |