aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorUjp8LfXBJ6wCPR <github@lillecarl.com>2020-02-29 13:20:05 +0100
committerShauren <shauren.trinity@gmail.com>2021-12-22 15:48:01 +0100
commit43aa763d04b524f50c73b55802b11780b75a2f82 (patch)
treed4c0d102ce1dfe8d1ccee852179c93612c341deb /src/server
parent32a91914064cbc22bd85a649bf251b6e6d7fff12 (diff)
Part1: Modernize codebase with Clang-Tidy range based loops (#24164)
(cherry picked from commit fb75a958f02695f166481033203869940d98b537)
Diffstat (limited to 'src/server')
-rw-r--r--src/server/database/Database/QueryHolder.cpp4
-rw-r--r--src/server/game/AI/CoreAI/CombatAI.cpp29
2 files changed, 16 insertions, 17 deletions
diff --git a/src/server/database/Database/QueryHolder.cpp b/src/server/database/Database/QueryHolder.cpp
index 92877c97ded..dacd12913da 100644
--- a/src/server/database/Database/QueryHolder.cpp
+++ b/src/server/database/Database/QueryHolder.cpp
@@ -57,11 +57,11 @@ void SQLQueryHolderBase::SetPreparedResult(size_t index, PreparedResultSet* resu
SQLQueryHolderBase::~SQLQueryHolderBase()
{
- for (size_t i = 0; i < m_queries.size(); i++)
+ for (std::pair<PreparedStatementBase*, PreparedQueryResult>& query : m_queries)
{
/// if the result was never used, free the resources
/// results used already (getresult called) are expected to be deleted
- delete m_queries[i].first;
+ delete query.first;
}
}
diff --git a/src/server/game/AI/CoreAI/CombatAI.cpp b/src/server/game/AI/CoreAI/CombatAI.cpp
index e5bbab8139d..919215e91b4 100644
--- a/src/server/game/AI/CoreAI/CombatAI.cpp
+++ b/src/server/game/AI/CoreAI/CombatAI.cpp
@@ -55,9 +55,9 @@ void AggressorAI::UpdateAI(uint32 /*diff*/)
void CombatAI::InitializeAI()
{
- for (uint32 i = 0; i < MAX_CREATURE_SPELLS; ++i)
- if (me->m_spells[i] && sSpellMgr->GetSpellInfo(me->m_spells[i], me->GetMap()->GetDifficultyID()))
- Spells.push_back(me->m_spells[i]);
+ for (uint32 spell : me->m_spells)
+ if (spell && sSpellMgr->GetSpellInfo(spell, me->GetMap()->GetDifficultyID()))
+ Spells.push_back(spell);
CreatureAI::InitializeAI();
}
@@ -69,22 +69,22 @@ void CombatAI::Reset()
void CombatAI::JustDied(Unit* killer)
{
- for (SpellVector::iterator i = Spells.begin(); i != Spells.end(); ++i)
- if (AISpellInfoType const* info = GetAISpellInfo(*i, me->GetMap()->GetDifficultyID()))
+ for (uint32 spell : Spells)
+ if (AISpellInfoType const* info = GetAISpellInfo(spell, me->GetMap()->GetDifficultyID()))
if (info->condition == AICOND_DIE)
- me->CastSpell(killer, *i, true);
+ me->CastSpell(killer, spell, true);
}
void CombatAI::JustEngagedWith(Unit* who)
{
- for (SpellVector::iterator i = Spells.begin(); i != Spells.end(); ++i)
+ for (uint32 spell : Spells)
{
- if (AISpellInfoType const* info = GetAISpellInfo(*i, me->GetMap()->GetDifficultyID()))
+ if (AISpellInfoType const* info = GetAISpellInfo(spell, me->GetMap()->GetDifficultyID()))
{
if (info->condition == AICOND_AGGRO)
- me->CastSpell(who, *i, false);
+ me->CastSpell(who, spell, false);
else if (info->condition == AICOND_COMBAT)
- Events.ScheduleEvent(*i, info->cooldown + rand32() % info->cooldown);
+ Events.ScheduleEvent(spell, info->cooldown + rand32() % info->cooldown);
}
}
}
@@ -124,12 +124,11 @@ void CasterAI::InitializeAI()
_attackDistance = 30.0f;
- for (SpellVector::iterator itr = Spells.begin(); itr != Spells.end(); ++itr)
- if (AISpellInfoType const* info = GetAISpellInfo(*itr, me->GetMap()->GetDifficultyID()))
+ for (uint32 spell : Spells)
+ if (AISpellInfoType const* info = GetAISpellInfo(spell, me->GetMap()->GetDifficultyID()))
if (info->condition == AICOND_COMBAT && _attackDistance > info->maxRange)
_attackDistance = info->maxRange;
-
if (_attackDistance == 30.0f)
_attackDistance = MELEE_RANGE;
}
@@ -327,8 +326,8 @@ void VehicleAI::CheckConditions(uint32 diff)
{
if (Vehicle * vehicleKit = me->GetVehicleKit())
{
- for (SeatMap::iterator itr = vehicleKit->Seats.begin(); itr != vehicleKit->Seats.end(); ++itr)
- if (Unit * passenger = ObjectAccessor::GetUnit(*me, itr->second.Passenger.Guid))
+ for (std::pair<int8 const, VehicleSeat>& Seat : vehicleKit->Seats)
+ if (Unit* passenger = ObjectAccessor::GetUnit(*me, Seat.second.Passenger.Guid))
{
if (Player * player = passenger->ToPlayer())
{