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.cpp71
1 files changed, 32 insertions, 39 deletions
diff --git a/src/game/Map.cpp b/src/game/Map.cpp
index d859b8567cb..cc47cfbf051 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -698,11 +698,9 @@ void Map::Update(const uint32 &t_diff)
{
/// update players at tick
for (m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter)
- {
- Player* plr = m_mapRefIter->getSource();
- if(plr && plr->IsInWorld())
- plr->Update(t_diff);
- }
+ if (Player* plr = m_mapRefIter->getSource())
+ if (plr && plr->IsInWorld())
+ plr->Update(t_diff);
m_notifyTimer.Update(t_diff);
if(m_notifyTimer.Passed())
@@ -726,7 +724,7 @@ void Map::Update(const uint32 &t_diff)
{
Player* plr = m_mapRefIter->getSource();
- if(!plr->IsInWorld())
+ if (!plr->IsInWorld())
continue;
CellPair standing_cell(Trinity::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY()));
@@ -749,7 +747,7 @@ void Map::Update(const uint32 &t_diff)
// marked cells are those that have been visited
// don't visit the same cell twice
uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x;
- if(!isCellMarked(cell_id))
+ if (!isCellMarked(cell_id))
{
markCell(cell_id);
CellPair pair(x,y);
@@ -763,12 +761,12 @@ void Map::Update(const uint32 &t_diff)
}
}
- if(plr->m_seer != plr && !plr->GetVehicle())
+ if (plr->m_seer != plr && !plr->GetVehicle())
AddUnitToNotify(plr);
}
// non-player active objects
- if(!m_activeNonPlayers.empty())
+ if (!m_activeNonPlayers.empty())
{
for (m_activeNonPlayersIter = m_activeNonPlayers.begin(); m_activeNonPlayersIter != m_activeNonPlayers.end(); )
{
@@ -779,7 +777,7 @@ void Map::Update(const uint32 &t_diff)
// step to next-next, and if we step to end() then newly added objects can wait next update.
++m_activeNonPlayersIter;
- if(!obj->IsInWorld())
+ if (!obj->IsInWorld())
continue;
CellPair standing_cell(Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()));
@@ -2644,7 +2642,7 @@ void InstanceMap::Update(const uint32& t_diff)
{
Map::Update(t_diff);
- if(i_data)
+ if (i_data)
i_data->Update(t_diff);
}
@@ -2652,7 +2650,7 @@ void InstanceMap::Remove(Player *player, bool remove)
{
sLog.outDetail("MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to other map", player->GetName(), GetInstanceId(), GetMapName());
//if last player set unload timer
- if(!m_unloadTimer && m_mapRefManager.getSize() == 1)
+ if (!m_unloadTimer && m_mapRefManager.getSize() == 1)
m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld.getConfig(CONFIG_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY);
Map::Remove(player, remove);
// for normal instances schedule the reset after all players have left
@@ -2661,7 +2659,7 @@ void InstanceMap::Remove(Player *player, bool remove)
void InstanceMap::CreateInstanceData(bool load)
{
- if(i_data != NULL)
+ if (i_data != NULL)
return;
InstanceTemplate const* mInstance = objmgr.GetInstanceTemplate(GetId());
@@ -2671,12 +2669,12 @@ void InstanceMap::CreateInstanceData(bool load)
i_data = Script->CreateInstanceData(this);
}
- if(!i_data)
+ if (!i_data)
return;
i_data->Initialize();
- if(load)
+ if (load)
{
// TODO: make a global storage for this
QueryResult* result = CharacterDatabase.PQuery("SELECT data FROM instance WHERE map = '%u' AND id = '%u'", GetId(), i_InstanceId);
@@ -2684,7 +2682,7 @@ void InstanceMap::CreateInstanceData(bool load)
{
Field* fields = result->Fetch();
const char* data = fields[0].GetString();
- if(data && data != "")
+ if (data && data != "")
{
sLog.outDebug("Loading instance data for `%s` with id %u", objmgr.GetScriptName(i_script_id), i_InstanceId);
i_data->Load(data);
@@ -2702,9 +2700,9 @@ bool InstanceMap::Reset(uint8 method)
// note: since the map may not be loaded when the instance needs to be reset
// the instance must be deleted from the DB by InstanceSaveManager
- if(HavePlayers())
+ if (HavePlayers())
{
- if(method == INSTANCE_RESET_ALL)
+ 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)
@@ -2712,12 +2710,10 @@ bool InstanceMap::Reset(uint8 method)
}
else
{
- if(method == INSTANCE_RESET_GLOBAL)
- {
+ 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)
itr->getSource()->m_InstanceValid = false;
- }
// the unload timer is not started
// instead the map will unload immediately after the players have left
@@ -2737,11 +2733,11 @@ bool InstanceMap::Reset(uint8 method)
void InstanceMap::PermBindAllPlayers(Player *player)
{
- if(!IsDungeon())
+ if (!IsDungeon())
return;
InstanceSave *save = sInstanceSaveManager.GetInstanceSave(GetInstanceId());
- if(!save)
+ if (!save)
{
sLog.outError("Cannot bind players, no instance save available for map!");
return;
@@ -2755,7 +2751,7 @@ void InstanceMap::PermBindAllPlayers(Player *player)
// players inside an instance cannot be bound to other instances
// some players may already be permanently bound, in this case nothing happens
InstancePlayerBind *bind = plr->GetBoundInstance(save->GetMapId(), save->GetDifficulty());
- if(!bind || !bind->perm)
+ if (!bind || !bind->perm)
{
plr->BindToInstance(save, true);
WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4);
@@ -2764,7 +2760,7 @@ void InstanceMap::PermBindAllPlayers(Player *player)
}
// if the leader is not in the instance the group will not get a perm bind
- if(group && group->GetLeaderGUID() == plr->GetGUID())
+ if (group && group->GetLeaderGUID() == plr->GetGUID())
group->BindToInstance(save, true);
}
}
@@ -2773,7 +2769,7 @@ void InstanceMap::UnloadAll()
{
assert(!HavePlayers());
- if(m_resetAfterUnload == true)
+ if (m_resetAfterUnload == true)
objmgr.DeleteRespawnTimeForInstance(GetInstanceId());
Map::UnloadAll();
@@ -2790,10 +2786,10 @@ void InstanceMap::SetResetSchedule(bool on)
// only for normal instances
// the reset time is only scheduled when there are no payers inside
// it is assumed that the reset time will rarely (if ever) change while the reset is scheduled
- if(IsDungeon() && !HavePlayers() && !IsRaid() && !IsHeroic())
+ if (IsDungeon() && !HavePlayers() && !IsRaid() && !IsHeroic())
{
InstanceSave *save = sInstanceSaveManager.GetInstanceSave(GetInstanceId());
- if(!save) sLog.outError("InstanceMap::SetResetSchedule: cannot turn schedule %s, no save available for instance %d of %d", on ? "on" : "off", GetInstanceId(), GetId());
+ if (!save) sLog.outError("InstanceMap::SetResetSchedule: cannot turn schedule %s, no save available for instance %d of %d", on ? "on" : "off", GetInstanceId(), GetId());
else sInstanceSaveManager.ScheduleReset(on, save->GetResetTime(), InstanceSaveManager::InstResetEvent(0, GetId(), GetInstanceId()));
}
}
@@ -2801,7 +2797,7 @@ void InstanceMap::SetResetSchedule(bool on)
uint32 InstanceMap::GetMaxPlayers() const
{
InstanceTemplate const* iTemplate = objmgr.GetInstanceTemplate(GetId());
- if(!iTemplate)
+ if (!iTemplate)
return 0;
return IsHeroic() ? iTemplate->maxPlayersHeroic : iTemplate->maxPlayers;
}
@@ -2827,14 +2823,14 @@ void BattleGroundMap::InitVisibilityDistance()
bool BattleGroundMap::CanEnter(Player * player)
{
- if(player->GetMapRef().getTarget() == this)
+ if (player->GetMapRef().getTarget() == this)
{
sLog.outError("BGMap::CanEnter - player %u already in map!", player->GetGUIDLow());
assert(false);
return false;
}
- if(player->GetBattleGroundId() != GetInstanceId())
+ if (player->GetBattleGroundId() != GetInstanceId())
return false;
// player number limit is checked in bgmgr, no need to do it here
@@ -2868,15 +2864,12 @@ void BattleGroundMap::SetUnload()
void BattleGroundMap::RemoveAllPlayers()
{
- if(HavePlayers())
- {
+ if (HavePlayers())
for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
- {
- Player* plr = itr->getSource();
- if(!plr->IsBeingTeleportedFar())
- plr->TeleportTo(plr->GetBattleGroundEntryPoint());
- }
- }
+ if (Player* plr = itr->getSource())
+ if (!plr->IsBeingTeleportedFar())
+ plr->TeleportTo(plr->GetBattleGroundEntryPoint());
+
}
/// Put scripts in the execution queue