aboutsummaryrefslogtreecommitdiff
path: root/src/game/Map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/Map.cpp')
-rw-r--r--src/game/Map.cpp96
1 files changed, 49 insertions, 47 deletions
diff --git a/src/game/Map.cpp b/src/game/Map.cpp
index df03bb96842..c27053b60b1 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -1,5 +1,7 @@
/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+ *
+ * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -8,12 +10,12 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "Player.h"
@@ -421,7 +423,7 @@ bool Map::Add(Player *player)
player->SetInstanceId(this->GetInstanceId());
// update player state for other player and visa-versa
- CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
+ CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
Cell cell(p);
EnsureGridLoadedForPlayer(cell, player, true);
player->AddToWorld();
@@ -440,7 +442,7 @@ template<class T>
void
Map::Add(T *obj)
{
- CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
+ CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
assert(obj);
@@ -467,7 +469,7 @@ Map::Add(T *obj)
void Map::MessageBroadcast(Player *player, WorldPacket *msg, bool to_self)
{
- CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
+ CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP )
{
@@ -481,15 +483,15 @@ void Map::MessageBroadcast(Player *player, WorldPacket *msg, bool to_self)
if( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) )
return;
- MaNGOS::MessageDeliverer post_man(*player, msg, to_self);
- TypeContainerVisitor<MaNGOS::MessageDeliverer, WorldTypeMapContainer > message(post_man);
+ Trinity::MessageDeliverer post_man(*player, msg, to_self);
+ TypeContainerVisitor<Trinity::MessageDeliverer, WorldTypeMapContainer > message(post_man);
CellLock<ReadGuard> cell_lock(cell, p);
cell_lock->Visit(cell_lock, message, *this);
}
void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg)
{
- CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
+ CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP )
{
@@ -504,15 +506,15 @@ void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg)
if( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) )
return;
- MaNGOS::ObjectMessageDeliverer post_man(msg);
- TypeContainerVisitor<MaNGOS::ObjectMessageDeliverer, WorldTypeMapContainer > message(post_man);
+ Trinity::ObjectMessageDeliverer post_man(msg);
+ TypeContainerVisitor<Trinity::ObjectMessageDeliverer, WorldTypeMapContainer > message(post_man);
CellLock<ReadGuard> cell_lock(cell, p);
cell_lock->Visit(cell_lock, message, *this);
}
void Map::MessageDistBroadcast(Player *player, WorldPacket *msg, float dist, bool to_self, bool own_team_only)
{
- CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
+ CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP )
{
@@ -526,15 +528,15 @@ void Map::MessageDistBroadcast(Player *player, WorldPacket *msg, float dist, boo
if( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) )
return;
- MaNGOS::MessageDistDeliverer post_man(*player, msg, dist, to_self, own_team_only);
- TypeContainerVisitor<MaNGOS::MessageDistDeliverer , WorldTypeMapContainer > message(post_man);
+ Trinity::MessageDistDeliverer post_man(*player, msg, dist, to_self, own_team_only);
+ TypeContainerVisitor<Trinity::MessageDistDeliverer , WorldTypeMapContainer > message(post_man);
CellLock<ReadGuard> cell_lock(cell, p);
cell_lock->Visit(cell_lock, message, *this);
}
void Map::MessageDistBroadcast(WorldObject *obj, WorldPacket *msg, float dist)
{
- CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
+ CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP )
{
@@ -549,8 +551,8 @@ void Map::MessageDistBroadcast(WorldObject *obj, WorldPacket *msg, float dist)
if( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) )
return;
- MaNGOS::ObjectMessageDistDeliverer post_man(*obj, msg,dist);
- TypeContainerVisitor<MaNGOS::ObjectMessageDistDeliverer, WorldTypeMapContainer > message(post_man);
+ Trinity::ObjectMessageDistDeliverer post_man(*obj, msg,dist);
+ TypeContainerVisitor<Trinity::ObjectMessageDistDeliverer, WorldTypeMapContainer > message(post_man);
CellLock<ReadGuard> cell_lock(cell, p);
cell_lock->Visit(cell_lock, message, *this);
}
@@ -588,7 +590,7 @@ void InstanceMap::Update(const uint32& t_diff)
void Map::Remove(Player *player, bool remove)
{
- CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
+ CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
{
// invalid coordinates
@@ -640,7 +642,7 @@ template<class T>
void
Map::Remove(T *obj, bool remove)
{
- CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
+ CellPair p = Trinity::ComputeCellPair(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 " I64FMTD " have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
@@ -674,8 +676,8 @@ Map::PlayerRelocation(Player *player, float x, float y, float z, float orientati
{
assert(player);
- CellPair old_val = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
- CellPair new_val = MaNGOS::ComputeCellPair(x, y);
+ CellPair old_val = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
+ CellPair new_val = Trinity::ComputeCellPair(x, y);
Cell old_cell(old_val);
Cell new_cell(new_val);
@@ -720,13 +722,13 @@ Map::CreatureRelocation(Creature *creature, float x, float y, float z, float ang
Cell old_cell = creature->GetCurrentCell();
- CellPair new_val = MaNGOS::ComputeCellPair(x, y);
+ CellPair new_val = Trinity::ComputeCellPair(x, y);
Cell new_cell(new_val);
// delay creature move for grid/cell to grid/cell moves
if( old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell) )
{
- #ifdef MANGOS_DEBUG
+ #ifdef TRINITY_DEBUG
if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0)
sLog.outDebug("Creature (GUID: %u Entry: %u) added to moving list from grid[%u,%u]cell[%u,%u] to grid[%u,%u]cell[%u,%u].", creature->GetGUIDLow(), creature->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
@@ -760,7 +762,7 @@ void Map::MoveAllCreaturesInMoveList()
i_creaturesToMove.erase(iter);
// calculate cells
- CellPair new_val = MaNGOS::ComputeCellPair(cm.x, cm.y);
+ CellPair new_val = Trinity::ComputeCellPair(cm.x, cm.y);
Cell new_cell(new_val);
// do move or do move to respawn or remove creature if previous all fail
@@ -777,7 +779,7 @@ void Map::MoveAllCreaturesInMoveList()
if(!CreatureRespawnRelocation(c))
{
// ... or unload (if respawn grid also not loaded)
- #ifdef MANGOS_DEBUG
+ #ifdef TRINITY_DEBUG
if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0)
sLog.outDebug("Creature (GUID: %u Entry: %u ) can't be move to unloaded respawn grid.",c->GetGUIDLow(),c->GetEntry());
#endif
@@ -796,7 +798,7 @@ bool Map::CreatureCellRelocation(Creature *c, Cell new_cell)
// if in same cell then none do
if(old_cell.DiffCell(new_cell))
{
- #ifdef MANGOS_DEBUG
+ #ifdef TRINITY_DEBUG
if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0)
sLog.outDebug("Creature (GUID: %u Entry: %u) moved in grid[%u,%u] from cell[%u,%u] to cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY());
#endif
@@ -810,7 +812,7 @@ bool Map::CreatureCellRelocation(Creature *c, Cell new_cell)
}
else
{
- #ifdef MANGOS_DEBUG
+ #ifdef TRINITY_DEBUG
if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0)
sLog.outDebug("Creature (GUID: %u Entry: %u) move in same grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY());
#endif
@@ -819,7 +821,7 @@ bool Map::CreatureCellRelocation(Creature *c, Cell new_cell)
else // in diff. grids
if(loaded(GridPair(new_cell.GridX(), new_cell.GridY())))
{
- #ifdef MANGOS_DEBUG
+ #ifdef TRINITY_DEBUG
if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0)
sLog.outDebug("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
@@ -832,7 +834,7 @@ bool Map::CreatureCellRelocation(Creature *c, Cell new_cell)
}
else
{
- #ifdef MANGOS_DEBUG
+ #ifdef TRINITY_DEBUG
if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0)
sLog.outDebug("Creature (GUID: %u Entry: %u) attempt move from grid[%u,%u]cell[%u,%u] to unloaded 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
@@ -847,13 +849,13 @@ bool Map::CreatureRespawnRelocation(Creature *c)
float resp_x, resp_y, resp_z, resp_o;
c->GetRespawnCoord(resp_x, resp_y, resp_z, &resp_o);
- CellPair resp_val = MaNGOS::ComputeCellPair(resp_x, resp_y);
+ CellPair resp_val = Trinity::ComputeCellPair(resp_x, resp_y);
Cell resp_cell(resp_val);
c->CombatStop();
c->GetMotionMaster()->Clear();
- #ifdef MANGOS_DEBUG
+ #ifdef TRINITY_DEBUG
if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0)
sLog.outDebug("Creature (GUID: %u Entry: %u) will moved from grid[%u,%u]cell[%u,%u] to respawn grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), c->GetCurrentCell().GridX(), c->GetCurrentCell().GridY(), c->GetCurrentCell().CellX(), c->GetCurrentCell().CellY(), resp_cell.GridX(), resp_cell.GridY(), resp_cell.CellX(), resp_cell.CellY());
#endif
@@ -931,7 +933,7 @@ void Map::UnloadAll(bool pForce)
float Map::GetHeight(float x, float y, float z, bool pUseVmaps) const
{
- GridPair p = MaNGOS::ComputeGridPair(x, y);
+ GridPair p = Trinity::ComputeGridPair(x, y);
// half opt method
int gx=(int)(32-x/SIZE_OF_GRIDS); //grid x
@@ -1028,7 +1030,7 @@ uint16 Map::GetAreaFlag(float x, float y ) const
//local x,y coords
float lx,ly;
int gx,gy;
- GridPair p = MaNGOS::ComputeGridPair(x, y);
+ GridPair p = Trinity::ComputeGridPair(x, y);
// half opt method
gx=(int)(32-x/SIZE_OF_GRIDS) ; //grid x
@@ -1139,7 +1141,7 @@ bool Map::CheckGridIntegrity(Creature* c, bool moved) const
{
Cell const& cur_cell = c->GetCurrentCell();
- CellPair xy_val = MaNGOS::ComputeCellPair(c->GetPositionX(), c->GetPositionY());
+ CellPair xy_val = Trinity::ComputeCellPair(c->GetPositionX(), c->GetPositionY());
Cell xy_cell(xy_val);
if(xy_cell != cur_cell)
{
@@ -1163,8 +1165,8 @@ void Map::UpdateObjectVisibility( WorldObject* obj, Cell cell, CellPair cellpair
{
cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
- MaNGOS::VisibleChangesNotifier notifier(*obj);
- TypeContainerVisitor<MaNGOS::VisibleChangesNotifier, WorldTypeMapContainer > player_notifier(notifier);
+ Trinity::VisibleChangesNotifier notifier(*obj);
+ TypeContainerVisitor<Trinity::VisibleChangesNotifier, WorldTypeMapContainer > player_notifier(notifier);
CellLock<GridReadGuard> cell_lock(cell, cellpair);
cell_lock->Visit(cell_lock, player_notifier, *this);
}
@@ -1173,8 +1175,8 @@ void Map::UpdatePlayerVisibility( Player* player, Cell cell, CellPair cellpair )
{
cell.data.Part.reserved = ALL_DISTRICT;
- MaNGOS::PlayerNotifier pl_notifier(*player);
- TypeContainerVisitor<MaNGOS::PlayerNotifier, WorldTypeMapContainer > player_notifier(pl_notifier);
+ Trinity::PlayerNotifier pl_notifier(*player);
+ TypeContainerVisitor<Trinity::PlayerNotifier, WorldTypeMapContainer > player_notifier(pl_notifier);
CellLock<ReadGuard> cell_lock(cell, cellpair);
cell_lock->Visit(cell_lock, player_notifier, *this);
@@ -1182,12 +1184,12 @@ void Map::UpdatePlayerVisibility( Player* player, Cell cell, CellPair cellpair )
void Map::UpdateObjectsVisibilityFor( Player* player, Cell cell, CellPair cellpair )
{
- MaNGOS::VisibleNotifier notifier(*player);
+ Trinity::VisibleNotifier notifier(*player);
cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
- TypeContainerVisitor<MaNGOS::VisibleNotifier, WorldTypeMapContainer > world_notifier(notifier);
- TypeContainerVisitor<MaNGOS::VisibleNotifier, GridTypeMapContainer > grid_notifier(notifier);
+ TypeContainerVisitor<Trinity::VisibleNotifier, WorldTypeMapContainer > world_notifier(notifier);
+ TypeContainerVisitor<Trinity::VisibleNotifier, GridTypeMapContainer > grid_notifier(notifier);
CellLock<GridReadGuard> cell_lock(cell, cellpair);
cell_lock->Visit(cell_lock, world_notifier, *this);
cell_lock->Visit(cell_lock, grid_notifier, *this);
@@ -1199,11 +1201,11 @@ void Map::UpdateObjectsVisibilityFor( Player* player, Cell cell, CellPair cellpa
void Map::PlayerRelocationNotify( Player* player, Cell cell, CellPair cellpair )
{
CellLock<ReadGuard> cell_lock(cell, cellpair);
- MaNGOS::PlayerRelocationNotifier relocationNotifier(*player);
+ Trinity::PlayerRelocationNotifier relocationNotifier(*player);
cell.data.Part.reserved = ALL_DISTRICT;
- TypeContainerVisitor<MaNGOS::PlayerRelocationNotifier, GridTypeMapContainer > p2grid_relocation(relocationNotifier);
- TypeContainerVisitor<MaNGOS::PlayerRelocationNotifier, WorldTypeMapContainer > p2world_relocation(relocationNotifier);
+ TypeContainerVisitor<Trinity::PlayerRelocationNotifier, GridTypeMapContainer > p2grid_relocation(relocationNotifier);
+ TypeContainerVisitor<Trinity::PlayerRelocationNotifier, WorldTypeMapContainer > p2world_relocation(relocationNotifier);
cell_lock->Visit(cell_lock, p2grid_relocation, *this);
cell_lock->Visit(cell_lock, p2world_relocation, *this);
@@ -1212,12 +1214,12 @@ void Map::PlayerRelocationNotify( Player* player, Cell cell, CellPair cellpair )
void Map::CreatureRelocationNotify(Creature *creature, Cell cell, CellPair cellpair)
{
CellLock<ReadGuard> cell_lock(cell, cellpair);
- MaNGOS::CreatureRelocationNotifier relocationNotifier(*creature);
+ Trinity::CreatureRelocationNotifier relocationNotifier(*creature);
cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate(); // not trigger load unloaded grids at notifier call
- TypeContainerVisitor<MaNGOS::CreatureRelocationNotifier, WorldTypeMapContainer > c2world_relocation(relocationNotifier);
- TypeContainerVisitor<MaNGOS::CreatureRelocationNotifier, GridTypeMapContainer > c2grid_relocation(relocationNotifier);
+ TypeContainerVisitor<Trinity::CreatureRelocationNotifier, WorldTypeMapContainer > c2world_relocation(relocationNotifier);
+ TypeContainerVisitor<Trinity::CreatureRelocationNotifier, GridTypeMapContainer > c2grid_relocation(relocationNotifier);
cell_lock->Visit(cell_lock, c2world_relocation, *this);
cell_lock->Visit(cell_lock, c2grid_relocation, *this);