aboutsummaryrefslogtreecommitdiff
path: root/src/game/Map.h
diff options
context:
space:
mode:
authormegamage <none@none>2008-12-12 23:54:02 -0600
committermegamage <none@none>2008-12-12 23:54:02 -0600
commit0ea36ed76eff53d1e8eea8f57b2f5f9feedb8932 (patch)
tree546c94a3aadaa41ad407fc09a4bb215adcd5d3a8 /src/game/Map.h
parent032f5bc87de643b9946bebab1afeef27c23840cf (diff)
*Move cell visit into functions.
--HG-- branch : trunk
Diffstat (limited to 'src/game/Map.h')
-rw-r--r--src/game/Map.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/game/Map.h b/src/game/Map.h
index 2fb2f4f31e5..201e69904d8 100644
--- a/src/game/Map.h
+++ b/src/game/Map.h
@@ -253,6 +253,9 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O
typedef MapRefManager PlayerList;
PlayerList const& GetPlayers() const { return m_mapRefManager; }
template<class T> void SwitchGridContainers(T* obj, bool active);
+ template<class NOTIFIER> void VisitAll(const float &x, const float &y, float radius, NOTIFIER &notifier);
+ template<class NOTIFIER> void VisitWorld(const float &x, const float &y, float radius, NOTIFIER &notifier);
+ template<class NOTIFIER> void VisitGrid(const float &x, const float &y, float radius, NOTIFIER &notifier);
private:
void LoadVMap(int pX, int pY);
void LoadMap(uint32 mapid, uint32 instanceid, int x,int y);
@@ -407,4 +410,51 @@ Map::Visit(const CellLock<LOCK_TYPE> &cell, TypeContainerVisitor<T, CONTAINER> &
getNGrid(x, y)->Visit(cell_x, cell_y, visitor);
}
}
+
+template<class NOTIFIER>
+inline void
+Map::VisitAll(const float &x, const float &y, float radius, NOTIFIER &notifier)
+{
+ float x_off, y_off;
+ CellPair p(Trinity::ComputeCellPair(x, y, x_off, y_off));
+ Cell cell(p);
+ cell.data.Part.reserved = ALL_DISTRICT;
+ cell.SetNoCreate();
+ CellLock<GridReadGuard> cell_lock(cell, p);
+
+ TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier);
+ cell_lock->Visit(cell_lock, world_object_notifier, *this, radius, x_off, y_off);
+ TypeContainerVisitor<NOTIFIER, GridTypeMapContainer > grid_object_notifier(notifier);
+ cell_lock->Visit(cell_lock, grid_object_notifier, *this, radius, x_off, y_off);
+}
+
+template<class NOTIFIER>
+inline void
+Map::VisitWorld(const float &x, const float &y, float radius, NOTIFIER &notifier)
+{
+ float x_off, y_off;
+ CellPair p(Trinity::ComputeCellPair(x, y, x_off, y_off));
+ Cell cell(p);
+ cell.data.Part.reserved = ALL_DISTRICT;
+ cell.SetNoCreate();
+ CellLock<GridReadGuard> cell_lock(cell, p);
+
+ TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier);
+ cell_lock->Visit(cell_lock, world_object_notifier, *this, radius, x_off, y_off);
+}
+
+template<class NOTIFIER>
+inline void
+Map::VisitGrid(const float &x, const float &y, float radius, NOTIFIER &notifier)
+{
+ float x_off, y_off;
+ CellPair p(Trinity::ComputeCellPair(x, y, x_off, y_off));
+ Cell cell(p);
+ cell.data.Part.reserved = ALL_DISTRICT;
+ cell.SetNoCreate();
+ CellLock<GridReadGuard> cell_lock(cell, p);
+
+ TypeContainerVisitor<NOTIFIER, GridTypeMapContainer > grid_object_notifier(notifier);
+ cell_lock->Visit(cell_lock, grid_object_notifier, *this, radius, x_off, y_off);
+}
#endif