aboutsummaryrefslogtreecommitdiff
path: root/src/framework/GameSystem/NGrid.h
diff options
context:
space:
mode:
authormaximius <none@none>2009-09-27 02:24:25 -0700
committermaximius <none@none>2009-09-27 02:24:25 -0700
commitf980dd9ac6c1679caac7a41d806d65c90a02939f (patch)
treeadd2748b3fcfd38d00883789dc692c087deed77f /src/framework/GameSystem/NGrid.h
parenta635bdd0ccdf77c56c45ee1a6d456b3a2ef43ff3 (diff)
*Merge [8524] New cell search algorithm implemented. You can now choose different
visibility distances on continents, in BG/Arenas and instances. Author: Ambal *Some warning cleanup --HG-- branch : trunk
Diffstat (limited to 'src/framework/GameSystem/NGrid.h')
-rw-r--r--src/framework/GameSystem/NGrid.h38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/framework/GameSystem/NGrid.h b/src/framework/GameSystem/NGrid.h
index 126703febd2..6ba5d10ffc1 100644
--- a/src/framework/GameSystem/NGrid.h
+++ b/src/framework/GameSystem/NGrid.h
@@ -81,8 +81,19 @@ class TRINITY_DLL_DECL NGrid
i_GridInfo = GridInfo(expiry, unload);
}
- const GridType& operator()(unsigned short x, unsigned short y) const { return i_cells[x][y]; }
- GridType& operator()(unsigned short x, unsigned short y) { return i_cells[x][y]; }
+ const GridType& operator()(unsigned short x, unsigned short y) const
+ {
+ ASSERT(x < N);
+ ASSERT(y < N);
+ return i_cells[x][y];
+ }
+
+ GridType& operator()(unsigned short x, unsigned short y)
+ {
+ ASSERT(x < N);
+ ASSERT(y < N);
+ return i_cells[x][y];
+ }
const uint32& GetGridId(void) const { return i_gridId; }
void SetGridId(const uint32 id) const { i_gridId = id; }
@@ -110,24 +121,24 @@ class TRINITY_DLL_DECL NGrid
template<class SPECIFIC_OBJECT> void AddWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl)
{
- i_cells[x][y].AddWorldObject(obj, hdl);
+ getGridType(x, y).AddWorldObject(obj, hdl);
}
template<class SPECIFIC_OBJECT> void RemoveWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl)
{
- i_cells[x][y].RemoveWorldObject(obj, hdl);
+ getGridType(x, y).RemoveWorldObject(obj, hdl);
}
template<class T, class TT> void Visit(TypeContainerVisitor<T, TypeMapContainer<TT> > &visitor)
{
for(unsigned int x=0; x < N; ++x)
for(unsigned int y=0; y < N; ++y)
- i_cells[x][y].Visit(visitor);
+ getGridType(x, y).Visit(visitor);
}
template<class T, class TT> void Visit(const uint32 &x, const uint32 &y, TypeContainerVisitor<T, TypeMapContainer<TT> > &visitor)
{
- i_cells[x][y].Visit(visitor);
+ getGridType(x, y).Visit(visitor);
}
unsigned int ActiveObjectsInGrid(void) const
@@ -141,26 +152,33 @@ class TRINITY_DLL_DECL NGrid
template<class SPECIFIC_OBJECT> const SPECIFIC_OBJECT* GetGridObject(const uint32 x, const uint32 y, OBJECT_HANDLE hdl) const
{
- return i_cells[x][y].template GetGridObject<SPECIFIC_OBJECT>(hdl);
+ return getGridType(x, y).template GetGridObject<SPECIFIC_OBJECT>(hdl);
}
template<class SPECIFIC_OBJECT> SPECIFIC_OBJECT* GetGridObject(const uint32 x, const uint32 y, OBJECT_HANDLE hdl)
{
- return i_cells[x][y].template GetGridObject<SPECIFIC_OBJECT>(hdl);
+ return getGridType(x, y).template GetGridObject<SPECIFIC_OBJECT>(hdl);
}
template<class SPECIFIC_OBJECT> bool AddGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl)
{
- return i_cells[x][y].AddGridObject(hdl, obj);
+ return getGridType(x, y).AddGridObject(hdl, obj);
}
template<class SPECIFIC_OBJECT> bool RemoveGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl)
{
- return i_cells[x][y].RemoveGridObject(obj, hdl);
+ return getGridType(x, y).RemoveGridObject(obj, hdl);
}
private:
+ GridType& getGridType(const uint32& x, const uint32& y)
+ {
+ ASSERT(x < N);
+ ASSERT(y < N);
+ return i_cells[x][y];
+ }
+
uint32 i_gridId;
GridInfo i_GridInfo;
GridReference<NGrid<N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES, ThreadModel> > i_Reference;