diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2016-09-04 19:41:17 -0300 |
|---|---|---|
| committer | ariel- <ariel-@users.noreply.github.com> | 2016-09-04 19:46:12 -0300 |
| commit | 932d31598d697bd6cdb4f83ec70018e789984948 (patch) | |
| tree | d4630744d2e158eedf2dffab9b1ef01fff018e04 /src/server/game/Battlefield/Battlefield.cpp | |
| parent | 43c071d0c88fc546517902dbe0f58fd69bc04b18 (diff) | |
Core/Battlefield: container optimization
Diffstat (limited to 'src/server/game/Battlefield/Battlefield.cpp')
| -rw-r--r-- | src/server/game/Battlefield/Battlefield.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index 85e1c701aff..093fccb5977 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -197,7 +197,7 @@ bool Battlefield::Update(uint32 diff) void Battlefield::InvitePlayersInZoneToQueue() { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) - for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) + for (auto itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) InvitePlayerToQueue(player); } @@ -215,7 +215,7 @@ void Battlefield::InvitePlayersInQueueToWar() { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) { - for (GuidSet::const_iterator itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr) + for (auto itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr) { if (Player* player = ObjectAccessor::FindPlayer(*itr)) { @@ -234,7 +234,8 @@ void Battlefield::InvitePlayersInQueueToWar() void Battlefield::InvitePlayersInZoneToWar() { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) - for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) + { + for (auto itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) { if (Player* player = ObjectAccessor::FindPlayer(*itr)) { @@ -246,6 +247,7 @@ void Battlefield::InvitePlayersInZoneToWar() m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = time(nullptr) + 10; } } + } } void Battlefield::InvitePlayerToWar(Player* player) @@ -291,7 +293,7 @@ void Battlefield::InitStalker(uint32 entry, Position const& pos) void Battlefield::KickAfkPlayers() { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) - for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) + for (auto itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) if (player->isAFK()) KickPlayerFromBattlefield(*itr); @@ -396,13 +398,13 @@ void Battlefield::TeamCastSpell(TeamId team, int32 spellId) { if (spellId > 0) { - for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) + for (auto itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->CastSpell(player, uint32(spellId), true); } else { - for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) + for (auto itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->RemoveAuraFromStack(uint32(-spellId)); } @@ -411,7 +413,7 @@ void Battlefield::TeamCastSpell(TeamId team, int32 spellId) void Battlefield::BroadcastPacketToZone(WorldPacket& data) const { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) - for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) + for (auto itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->SendDirectMessage(&data); } @@ -419,7 +421,7 @@ void Battlefield::BroadcastPacketToZone(WorldPacket& data) const void Battlefield::BroadcastPacketToQueue(WorldPacket& data) const { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) - for (GuidSet::const_iterator itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr) + for (auto itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr) if (Player* player = ObjectAccessor::FindConnectedPlayer(*itr)) player->SendDirectMessage(&data); } @@ -427,7 +429,7 @@ void Battlefield::BroadcastPacketToQueue(WorldPacket& data) const void Battlefield::BroadcastPacketToWar(WorldPacket& data) const { for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) - for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) + for (auto itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->SendDirectMessage(&data); } @@ -441,7 +443,7 @@ void Battlefield::SendWarning(uint8 id, WorldObject const* target /*= nullptr*/) void Battlefield::SendUpdateWorldState(uint32 field, uint32 value) { for (uint8 i = 0; i < BG_TEAMS_COUNT; ++i) - for (GuidSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr) + for (auto itr = m_players[i].begin(); itr != m_players[i].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) player->SendUpdateWorldState(field, value); } @@ -482,7 +484,7 @@ void Battlefield::ShowNpc(Creature* creature, bool aggressive) // **************************************************** Group* Battlefield::GetFreeBfRaid(TeamId TeamId) { - for (GuidSet::const_iterator itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr) + for (auto itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr) if (Group* group = sGroupMgr->GetGroupByGUID(itr->GetCounter())) if (!group->IsFull()) return group; @@ -492,7 +494,7 @@ Group* Battlefield::GetFreeBfRaid(TeamId TeamId) Group* Battlefield::GetGroupPlayer(ObjectGuid guid, TeamId TeamId) { - for (GuidSet::const_iterator itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr) + for (auto itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr) if (Group* group = sGroupMgr->GetGroupByGUID(itr->GetCounter())) if (group->IsMember(guid)) return group; |
