diff options
| author | megamage <none@none.none> | 2011-10-18 10:53:34 -0400 |
|---|---|---|
| committer | megamage <none@none.none> | 2011-10-18 10:53:34 -0400 |
| commit | c29ff410015be2ef8c8c55ba3015940962ff56c3 (patch) | |
| tree | d2b5b36bbf32bbb695ef0f1456a461294609fd06 /src/server/game/Grids | |
| parent | e3f8588a227cbf9108f396131a199d75868bf539 (diff) | |
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.
Diffstat (limited to 'src/server/game/Grids')
| -rwxr-xr-x | src/server/game/Grids/Cells/Cell.h | 16 | ||||
| -rw-r--r--[-rwxr-xr-x] | src/server/game/Grids/Cells/CellImpl.h | 40 | ||||
| -rw-r--r--[-rwxr-xr-x] | src/server/game/Grids/GridDefines.h | 16 | ||||
| -rwxr-xr-x | src/server/game/Grids/Notifiers/GridNotifiers.cpp | 2 | ||||
| -rwxr-xr-x | src/server/game/Grids/Notifiers/GridNotifiers.h | 4 | ||||
| -rwxr-xr-x | src/server/game/Grids/ObjectGridLoader.cpp | 30 | ||||
| -rwxr-xr-x | src/server/game/Grids/ObjectGridLoader.h | 2 |
7 files changed, 55 insertions, 55 deletions
diff --git a/src/server/game/Grids/Cells/Cell.h b/src/server/game/Grids/Cells/Cell.h index 56c4d96e427..ba396106f46 100755 --- a/src/server/game/Grids/Cells/Cell.h +++ b/src/server/game/Grids/Cells/Cell.h @@ -49,7 +49,7 @@ struct CellArea CellArea(int right, int left, int upper, int lower) : right_offset(right), left_offset(left), upper_offset(upper), lower_offset(lower) {} bool operator!() const { return !right_offset && !left_offset && !upper_offset && !lower_offset; } - void ResizeBorders(CellPair& begin_cell, CellPair& end_cell) const + void ResizeBorders(CellCoord& begin_cell, CellCoord& end_cell) const { begin_cell.dec_x(left_offset); begin_cell.dec_y(lower_offset); @@ -67,7 +67,7 @@ struct Cell { Cell() { data.All = 0; } Cell(const Cell &cell) { data.All = cell.data.All; } - explicit Cell(CellPair const& p); + explicit Cell(CellCoord const& p); void operator|=(Cell &cell) { @@ -131,9 +131,9 @@ struct Cell bool NoCreate() const { return data.Part.nocreate; } void SetNoCreate() { data.Part.nocreate = 1; } - CellPair cellPair() const + CellCoord GetCellCoord() const { - return CellPair( + return CellCoord( data.Part.grid_x*MAX_NUMBER_OF_CELLS+data.Part.cell_x, data.Part.grid_y*MAX_NUMBER_OF_CELLS+data.Part.cell_y); } @@ -160,15 +160,15 @@ struct Cell uint32 All; } data; - template<class T, class CONTAINER> void Visit(const CellPair&, TypeContainerVisitor<T, CONTAINER> &visitor, Map &) const; - template<class T, class CONTAINER> void Visit(const CellPair&, TypeContainerVisitor<T, CONTAINER> &visitor, Map &, const WorldObject&, float) const; - template<class T, class CONTAINER> void Visit(const CellPair&, TypeContainerVisitor<T, CONTAINER> &visitor, Map &, float, float, float) const; + template<class T, class CONTAINER> void Visit(const CellCoord&, TypeContainerVisitor<T, CONTAINER> &visitor, Map &) const; + template<class T, class CONTAINER> void Visit(const CellCoord&, TypeContainerVisitor<T, CONTAINER> &visitor, Map &, const WorldObject&, float) const; + template<class T, class CONTAINER> void Visit(const CellCoord&, TypeContainerVisitor<T, CONTAINER> &visitor, Map &, float, float, float) const; static CellArea CalculateCellArea(const WorldObject &obj, float radius); static CellArea CalculateCellArea(float x, float y, float radius); private: - template<class T, class CONTAINER> void VisitCircle(TypeContainerVisitor<T, CONTAINER> &, Map &, const CellPair&, const CellPair&) const; + template<class T, class CONTAINER> void VisitCircle(TypeContainerVisitor<T, CONTAINER> &, Map &, const CellCoord&, const CellCoord&) const; }; #endif diff --git a/src/server/game/Grids/Cells/CellImpl.h b/src/server/game/Grids/Cells/CellImpl.h index 77cf6a0b5c0..18337f8fadc 100755..100644 --- a/src/server/game/Grids/Cells/CellImpl.h +++ b/src/server/game/Grids/Cells/CellImpl.h @@ -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); } diff --git a/src/server/game/Grids/GridDefines.h b/src/server/game/Grids/GridDefines.h index 0bd5a2db71c..70d38720005 100755..100644 --- a/src/server/game/Grids/GridDefines.h +++ b/src/server/game/Grids/GridDefines.h @@ -139,8 +139,8 @@ bool operator!=(const CoordPair<LIMIT> &p1, const CoordPair<LIMIT> &p2) return !(p1 == p2); } -typedef CoordPair<MAX_NUMBER_OF_GRIDS> GridPair; -typedef CoordPair<TOTAL_NUMBER_OF_CELLS_PER_MAP> CellPair; +typedef CoordPair<MAX_NUMBER_OF_GRIDS> GridCoord; +typedef CoordPair<TOTAL_NUMBER_OF_CELLS_PER_MAP> CellCoord; namespace Trinity { @@ -156,17 +156,17 @@ namespace Trinity return RET_TYPE(x_val, y_val); } - inline GridPair ComputeGridPair(float x, float y) + inline GridCoord ComputeGridCoord(float x, float y) { - return Compute<GridPair, CENTER_GRID_ID>(x, y, CENTER_GRID_OFFSET, SIZE_OF_GRIDS); + return Compute<GridCoord, CENTER_GRID_ID>(x, y, CENTER_GRID_OFFSET, SIZE_OF_GRIDS); } - inline CellPair ComputeCellPair(float x, float y) + inline CellCoord ComputeCellCoord(float x, float y) { - return Compute<CellPair, CENTER_GRID_CELL_ID>(x, y, CENTER_GRID_CELL_OFFSET, SIZE_OF_GRID_CELL); + return Compute<CellCoord, CENTER_GRID_CELL_ID>(x, y, CENTER_GRID_CELL_OFFSET, SIZE_OF_GRID_CELL); } - inline CellPair ComputeCellPair(float x, float y, float &x_off, float &y_off) + inline CellCoord ComputeCellCoord(float x, float y, float &x_off, float &y_off) { double x_offset = (double(x) - CENTER_GRID_CELL_OFFSET)/SIZE_OF_GRID_CELL; double y_offset = (double(y) - CENTER_GRID_CELL_OFFSET)/SIZE_OF_GRID_CELL; @@ -175,7 +175,7 @@ namespace Trinity int y_val = int(y_offset + CENTER_GRID_CELL_ID + 0.5f); x_off = (float(x_offset) - x_val + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL; y_off = (float(y_offset) - y_val + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL; - return CellPair(x_val, y_val); + return CellCoord(x_val, y_val); } inline void NormalizeMapCoord(float &c) diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.cpp b/src/server/game/Grids/Notifiers/GridNotifiers.cpp index dc938859e92..0377713a520 100755 --- a/src/server/game/Grids/Notifiers/GridNotifiers.cpp +++ b/src/server/game/Grids/Notifiers/GridNotifiers.cpp @@ -215,7 +215,7 @@ void DelayedUnitRelocation::Visit(PlayerMapType &m) if (player != viewPoint && !viewPoint->IsPositionValid()) continue; - CellPair pair2(Trinity::ComputeCellPair(viewPoint->GetPositionX(), viewPoint->GetPositionY())); + CellCoord pair2(Trinity::ComputeCellCoord(viewPoint->GetPositionX(), viewPoint->GetPositionY())); Cell cell2(pair2); //cell.SetNoCreate(); need load cells around viewPoint or player, that's why its commented diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index 0cd15143cee..af86af25db5 100755 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -81,9 +81,9 @@ namespace Trinity { Map &i_map; Cell &cell; - CellPair &p; + CellCoord &p; const float i_radius; - DelayedUnitRelocation(Cell &c, CellPair &pair, Map &map, float radius) : + DelayedUnitRelocation(Cell &c, CellCoord &pair, Map &map, float radius) : i_map(map), cell(c), p(pair), i_radius(radius) {} template<class T> void Visit(GridRefManager<T> &) {} void Visit(CreatureMapType &); diff --git a/src/server/game/Grids/ObjectGridLoader.cpp b/src/server/game/Grids/ObjectGridLoader.cpp index ee488f404dc..68fc39b39eb 100755 --- a/src/server/game/Grids/ObjectGridLoader.cpp +++ b/src/server/game/Grids/ObjectGridLoader.cpp @@ -82,19 +82,19 @@ class ObjectWorldLoader uint32 i_corpses; }; -template<class T> void ObjectGridLoader::SetObjectCell(T* /*obj*/, CellPair const& /*cell_pair*/) +template<class T> void ObjectGridLoader::SetObjectCell(T* /*obj*/, CellCoord const& /*cellCoord*/) { } -template<> void ObjectGridLoader::SetObjectCell(Creature* obj, CellPair const& cell_pair) +template<> void ObjectGridLoader::SetObjectCell(Creature* obj, CellCoord const& cellCoord) { - Cell cell(cell_pair); + Cell cell(cellCoord); obj->SetCurrentCell(cell); } template <class T> -void AddObjectHelper(CellPair &cell, GridRefManager<T> &m, uint32 &count, Map* map, T *obj) +void AddObjectHelper(CellCoord &cell, GridRefManager<T> &m, uint32 &count, Map* map, T *obj) { obj->GetGridRef().link(&m, obj); ObjectGridLoader::SetObjectCell(obj, cell); @@ -106,7 +106,7 @@ void AddObjectHelper(CellPair &cell, GridRefManager<T> &m, uint32 &count, Map* m } template <class T> -void LoadHelper(CellGuidSet const& guid_set, CellPair &cell, GridRefManager<T> &m, uint32 &count, Map* map) +void LoadHelper(CellGuidSet const& guid_set, CellCoord &cell, GridRefManager<T> &m, uint32 &count, Map* map) { for (CellGuidSet::const_iterator i_guid = guid_set.begin(); i_guid != guid_set.end(); ++i_guid) { @@ -123,7 +123,7 @@ void LoadHelper(CellGuidSet const& guid_set, CellPair &cell, GridRefManager<T> & } } -void LoadHelper(CellCorpseSet const& cell_corpses, CellPair &cell, CorpseMapType &m, uint32 &count, Map* map) +void LoadHelper(CellCorpseSet const& cell_corpses, CellCoord &cell, CorpseMapType &m, uint32 &count, Map* map) { if (cell_corpses.empty()) return; @@ -154,12 +154,12 @@ ObjectGridLoader::Visit(GameObjectMapType &m) { uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX(); uint32 y = (i_cell.GridY()*MAX_NUMBER_OF_CELLS) + i_cell.CellY(); - CellPair cell_pair(x, y); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + CellCoord cellCoord(x, y); + uint32 cell_id = (cellCoord.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord; CellObjectGuids const& cell_guids = sObjectMgr->GetCellObjectGuids(i_map->GetId(), i_map->GetSpawnMode(), cell_id); - LoadHelper(cell_guids.gameobjects, cell_pair, m, i_gameObjects, i_map); + LoadHelper(cell_guids.gameobjects, cellCoord, m, i_gameObjects, i_map); } void @@ -167,12 +167,12 @@ ObjectGridLoader::Visit(CreatureMapType &m) { uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX(); uint32 y = (i_cell.GridY()*MAX_NUMBER_OF_CELLS) + i_cell.CellY(); - CellPair cell_pair(x, y); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + CellCoord cellCoord(x, y); + uint32 cell_id = (cellCoord.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord; CellObjectGuids const& cell_guids = sObjectMgr->GetCellObjectGuids(i_map->GetId(), i_map->GetSpawnMode(), cell_id); - LoadHelper(cell_guids.creatures, cell_pair, m, i_creatures, i_map); + LoadHelper(cell_guids.creatures, cellCoord, m, i_creatures, i_map); } void @@ -180,12 +180,12 @@ ObjectWorldLoader::Visit(CorpseMapType &m) { uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX(); uint32 y = (i_cell.GridY()*MAX_NUMBER_OF_CELLS) + i_cell.CellY(); - CellPair cell_pair(x, y); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + CellCoord cellCoord(x, y); + uint32 cell_id = (cellCoord.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord; // corpses are always added to spawn mode 0 and they are spawned by their instance id CellObjectGuids const& cell_guids = sObjectMgr->GetCellObjectGuids(i_map->GetId(), 0, cell_id); - LoadHelper(cell_guids.corpses, cell_pair, m, i_corpses, i_map); + LoadHelper(cell_guids.corpses, cellCoord, m, i_corpses, i_map); } void diff --git a/src/server/game/Grids/ObjectGridLoader.h b/src/server/game/Grids/ObjectGridLoader.h index 5fc5dc47e71..e87860fa0ee 100755 --- a/src/server/game/Grids/ObjectGridLoader.h +++ b/src/server/game/Grids/ObjectGridLoader.h @@ -44,7 +44,7 @@ class ObjectGridLoader void LoadN(void); - template<class T> static void SetObjectCell(T* obj, CellPair const& cellPair); + template<class T> static void SetObjectCell(T* obj, CellCoord const& cellCoord); private: Cell i_cell; |
