aboutsummaryrefslogtreecommitdiff
path: root/src/game/Map.cpp
diff options
context:
space:
mode:
authormaximius <none@none>2009-10-17 16:20:24 -0700
committermaximius <none@none>2009-10-17 16:20:24 -0700
commit3f338cc1c328c7280957583b50598292cd8fb64b (patch)
treeca209c2cd024e3902b7844b3224bceff7c5bb570 /src/game/Map.cpp
parente585187b248f48b3c6e9247b49fa07c6565d65e5 (diff)
*Massive cleanup redux.
--HG-- branch : trunk
Diffstat (limited to 'src/game/Map.cpp')
-rw-r--r--src/game/Map.cpp112
1 files changed, 56 insertions, 56 deletions
diff --git a/src/game/Map.cpp b/src/game/Map.cpp
index 2f8c4d0e152..2c9030a4608 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -217,20 +217,20 @@ Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode, Map* _par
{
m_notifyTimer.SetInterval(IN_MILISECONDS/2);
- for(unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx)
+ for (unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx)
{
- for(unsigned int j=0; j < MAX_NUMBER_OF_GRIDS; ++j)
+ for (unsigned int j=0; j < MAX_NUMBER_OF_GRIDS; ++j)
{
//z code
GridMaps[idx][j] =NULL;
setNGrid(NULL, idx, j);
}
}
-
+
//lets initialize visibility distance for map
Map::InitVisibilityDistance();
}
-
+
void Map::InitVisibilityDistance()
{
//init visibility for continents
@@ -501,43 +501,43 @@ Map::Add(T *obj)
void Map::MessageBroadcast(Player *player, WorldPacket *msg, bool to_self)
{
CellPair p = MaNGOS::ComputeCellPair(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::MessageBroadcast: Player (GUID: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUIDLow(), player->GetPositionX(), player->GetPositionY(), p.x_coord, p.y_coord);
return;
}
-
+
Cell cell(p);
cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
-
+
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);
CellLock<ReadGuard> cell_lock(cell, p);
cell_lock->Visit(cell_lock, message, *this, *player, GetVisibilityDistance());
}
-
+
void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg)
{
CellPair p = MaNGOS::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::MessageBroadcast: Object (GUID: %u TypeId: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUIDLow(), obj->GetTypeId(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
return;
}
-
+
Cell cell(p);
cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
-
+
if( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) )
return;
-
+
//TODO: currently on continents when Visibility.Distance.InFlight > Visibility.Distance.Continents
//we have alot of blinking mobs because monster move packet send is broken...
MaNGOS::ObjectMessageDeliverer post_man(*obj,msg);
@@ -549,43 +549,43 @@ void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg)
void Map::MessageDistBroadcast(Player *player, WorldPacket *msg, float dist, bool to_self, bool own_team_only)
{
CellPair p = MaNGOS::ComputeCellPair(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::MessageBroadcast: Player (GUID: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUIDLow(), player->GetPositionX(), player->GetPositionY(), p.x_coord, p.y_coord);
return;
}
-
+
Cell cell(p);
cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
-
+
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);
CellLock<ReadGuard> cell_lock(cell, p);
cell_lock->Visit(cell_lock, message, *this, *player, dist);
}
-
+
void Map::MessageDistBroadcast(WorldObject *obj, WorldPacket *msg, float dist)
{
CellPair p = MaNGOS::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::MessageBroadcast: Object (GUID: %u TypeId: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUIDLow(), obj->GetTypeId(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
return;
}
-
+
Cell cell(p);
cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
-
+
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);
CellLock<ReadGuard> cell_lock(cell, p);
@@ -603,7 +603,7 @@ void Map::RelocationNotify()
i_notifyLock = true;
//Notify
- for(std::vector<Unit*>::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter)
+ for (std::vector<Unit*>::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter)
{
Unit *unit = *iter;
if(!unit)
@@ -639,7 +639,7 @@ void Map::RelocationNotify()
VisitAll(unit->GetPositionX(), unit->GetPositionY(), GetVisibilityDistance() + dist, notifier);
}
}
- for(std::vector<Unit*>::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter)
+ for (std::vector<Unit*>::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter)
if(*iter)
(*iter)->m_Notified = false;
i_unitsToNotify.clear();
@@ -697,7 +697,7 @@ void Map::RemoveUnitFromNotify(Unit *unit)
void Map::Update(const uint32 &t_diff)
{
/// update players at tick
- for(m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter)
+ for (m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter)
{
Player* plr = m_mapRefIter->getSource();
if(plr && plr->IsInWorld())
@@ -722,7 +722,7 @@ void Map::Update(const uint32 &t_diff)
// the player iterator is stored in the map object
// to make sure calls to Map::Remove don't invalidate it
- for(m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter)
+ for (m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter)
{
Player* plr = m_mapRefIter->getSource();
@@ -742,9 +742,9 @@ void Map::Update(const uint32 &t_diff)
CellArea area = Cell::CalculateCellArea(*plr, GetVisibilityDistance());
area.ResizeBorders(begin_cell, end_cell);
- for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x)
+ for (uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x)
{
- for(uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y)
+ for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y)
{
// marked cells are those that have been visited
// don't visit the same cell twice
@@ -770,7 +770,7 @@ void Map::Update(const uint32 &t_diff)
// non-player active objects
if(!m_activeNonPlayers.empty())
{
- for(m_activeNonPlayersIter = m_activeNonPlayers.begin(); m_activeNonPlayersIter != m_activeNonPlayers.end(); )
+ for (m_activeNonPlayersIter = m_activeNonPlayers.begin(); m_activeNonPlayersIter != m_activeNonPlayers.end(); )
{
// skip not in world
WorldObject* obj = *m_activeNonPlayersIter;
@@ -794,9 +794,9 @@ void Map::Update(const uint32 &t_diff)
begin_cell << 1; begin_cell -= 1; // upper left
end_cell >> 1; end_cell += 1; // lower right
- for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x)
+ for (uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x)
{
- for(uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y)
+ for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y)
{
// marked cells are those that have been visited
// don't visit the same cell twice
@@ -974,7 +974,7 @@ Map::CreatureRelocation(Creature *creature, float x, float y, float z, float ang
if(creature->IsVehicle())
{
- for(SeatMap::iterator itr = creature->GetVehicleKit()->m_Seats.begin(); itr != creature->GetVehicleKit()->m_Seats.end(); ++itr)
+ for (SeatMap::iterator itr = creature->GetVehicleKit()->m_Seats.begin(); itr != creature->GetVehicleKit()->m_Seats.end(); ++itr)
if(Unit *passenger = itr->second.passenger)
{
if(passenger->GetTypeId() == TYPEID_PLAYER)
@@ -1204,7 +1204,7 @@ void Map::RemoveAllPlayers()
{
if(HavePlayers())
{
- for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
+ for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
{
Player* plr = itr->getSource();
if(!plr->IsBeingTeleportedFar())
@@ -2118,10 +2118,10 @@ void Map::UpdateObjectVisibility( WorldObject* obj, Cell cell, CellPair cellpair
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);
-
+
CellLock<ReadGuard> cell_lock(cell, cellpair);
cell_lock->Visit(cell_lock, player_notifier, *this, *player, GetVisibilityDistance());
}
@@ -2129,7 +2129,7 @@ void Map::UpdatePlayerVisibility( Player* player, Cell cell, CellPair cellpair )
void Map::UpdateObjectsVisibilityFor( Player* player, Cell cell, CellPair cellpair )
{
MaNGOS::VisibleNotifier notifier(*player);
-
+
cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
TypeContainerVisitor<MaNGOS::VisibleNotifier, WorldTypeMapContainer > world_notifier(notifier);
@@ -2137,34 +2137,34 @@ void Map::UpdateObjectsVisibilityFor( Player* player, Cell cell, CellPair cellpa
CellLock<GridReadGuard> cell_lock(cell, cellpair);
cell_lock->Visit(cell_lock, world_notifier, *this, *player, GetVisibilityDistance());
cell_lock->Visit(cell_lock, grid_notifier, *this, *player, GetVisibilityDistance());
-
+
// send data
notifier.Notify();
}
-
+
void Map::PlayerRelocationNotify( Player* player, Cell cell, CellPair cellpair )
{
CellLock<ReadGuard> cell_lock(cell, cellpair);
MaNGOS::PlayerRelocationNotifier relocationNotifier(*player);
cell.data.Part.reserved = ALL_DISTRICT;
-
+
TypeContainerVisitor<MaNGOS::PlayerRelocationNotifier, GridTypeMapContainer > p2grid_relocation(relocationNotifier);
TypeContainerVisitor<MaNGOS::PlayerRelocationNotifier, WorldTypeMapContainer > p2world_relocation(relocationNotifier);
-
+
cell_lock->Visit(cell_lock, p2grid_relocation, *this, *player, MAX_CREATURE_ATTACK_RADIUS);
cell_lock->Visit(cell_lock, p2world_relocation, *this, *player, MAX_CREATURE_ATTACK_RADIUS);
}
-
+
void Map::CreatureRelocationNotify(Creature *creature, Cell cell, CellPair cellpair)
{
CellLock<ReadGuard> cell_lock(cell, cellpair);
MaNGOS::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);
-
+
cell_lock->Visit(cell_lock, c2world_relocation, *this, *creature, MAX_CREATURE_ATTACK_RADIUS);
cell_lock->Visit(cell_lock, c2grid_relocation, *this, *creature, MAX_CREATURE_ATTACK_RADIUS);
}
@@ -2188,7 +2188,7 @@ void Map::SendInitSelf( Player * player )
// build other passengers at transport also (they always visible and marked as visible and will not send at visibility update at add to map
if(Transport* transport = player->GetTransport())
{
- for(Transport::PlayerSet::const_iterator itr = transport->GetPassengers().begin();itr!=transport->GetPassengers().end();++itr)
+ for (Transport::PlayerSet::const_iterator itr = transport->GetPassengers().begin(); itr!=transport->GetPassengers().end(); ++itr)
{
if(player!=(*itr) && player->HaveAtClient(*itr))
{
@@ -2364,7 +2364,7 @@ void Map::RemoveAllObjectsInRemoveList()
uint32 Map::GetPlayersCountExceptGMs() const
{
uint32 count = 0;
- for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
+ for (MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
if(!itr->getSource()->isGameMaster())
++count;
return count;
@@ -2372,7 +2372,7 @@ uint32 Map::GetPlayersCountExceptGMs() const
void Map::SendToPlayers(WorldPacket const* data) const
{
- for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
+ for (MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
itr->getSource()->GetSession()->SendPacket(data);
}
@@ -2380,20 +2380,20 @@ 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);
-
+
//we must find visible range in cells so we unload only non-visible cells...
float viewDist = GetVisibilityDistance();
int cell_range = (int)ceilf(viewDist / SIZE_OF_GRID_CELL) + 1;
-
+
cell_min << cell_range;
cell_min -= cell_range;
cell_max >> cell_range;
cell_max += cell_range;
- for(MapRefManager::const_iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter)
+ for (MapRefManager::const_iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter)
{
Player* plr = iter->getSource();
@@ -2403,7 +2403,7 @@ bool Map::ActiveObjectsNearGrid(uint32 x, uint32 y) const
return true;
}
- for(ActiveNonPlayers::const_iterator iter = m_activeNonPlayers.begin(); iter != m_activeNonPlayers.end(); ++iter)
+ for (ActiveNonPlayers::const_iterator iter = m_activeNonPlayers.begin(); iter != m_activeNonPlayers.end(); ++iter)
{
WorldObject* obj = *iter;
@@ -2707,7 +2707,7 @@ bool InstanceMap::Reset(uint8 method)
if(method == INSTANCE_RESET_ALL)
{
// notify the players to leave the instance so it can be reset
- for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
+ for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
itr->getSource()->SendResetFailedNotify(GetId());
}
else
@@ -2715,7 +2715,7 @@ bool InstanceMap::Reset(uint8 method)
if(method == INSTANCE_RESET_GLOBAL)
{
// set the homebind timer for players inside (1 minute)
- for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
+ for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
itr->getSource()->m_InstanceValid = false;
}
@@ -2749,7 +2749,7 @@ void InstanceMap::PermBindAllPlayers(Player *player)
Group *group = player->GetGroup();
// group members outside the instance group don't get bound
- for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
+ for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
{
Player* plr = itr->getSource();
// players inside an instance cannot be bound to other instances
@@ -2781,7 +2781,7 @@ void InstanceMap::UnloadAll()
void InstanceMap::SendResetWarnings(uint32 timeLeft) const
{
- for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
+ for (MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
itr->getSource()->SendInstanceResetWarning(GetId(), itr->getSource()->GetDifficulty(), timeLeft);
}
@@ -2870,7 +2870,7 @@ void BattleGroundMap::RemoveAllPlayers()
{
if(HavePlayers())
{
- for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
+ for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
{
Player* plr = itr->getSource();
if(!plr->IsBeingTeleportedFar())