aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Maps/Map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Maps/Map.cpp')
-rwxr-xr-xsrc/server/game/Maps/Map.cpp98
1 files changed, 49 insertions, 49 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 8824f302f56..44fb7b3fc83 100755
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -141,9 +141,9 @@ void Map::LoadMap(int gx, int gy, bool reload)
// load grid map for base map
if (!m_parentMap->GridMaps[gx][gy])
- m_parentMap->EnsureGridCreated(GridPair(63-gx, 63-gy));
+ m_parentMap->EnsureGridCreated(GridCoord(63-gx, 63-gy));
- ((MapInstanced*)(m_parentMap))->AddGridMapReference(GridPair(gx, gy));
+ ((MapInstanced*)(m_parentMap))->AddGridMapReference(GridCoord(gx, gy));
GridMaps[gx][gy] = m_parentMap->GridMaps[gx][gy];
return;
}
@@ -265,7 +265,7 @@ void Map::RemoveFromGrid(T* obj, NGridType *grid, Cell const& cell)
template<class T>
void Map::SwitchGridContainers(T* obj, bool on)
{
- CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
+ CellCoord p = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
{
sLog->outError("Map::SwitchGridContainers: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
@@ -273,7 +273,7 @@ void Map::SwitchGridContainers(T* obj, bool on)
}
Cell cell(p);
- if (!loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)))
+ if (!loaded(GridCoord(cell.data.Part.grid_x, cell.data.Part.grid_y)))
return;
sLog->outStaticDebug("Switch object " UI64FMTD " from grid[%u, %u] %u", obj->GetGUID(), cell.data.Part.grid_x, cell.data.Part.grid_y, on);
@@ -323,7 +323,7 @@ void Map::DeleteFromWorld(Player* pl)
}
void
-Map::EnsureGridCreated(const GridPair &p)
+Map::EnsureGridCreated(const GridCoord &p)
{
if (!getNGrid(p.x_coord, p.y_coord))
{
@@ -376,7 +376,7 @@ Map::EnsureGridLoadedAtEnter(const Cell &cell, Player* player)
bool Map::EnsureGridLoaded(const Cell &cell)
{
- EnsureGridCreated(GridPair(cell.GridX(), cell.GridY()));
+ EnsureGridCreated(GridCoord(cell.GridX(), cell.GridY()));
NGridType *grid = getNGrid(cell.GridX(), cell.GridY());
ASSERT(grid != NULL);
@@ -390,7 +390,7 @@ bool Map::EnsureGridLoaded(const Cell &cell)
loader.LoadN();
// Add resurrectable corpses to world object list in grid
- sObjectAccessor->AddCorpsesToGrid(GridPair(cell.GridX(), cell.GridY()), (*grid)(cell.CellX(), cell.CellY()), this);
+ sObjectAccessor->AddCorpsesToGrid(GridCoord(cell.GridX(), cell.GridY()), (*grid)(cell.CellX(), cell.CellY()), this);
return true;
}
@@ -399,7 +399,7 @@ bool Map::EnsureGridLoaded(const Cell &cell)
void Map::LoadGrid(float x, float y)
{
- CellPair pair = Trinity::ComputeCellPair(x, y);
+ CellCoord pair = Trinity::ComputeCellCoord(x, y);
Cell cell(pair);
EnsureGridLoaded(cell);
}
@@ -408,7 +408,7 @@ bool Map::AddToMap(Player* player)
{
// Check if we are adding to correct map
ASSERT (player->GetMap() == this);
- CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
+ CellCoord p = Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY());
if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
{
sLog->outError("Map::Add: Player (GUID: %u) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUIDLow(), player->GetPositionX(), player->GetPositionY(), p.x_coord, p.y_coord);
@@ -450,7 +450,7 @@ template<class T>
void
Map::AddToMap(T *obj)
{
- CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
+ CellCoord p = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
{
sLog->outError("Map::Add: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
@@ -467,7 +467,7 @@ Map::AddToMap(T *obj)
if (obj->isActiveObject())
EnsureGridLoadedAtEnter(cell);
else
- EnsureGridCreated(GridPair(cell.GridX(), cell.GridY()));
+ EnsureGridCreated(GridCoord(cell.GridX(), cell.GridY()));
NGridType *grid = getNGrid(cell.GridX(), cell.GridY());
ASSERT(grid != NULL);
@@ -487,14 +487,14 @@ Map::AddToMap(T *obj)
obj->UpdateObjectVisibility(true);
}
-bool Map::loaded(const GridPair &p) const
+bool Map::loaded(const GridCoord &p) const
{
return (getNGrid(p.x_coord, p.y_coord) && isGridObjectDataLoaded(p.x_coord, p.y_coord));
}
void Map::VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor<Trinity::ObjectUpdater, GridTypeMapContainer> &gridVisitor, TypeContainerVisitor<Trinity::ObjectUpdater, WorldTypeMapContainer> &worldVisitor)
{
- CellPair standing_cell(Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()));
+ 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.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
@@ -502,7 +502,7 @@ void Map::VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor<Trinity::Obj
// the overloaded operators handle range checking
// so there's no need for range checking inside the loop
- CellPair begin_cell(standing_cell), end_cell(standing_cell);
+ 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);
@@ -518,7 +518,7 @@ void Map::VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor<Trinity::Obj
continue;
markCell(cell_id);
- CellPair pair(x, y);
+ CellCoord pair(x, y);
Cell cell(pair);
cell.data.Part.reserved = CENTER_DISTRICT;
cell.Visit(pair, gridVisitor, *this);
@@ -620,8 +620,8 @@ void Map::ProcessRelocationNotifies(const uint32 diff)
uint32 gx = grid->getX(), gy = grid->getY();
- CellPair cell_min(gx*MAX_NUMBER_OF_CELLS, gy*MAX_NUMBER_OF_CELLS);
- CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);
+ CellCoord cell_min(gx*MAX_NUMBER_OF_CELLS, gy*MAX_NUMBER_OF_CELLS);
+ CellCoord cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);
for (uint32 x = cell_min.x_coord; x < cell_max.x_coord; ++x)
{
@@ -631,7 +631,7 @@ void Map::ProcessRelocationNotifies(const uint32 diff)
if (!isCellMarked(cell_id))
continue;
- CellPair pair(x, y);
+ CellCoord pair(x, y);
Cell cell(pair);
cell.SetNoCreate();
@@ -661,8 +661,8 @@ void Map::ProcessRelocationNotifies(const uint32 diff)
uint32 gx = grid->getX(), gy = grid->getY();
- CellPair cell_min(gx*MAX_NUMBER_OF_CELLS, gy*MAX_NUMBER_OF_CELLS);
- CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);
+ CellCoord cell_min(gx*MAX_NUMBER_OF_CELLS, gy*MAX_NUMBER_OF_CELLS);
+ CellCoord cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);
for (uint32 x = cell_min.x_coord; x < cell_max.x_coord; ++x)
{
@@ -672,7 +672,7 @@ void Map::ProcessRelocationNotifies(const uint32 diff)
if (!isCellMarked(cell_id))
continue;
- CellPair pair(x, y);
+ CellCoord pair(x, y);
Cell cell(pair);
cell.SetNoCreate();
Visit(cell, grid_notifier);
@@ -687,7 +687,7 @@ void Map::RemoveFromMap(Player* player, bool remove)
player->RemoveFromWorld();
SendRemoveTransports(player);
- CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
+ CellCoord p = Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY());
if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
sLog->outCrash("Map::Remove: Player is in invalid cell!");
else
@@ -720,13 +720,13 @@ Map::RemoveFromMap(T *obj, bool remove)
if (obj->isActiveObject())
RemoveFromActive(obj);
- CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
+ CellCoord p = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
sLog->outError("Map::Remove: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
else
{
Cell cell(p);
- if (loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)))
+ if (loaded(GridCoord(cell.data.Part.grid_x, cell.data.Part.grid_y)))
{
sLog->outStaticDebug("Remove object " UI64FMTD " from grid[%u, %u]", obj->GetGUID(), cell.data.Part.grid_x, cell.data.Part.grid_y);
NGridType *grid = getNGrid(cell.GridX(), cell.GridY());
@@ -753,8 +753,8 @@ Map::PlayerRelocation(Player* player, float x, float y, float z, float orientati
{
ASSERT(player);
- CellPair old_val = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
- CellPair new_val = Trinity::ComputeCellPair(x, y);
+ 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);
@@ -785,7 +785,7 @@ Map::CreatureRelocation(Creature* creature, float x, float y, float z, float ang
Cell old_cell = creature->GetCurrentCell();
- CellPair new_val = Trinity::ComputeCellPair(x, y);
+ CellCoord new_val = Trinity::ComputeCellCoord(x, y);
Cell new_cell(new_val);
if (!respawnRelocationOnFail && !getNGrid(new_cell.GridX(), new_cell.GridY()))
@@ -849,11 +849,11 @@ void Map::MoveAllCreaturesInMoveList()
continue;
// do move or do move to respawn or remove creature if previous all fail
- if (CreatureCellRelocation(c, Cell(Trinity::ComputeCellPair(c->_newPosition.m_positionX, c->_newPosition.m_positionY))))
+ if (CreatureCellRelocation(c, Cell(Trinity::ComputeCellCoord(c->_newPosition.m_positionX, c->_newPosition.m_positionY))))
{
// update pos
c->Relocate(c->_newPosition);
- //CreatureRelocationNotify(c, new_cell, new_cell.cellPair());
+ //CreatureRelocationNotify(c, new_cell, new_cell.cellCoord());
c->UpdateObjectVisibility(false);
}
else
@@ -924,14 +924,14 @@ bool Map::CreatureCellRelocation(Creature* c, Cell new_cell)
}
// in diff. loaded grid normal creature
- if (loaded(GridPair(new_cell.GridX(), new_cell.GridY())))
+ if (loaded(GridCoord(new_cell.GridX(), new_cell.GridY())))
{
#ifdef TRINITY_DEBUG
sLog->outDebug(LOG_FILTER_MAPS, "Creature (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
#endif
RemoveFromGrid(c, getNGrid(old_cell.GridX(), old_cell.GridY()), old_cell);
- EnsureGridCreated(GridPair(new_cell.GridX(), new_cell.GridY()));
+ EnsureGridCreated(GridCoord(new_cell.GridX(), new_cell.GridY()));
AddToGrid(c, getNGrid(new_cell.GridX(), new_cell.GridY()), new_cell);
return true;
@@ -947,8 +947,8 @@ bool Map::CreatureCellRelocation(Creature* c, Cell new_cell)
bool Map::CreatureRespawnRelocation(Creature* c, bool diffGridOnly)
{
float resp_x, resp_y, resp_z, resp_o;
- c->GetRespawnCoord(resp_x, resp_y, resp_z, &resp_o);
- CellPair resp_val = Trinity::ComputeCellPair(resp_x, resp_y);
+ c->GetRespawnPosition(resp_x, resp_y, resp_z, &resp_o);
+ CellCoord resp_val = Trinity::ComputeCellCoord(resp_x, resp_y);
Cell resp_cell(resp_val);
//creature will be unloaded with grid
@@ -967,7 +967,7 @@ bool Map::CreatureRespawnRelocation(Creature* c, bool diffGridOnly)
{
c->Relocate(resp_x, resp_y, resp_z, resp_o);
c->GetMotionMaster()->Initialize(); // prevent possible problems with default move generators
- //CreatureRelocationNotify(c, resp_cell, resp_cell.cellPair());
+ //CreatureRelocationNotify(c, resp_cell, resp_cell.GetCellCoord());
c->UpdateObjectVisibility(false);
return true;
}
@@ -1030,7 +1030,7 @@ bool Map::UnloadGrid(const uint32 x, const uint32 y, bool unloadAll)
VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(GetId(), gx, gy);
}
else
- ((MapInstanced*)m_parentMap)->RemoveGridMapReference(GridPair(gx, gy));
+ ((MapInstanced*)m_parentMap)->RemoveGridMapReference(GridCoord(gx, gy));
GridMaps[gx][gy] = NULL;
}
@@ -1589,7 +1589,7 @@ inline GridMap* Map::GetGrid(float x, float y)
int gy=(int)(32-y/SIZE_OF_GRIDS); //grid y
// ensure GridMap is loaded
- EnsureGridCreated(GridPair(63-gx, 63-gy));
+ EnsureGridCreated(GridCoord(63-gx, 63-gy));
return GridMaps[gx][gy];
}
@@ -1877,7 +1877,7 @@ bool Map::CheckGridIntegrity(Creature* c, bool moved) const
{
Cell const& cur_cell = c->GetCurrentCell();
- CellPair xy_val = Trinity::ComputeCellPair(c->GetPositionX(), c->GetPositionY());
+ CellCoord xy_val = Trinity::ComputeCellCoord(c->GetPositionX(), c->GetPositionY());
Cell xy_cell(xy_val);
if (xy_cell != cur_cell)
{
@@ -1897,7 +1897,7 @@ const char* Map::GetMapName() const
return i_mapEntry ? i_mapEntry->name[sWorld->GetDefaultDbcLocale()] : "UNNAMEDMAP\x0";
}
-void Map::UpdateObjectVisibility(WorldObject* obj, Cell cell, CellPair cellpair)
+void Map::UpdateObjectVisibility(WorldObject* obj, Cell cell, CellCoord cellpair)
{
cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
@@ -1906,7 +1906,7 @@ void Map::UpdateObjectVisibility(WorldObject* obj, Cell cell, CellPair cellpair)
cell.Visit(cellpair, player_notifier, *this, *obj, obj->GetVisibilityRange());
}
-void Map::UpdateObjectsVisibilityFor(Player* player, Cell cell, CellPair cellpair)
+void Map::UpdateObjectsVisibilityFor(Player* player, Cell cell, CellCoord cellpair)
{
Trinity::VisibleNotifier notifier(*player);
@@ -2135,8 +2135,8 @@ bool Map::ActiveObjectsNearGrid(uint32 x, uint32 y) const
ASSERT(x < MAX_NUMBER_OF_GRIDS);
ASSERT(y < MAX_NUMBER_OF_GRIDS);
- CellPair cell_min(x*MAX_NUMBER_OF_CELLS, y*MAX_NUMBER_OF_CELLS);
- CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);
+ CellCoord cell_min(x*MAX_NUMBER_OF_CELLS, y*MAX_NUMBER_OF_CELLS);
+ CellCoord cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);
//we must find visible range in cells so we unload only non-visible cells...
float viewDist = GetVisibilityRange();
@@ -2151,7 +2151,7 @@ bool Map::ActiveObjectsNearGrid(uint32 x, uint32 y) const
{
Player* plr = iter->getSource();
- CellPair p = Trinity::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY());
+ CellCoord p = Trinity::ComputeCellCoord(plr->GetPositionX(), plr->GetPositionY());
if ((cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&
(cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord))
return true;
@@ -2161,7 +2161,7 @@ bool Map::ActiveObjectsNearGrid(uint32 x, uint32 y) const
{
WorldObject* obj = *iter;
- CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
+ CellCoord p = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
if ((cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&
(cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord))
return true;
@@ -2178,13 +2178,13 @@ void Map::AddToActive(Creature* c)
if (!c->isPet() && c->GetDBTableGUIDLow())
{
float x, y, z;
- c->GetRespawnCoord(x, y, z);
- GridPair p = Trinity::ComputeGridPair(x, y);
+ c->GetRespawnPosition(x, y, z);
+ GridCoord p = Trinity::ComputeGridCoord(x, y);
if (getNGrid(p.x_coord, p.y_coord))
getNGrid(p.x_coord, p.y_coord)->incUnloadActiveLock();
else
{
- GridPair p2 = Trinity::ComputeGridPair(c->GetPositionX(), c->GetPositionY());
+ GridCoord p2 = Trinity::ComputeGridCoord(c->GetPositionX(), c->GetPositionY());
sLog->outError("Active creature (GUID: %u Entry: %u) added to grid[%u, %u] but spawn grid[%u, %u] was not loaded.",
c->GetGUIDLow(), c->GetEntry(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord);
}
@@ -2199,13 +2199,13 @@ void Map::RemoveFromActive(Creature* c)
if (!c->isPet() && c->GetDBTableGUIDLow())
{
float x, y, z;
- c->GetRespawnCoord(x, y, z);
- GridPair p = Trinity::ComputeGridPair(x, y);
+ c->GetRespawnPosition(x, y, z);
+ GridCoord p = Trinity::ComputeGridCoord(x, y);
if (getNGrid(p.x_coord, p.y_coord))
getNGrid(p.x_coord, p.y_coord)->decUnloadActiveLock();
else
{
- GridPair p2 = Trinity::ComputeGridPair(c->GetPositionX(), c->GetPositionY());
+ GridCoord p2 = Trinity::ComputeGridCoord(c->GetPositionX(), c->GetPositionY());
sLog->outError("Active creature (GUID: %u Entry: %u) removed from grid[%u, %u] but spawn grid[%u, %u] was not loaded.",
c->GetGUIDLow(), c->GetEntry(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord);
}