Core/Grid:
- Simplified CellArea calculation (Original author: SilverIce) - Removed unused code in Cell class (Original author: SilverIce) - Improve some Visit functions.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 ¬ifier)
|
||||
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 ¬ifier)
|
||||
|
||||
// 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 ¬ifier)
|
||||
inline void Map::VisitFirstFound(const float &x, const float &y, float radius, NOTIFIER ¬ifier)
|
||||
{
|
||||
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 ¬
|
||||
}
|
||||
|
||||
template<class NOTIFIER>
|
||||
inline void
|
||||
Map::VisitWorld(const float &x, const float &y, float radius, NOTIFIER ¬ifier)
|
||||
inline void Map::VisitWorld(const float &x, const float &y, float radius, NOTIFIER ¬ifier)
|
||||
{
|
||||
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 ¬ifier
|
||||
}
|
||||
|
||||
template<class NOTIFIER>
|
||||
inline void
|
||||
Map::VisitGrid(const float &x, const float &y, float radius, NOTIFIER ¬ifier)
|
||||
inline void Map::VisitGrid(const float &x, const float &y, float radius, NOTIFIER ¬ifier)
|
||||
{
|
||||
CellCoord p(Trinity::ComputeCellCoord(x, y));
|
||||
Cell cell(p);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
cell.SetNoCreate();
|
||||
|
||||
TypeContainerVisitor<NOTIFIER, GridTypeMapContainer > grid_object_notifier(notifier);
|
||||
|
||||
Reference in New Issue
Block a user