aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/Grids/Cells/Cell.h1
-rw-r--r--src/server/game/Grids/Cells/CellImpl.h11
-rwxr-xr-xsrc/server/game/Maps/Map.cpp26
3 files changed, 20 insertions, 18 deletions
diff --git a/src/server/game/Grids/Cells/Cell.h b/src/server/game/Grids/Cells/Cell.h
index ba396106f46..12648881719 100755
--- a/src/server/game/Grids/Cells/Cell.h
+++ b/src/server/game/Grids/Cells/Cell.h
@@ -68,6 +68,7 @@ struct Cell
Cell() { data.All = 0; }
Cell(const Cell &cell) { data.All = cell.data.All; }
explicit Cell(CellCoord const& p);
+ explicit Cell(float x, float y);
void operator|=(Cell &cell)
{
diff --git a/src/server/game/Grids/Cells/CellImpl.h b/src/server/game/Grids/Cells/CellImpl.h
index 17f85dde8f4..5a5be4d7358 100644
--- a/src/server/game/Grids/Cells/CellImpl.h
+++ b/src/server/game/Grids/Cells/CellImpl.h
@@ -35,6 +35,17 @@ inline Cell::Cell(CellCoord const& p)
data.Part.reserved = 0;
}
+inline Cell::Cell(float x, float y)
+{
+ CellCoord p = Trinity::ComputeCellCoord(x, y);
+ data.Part.grid_x = p.x_coord / MAX_NUMBER_OF_CELLS;
+ data.Part.grid_y = p.y_coord / MAX_NUMBER_OF_CELLS;
+ data.Part.cell_x = p.x_coord % MAX_NUMBER_OF_CELLS;
+ data.Part.cell_y = p.y_coord % MAX_NUMBER_OF_CELLS;
+ data.Part.nocreate = 0;
+ data.Part.reserved = 0;
+}
+
template<class T, class CONTAINER>
inline void
Cell::Visit(const CellCoord& standing_cell, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m) const
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 43eb09be775..e64464e4bff 100755
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -399,9 +399,7 @@ bool Map::EnsureGridLoaded(const Cell &cell)
void Map::LoadGrid(float x, float y)
{
- CellCoord pair = Trinity::ComputeCellCoord(x, y);
- Cell cell(pair);
- EnsureGridLoaded(cell);
+ EnsureGridLoaded(Cell(x, y));
}
bool Map::AddToMap(Player* player)
@@ -494,7 +492,7 @@ bool Map::loaded(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()));
+ CellCoord standing_cell(obj->GetPositionX(), obj->GetPositionY());
// Check for correctness of standing_cell, it also avoids problems with update_cell
if (!standing_cell.IsCoordValid())
@@ -753,11 +751,8 @@ Map::PlayerRelocation(Player* player, float x, float y, float z, float orientati
{
ASSERT(player);
- CellCoord old_val = Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY());
- CellCoord new_val = Trinity::ComputeCellCoord(x, y);
-
- Cell old_cell(old_val);
- Cell new_cell(new_val);
+ Cell old_cell(player->GetPositionX(), player->GetPositionY());
+ Cell new_cell(x, y);
player->Relocate(x, y, z, orientation);
@@ -784,9 +779,7 @@ Map::CreatureRelocation(Creature* creature, float x, float y, float z, float ang
ASSERT(CheckGridIntegrity(creature, false));
Cell old_cell = creature->GetCurrentCell();
-
- CellCoord new_val = Trinity::ComputeCellCoord(x, y);
- Cell new_cell(new_val);
+ Cell new_cell(x, y);
if (!respawnRelocationOnFail && !getNGrid(new_cell.GridX(), new_cell.GridY()))
return;
@@ -849,7 +842,7 @@ void Map::MoveAllCreaturesInMoveList()
continue;
// do move or do move to respawn or remove creature if previous all fail
- if (CreatureCellRelocation(c, Cell(Trinity::ComputeCellCoord(c->_newPosition.m_positionX, c->_newPosition.m_positionY))))
+ if (CreatureCellRelocation(c, Cell(c->_newPosition.m_positionX, c->_newPosition.m_positionY)))
{
// update pos
c->Relocate(c->_newPosition);
@@ -948,8 +941,7 @@ bool Map::CreatureRespawnRelocation(Creature* c, bool diffGridOnly)
{
float resp_x, resp_y, resp_z, resp_o;
c->GetRespawnPosition(resp_x, resp_y, resp_z, &resp_o);
- CellCoord resp_val = Trinity::ComputeCellCoord(resp_x, resp_y);
- Cell resp_cell(resp_val);
+ Cell resp_cell(resp_x, resp_y);
//creature will be unloaded with grid
if (diffGridOnly && !c->GetCurrentCell().DiffGrid(resp_cell))
@@ -1876,9 +1868,7 @@ bool Map::IsUnderWater(float x, float y, float z) const
bool Map::CheckGridIntegrity(Creature* c, bool moved) const
{
Cell const& cur_cell = c->GetCurrentCell();
-
- CellCoord xy_val = Trinity::ComputeCellCoord(c->GetPositionX(), c->GetPositionY());
- Cell xy_cell(xy_val);
+ Cell xy_cell(c->GetPositionX(), c->GetPositionY());
if (xy_cell != cur_cell)
{
sLog->outDebug(LOG_FILTER_MAPS, "Creature (GUID: %u) X: %f Y: %f (%s) is in grid[%u, %u]cell[%u, %u] instead of grid[%u, %u]cell[%u, %u]",