aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Maps
diff options
context:
space:
mode:
authorkaelima <kaelima@live.se>2011-10-19 17:40:44 +0100
committerkaelima <kaelima@live.se>2011-10-19 17:40:44 +0100
commitbe0b2fcf97404af624e538be96ea05892d3f41be (patch)
tree8849332a9a8930226fea13b4e5188f4b521a70c3 /src/server/game/Maps
parentd7e019072677dd098c491986ebe8c48259d20155 (diff)
Core/Grid:
- Simplified CellArea calculation (Original author: SilverIce) - Removed unused code in Cell class (Original author: SilverIce) - Improve some Visit functions.
Diffstat (limited to 'src/server/game/Maps')
-rwxr-xr-xsrc/server/game/Maps/Map.cpp27
-rwxr-xr-xsrc/server/game/Maps/Map.h19
2 files changed, 14 insertions, 32 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 485b1ba164f..425a31fc38a 100755
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -484,22 +484,16 @@ bool Map::IsGridLoaded(const GridCoord &p) const
void Map::VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor<Trinity::ObjectUpdater, GridTypeMapContainer> &gridVisitor, TypeContainerVisitor<Trinity::ObjectUpdater, WorldTypeMapContainer> &worldVisitor)
{
- CellCoord standing_cell(Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY()));
-
- // Check for correctness of standing_cell, it also avoids problems with update_cell
- if (!standing_cell.IsCoordValid())
+ // Check for valid position
+ if (!obj->IsPositionValid())
return;
- // the overloaded operators handle range checking
- // so there's no need for range checking inside the loop
- CellCoord begin_cell(standing_cell), end_cell(standing_cell);
- //lets update mobs/objects in ALL visible cells around object!
- CellArea area = Cell::CalculateCellArea(*obj, obj->GetGridActivationRange());
- area.ResizeBorders(begin_cell, end_cell);
+ // Update mobs/objects in ALL visible cells around object!
+ CellArea area = Cell::CalculateCellArea(obj->GetPositionX(), obj->GetPositionY(), obj->GetGridActivationRange());
- for (uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x)
+ for (uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x)
{
- for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y)
+ for (uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y)
{
// marked cells are those that have been visited
// don't visit the same cell twice
@@ -510,9 +504,8 @@ void Map::VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor<Trinity::Obj
markCell(cell_id);
CellCoord pair(x, y);
Cell cell(pair);
- cell.data.Part.reserved = CENTER_DISTRICT;
- cell.Visit(pair, gridVisitor, *this);
- cell.Visit(pair, worldVisitor, *this);
+ Visit(cell, gridVisitor);
+ Visit(cell, worldVisitor);
}
}
}
@@ -1841,7 +1834,7 @@ bool Map::IsInWater(float x, float y, float pZ, LiquidData* data) const
LiquidData liquid_status;
LiquidData* liquid_ptr = data ? data : &liquid_status;
if (getLiquidStatus(x, y, pZ, MAP_ALL_LIQUIDS, liquid_ptr))
- return true;
+ return true;
}
return false;
}
@@ -1880,7 +1873,6 @@ const char* Map::GetMapName() const
void Map::UpdateObjectVisibility(WorldObject* obj, Cell cell, CellCoord cellpair)
{
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::VisibleChangesNotifier notifier(*obj);
TypeContainerVisitor<Trinity::VisibleChangesNotifier, WorldTypeMapContainer > player_notifier(notifier);
@@ -1891,7 +1883,6 @@ void Map::UpdateObjectsVisibilityFor(Player* player, Cell cell, CellCoord cellpa
{
Trinity::VisibleNotifier notifier(*player);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
TypeContainerVisitor<Trinity::VisibleNotifier, WorldTypeMapContainer > world_notifier(notifier);
TypeContainerVisitor<Trinity::VisibleNotifier, GridTypeMapContainer > grid_notifier(notifier);
diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h
index 2247908fb08..a8386360ae2 100755
--- a/src/server/game/Maps/Map.h
+++ b/src/server/game/Maps/Map.h
@@ -615,8 +615,7 @@ class BattlegroundMap : public Map
};
template<class T, class CONTAINER>
-inline void
-Map::Visit(const Cell& cell, TypeContainerVisitor<T, CONTAINER> &visitor)
+inline void Map::Visit(Cell const& cell, TypeContainerVisitor<T, CONTAINER>& visitor)
{
const uint32 x = cell.GridX();
const uint32 y = cell.GridY();
@@ -631,12 +630,10 @@ Map::Visit(const Cell& cell, TypeContainerVisitor<T, CONTAINER> &visitor)
}
template<class NOTIFIER>
-inline void
-Map::VisitAll(const float &x, const float &y, float radius, NOTIFIER &notifier)
+inline void Map::VisitAll(float const& x, float const& y, float radius, NOTIFIER& notifier)
{
CellCoord p(Trinity::ComputeCellCoord(x, y));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier);
@@ -647,12 +644,10 @@ Map::VisitAll(const float &x, const float &y, float radius, NOTIFIER &notifier)
// should be used with Searcher notifiers, tries to search world if nothing found in grid
template<class NOTIFIER>
-inline void
-Map::VisitFirstFound(const float &x, const float &y, float radius, NOTIFIER &notifier)
+inline void Map::VisitFirstFound(const float &x, const float &y, float radius, NOTIFIER &notifier)
{
CellCoord p(Trinity::ComputeCellCoord(x, y));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier);
@@ -665,12 +660,10 @@ Map::VisitFirstFound(const float &x, const float &y, float radius, NOTIFIER &not
}
template<class NOTIFIER>
-inline void
-Map::VisitWorld(const float &x, const float &y, float radius, NOTIFIER &notifier)
+inline void Map::VisitWorld(const float &x, const float &y, float radius, NOTIFIER &notifier)
{
CellCoord p(Trinity::ComputeCellCoord(x, y));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier);
@@ -678,12 +671,10 @@ Map::VisitWorld(const float &x, const float &y, float radius, NOTIFIER &notifier
}
template<class NOTIFIER>
-inline void
-Map::VisitGrid(const float &x, const float &y, float radius, NOTIFIER &notifier)
+inline void Map::VisitGrid(const float &x, const float &y, float radius, NOTIFIER &notifier)
{
CellCoord p(Trinity::ComputeCellCoord(x, y));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
TypeContainerVisitor<NOTIFIER, GridTypeMapContainer > grid_object_notifier(notifier);