Rename some classes in grid system.
Note: The naming of classes is still confusing. "cell" usually refers to class "Grid", and "grid" usually refers to class "NGrid". But it requires a lot of changes to clean this up.
This commit is contained in:
Executable → Regular
+20
-20
@@ -25,7 +25,7 @@
|
||||
#include "Map.h"
|
||||
#include "Object.h"
|
||||
|
||||
inline Cell::Cell(CellPair const& p)
|
||||
inline Cell::Cell(CellCoord const& p)
|
||||
{
|
||||
data.Part.grid_x = p.x_coord / MAX_NUMBER_OF_CELLS;
|
||||
data.Part.grid_y = p.y_coord / MAX_NUMBER_OF_CELLS;
|
||||
@@ -37,7 +37,7 @@ inline Cell::Cell(CellPair const& p)
|
||||
|
||||
template<class T, class CONTAINER>
|
||||
inline void
|
||||
Cell::Visit(const CellPair& standing_cell, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m) const
|
||||
Cell::Visit(const CellCoord& standing_cell, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m) const
|
||||
{
|
||||
if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
|
||||
return;
|
||||
@@ -50,8 +50,8 @@ Cell::Visit(const CellPair& standing_cell, TypeContainerVisitor<T, CONTAINER> &v
|
||||
}
|
||||
|
||||
// set up the cell range based on the district
|
||||
CellPair begin_cell = standing_cell;
|
||||
CellPair end_cell = standing_cell;
|
||||
CellCoord begin_cell = standing_cell;
|
||||
CellCoord end_cell = standing_cell;
|
||||
|
||||
switch (district)
|
||||
{
|
||||
@@ -119,8 +119,8 @@ Cell::Visit(const CellPair& standing_cell, TypeContainerVisitor<T, CONTAINER> &v
|
||||
{
|
||||
for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; y++)
|
||||
{
|
||||
CellPair cell_pair(x, y);
|
||||
Cell r_zone(cell_pair);
|
||||
CellCoord cellCoord(x, y);
|
||||
Cell r_zone(cellCoord);
|
||||
r_zone.data.Part.nocreate = this->data.Part.nocreate;
|
||||
m.Visit(r_zone, visitor);
|
||||
}
|
||||
@@ -168,7 +168,7 @@ inline CellArea Cell::CalculateCellArea(float x, float y, float radius)
|
||||
|
||||
template<class T, class CONTAINER>
|
||||
inline void
|
||||
Cell::Visit(const CellPair& standing_cell, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, float radius, float x_off, float y_off) const
|
||||
Cell::Visit(const CellCoord& standing_cell, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, float radius, float x_off, float y_off) const
|
||||
{
|
||||
if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
|
||||
return;
|
||||
@@ -194,8 +194,8 @@ Cell::Visit(const CellPair& standing_cell, TypeContainerVisitor<T, CONTAINER> &v
|
||||
return;
|
||||
}
|
||||
|
||||
CellPair begin_cell = standing_cell;
|
||||
CellPair end_cell = standing_cell;
|
||||
CellCoord begin_cell = standing_cell;
|
||||
CellCoord end_cell = standing_cell;
|
||||
|
||||
area.ResizeBorders(begin_cell, end_cell);
|
||||
//visit all cells, found in CalculateCellArea()
|
||||
@@ -217,11 +217,11 @@ Cell::Visit(const CellPair& standing_cell, TypeContainerVisitor<T, CONTAINER> &v
|
||||
{
|
||||
for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y)
|
||||
{
|
||||
CellPair cell_pair(x, y);
|
||||
CellCoord cellCoord(x, y);
|
||||
//lets skip standing cell since we already visited it
|
||||
if (cell_pair != standing_cell)
|
||||
if (cellCoord != standing_cell)
|
||||
{
|
||||
Cell r_zone(cell_pair);
|
||||
Cell r_zone(cellCoord);
|
||||
r_zone.data.Part.nocreate = this->data.Part.nocreate;
|
||||
m.Visit(r_zone, visitor);
|
||||
}
|
||||
@@ -231,7 +231,7 @@ Cell::Visit(const CellPair& standing_cell, TypeContainerVisitor<T, CONTAINER> &v
|
||||
|
||||
template<class T, class CONTAINER>
|
||||
inline void
|
||||
Cell::Visit(const CellPair& l, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const WorldObject &obj, float radius) const
|
||||
Cell::Visit(const CellCoord& l, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const WorldObject &obj, float radius) const
|
||||
{
|
||||
//we should increase search radius by object's radius, otherwise
|
||||
//we could have problems with huge creatures, which won't attack nearest players etc
|
||||
@@ -240,7 +240,7 @@ Cell::Visit(const CellPair& l, TypeContainerVisitor<T, CONTAINER> &visitor, Map
|
||||
|
||||
template<class T, class CONTAINER>
|
||||
inline void
|
||||
Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const CellPair& begin_cell, const CellPair& end_cell) const
|
||||
Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const CellCoord& begin_cell, const CellCoord& end_cell) const
|
||||
{
|
||||
//here is an algorithm for 'filling' circum-squared octagon
|
||||
uint32 x_shift = (uint32)ceilf((end_cell.x_coord - begin_cell.x_coord) * 0.3f - 0.5f);
|
||||
@@ -253,8 +253,8 @@ Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const Cel
|
||||
{
|
||||
for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y)
|
||||
{
|
||||
CellPair cell_pair(x, y);
|
||||
Cell r_zone(cell_pair);
|
||||
CellCoord cellCoord(x, y);
|
||||
Cell r_zone(cellCoord);
|
||||
r_zone.data.Part.nocreate = this->data.Part.nocreate;
|
||||
m.Visit(r_zone, visitor);
|
||||
}
|
||||
@@ -277,14 +277,14 @@ Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const Cel
|
||||
{
|
||||
//we visit cells symmetrically from both sides, heading from center to sides and from up to bottom
|
||||
//e.g. filling 2 trapezoids after filling central cell strip...
|
||||
CellPair cell_pair_left(x_start - step, y);
|
||||
Cell r_zone_left(cell_pair_left);
|
||||
CellCoord cellCoord_left(x_start - step, y);
|
||||
Cell r_zone_left(cellCoord_left);
|
||||
r_zone_left.data.Part.nocreate = this->data.Part.nocreate;
|
||||
m.Visit(r_zone_left, visitor);
|
||||
|
||||
//right trapezoid cell visit
|
||||
CellPair cell_pair_right(x_end + step, y);
|
||||
Cell r_zone_right(cell_pair_right);
|
||||
CellCoord cellCoord_right(x_end + step, y);
|
||||
Cell r_zone_right(cellCoord_right);
|
||||
r_zone_right.data.Part.nocreate = this->data.Part.nocreate;
|
||||
m.Visit(r_zone_right, visitor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user