mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-13 11:43:18 -04:00
Modernize codebase with Clang-Tidy range based loops (#24165)
Manual expansion of auto types into "typed types"
This commit is contained in:
@@ -169,12 +169,12 @@ Creature* SmartScript::FindCreatureNear(WorldObject* searchObject, ObjectGuid::L
|
||||
void SmartScript::OnReset()
|
||||
{
|
||||
ResetBaseObject();
|
||||
for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
|
||||
for (SmartScriptHolder& event : mEvents)
|
||||
{
|
||||
if (!((*i).event.event_flags & SMART_EVENT_FLAG_DONT_RESET))
|
||||
if (!(event.event.event_flags & SMART_EVENT_FLAG_DONT_RESET))
|
||||
{
|
||||
InitTimer((*i));
|
||||
(*i).runOnce = false;
|
||||
InitTimer(event);
|
||||
event.runOnce = false;
|
||||
}
|
||||
}
|
||||
ProcessEventsFor(SMART_EVENT_RESET);
|
||||
@@ -214,15 +214,15 @@ void SmartScript::ResetBaseObject()
|
||||
|
||||
void SmartScript::ProcessEventsFor(SMART_EVENT e, Unit* unit, uint32 var0, uint32 var1, bool bvar, SpellInfo const* spell, GameObject* gob)
|
||||
{
|
||||
for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
|
||||
for (SmartScriptHolder& event : mEvents)
|
||||
{
|
||||
SMART_EVENT eventType = SMART_EVENT(i->GetEventType());
|
||||
SMART_EVENT eventType = SMART_EVENT(event.GetEventType());
|
||||
if (eventType == SMART_EVENT_LINK)//special handling
|
||||
continue;
|
||||
|
||||
if (eventType == e)
|
||||
if (sConditionMgr->IsObjectMeetingSmartEventConditions(i->entryOrGuid, i->event_id, i->source_type, unit, GetBaseObject()))
|
||||
ProcessEvent(*i, unit, var0, var1, bvar, spell, gob);
|
||||
if (sConditionMgr->IsObjectMeetingSmartEventConditions(event.entryOrGuid, event.event_id, event.source_type, unit, GetBaseObject()))
|
||||
ProcessEvent(event, unit, var0, var1, bvar, spell, gob);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,8 +508,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
// Special handling for vehicles
|
||||
if (IsUnit(target))
|
||||
if (Vehicle* vehicle = target->ToUnit()->GetVehicleKit())
|
||||
for (SeatMap::iterator it = vehicle->Seats.begin(); it != vehicle->Seats.end(); ++it)
|
||||
if (Player* player = ObjectAccessor::GetPlayer(*target, it->second.Passenger.Guid))
|
||||
for (std::pair<int8 const, VehicleSeat>& seat : vehicle->Seats)
|
||||
if (Player* player = ObjectAccessor::GetPlayer(*target, seat.second.Passenger.Guid))
|
||||
player->AreaExploredOrEventHappens(e.action.quest.quest);
|
||||
|
||||
if (IsPlayer(target))
|
||||
@@ -837,8 +837,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
|
||||
// Special handling for vehicles
|
||||
if (Vehicle* vehicle = unit->GetVehicleKit())
|
||||
for (SeatMap::iterator it = vehicle->Seats.begin(); it != vehicle->Seats.end(); ++it)
|
||||
if (Player* passenger = ObjectAccessor::GetPlayer(*unit, it->second.Passenger.Guid))
|
||||
for (std::pair<int8 const, VehicleSeat>& seat : vehicle->Seats)
|
||||
if (Player* passenger = ObjectAccessor::GetPlayer(*unit, seat.second.Passenger.Guid))
|
||||
passenger->GroupEventHappens(e.action.quest.quest, GetBaseObject());
|
||||
break;
|
||||
}
|
||||
@@ -960,8 +960,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
}
|
||||
else if (IsUnit(target)) // Special handling for vehicles
|
||||
if (Vehicle* vehicle = target->ToUnit()->GetVehicleKit())
|
||||
for (SeatMap::iterator seatItr = vehicle->Seats.begin(); seatItr != vehicle->Seats.end(); ++seatItr)
|
||||
if (Player* player = ObjectAccessor::GetPlayer(*target, seatItr->second.Passenger.Guid))
|
||||
for (std::pair<int8 const, VehicleSeat>& seat : vehicle->Seats)
|
||||
if (Player* player = ObjectAccessor::GetPlayer(*target, seat.second.Passenger.Guid))
|
||||
player->KilledMonsterCredit(e.action.killedMonster.creature);
|
||||
}
|
||||
}
|
||||
@@ -2067,9 +2067,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (!path || path->nodes.empty())
|
||||
continue;
|
||||
|
||||
for (auto itr = path->nodes.begin(); itr != path->nodes.end(); ++itr)
|
||||
for (WaypointNode const& waypoint : path->nodes)
|
||||
{
|
||||
WaypointNode const waypoint = *itr;
|
||||
float distamceToThisNode = creature->GetDistance(waypoint.x, waypoint.y, waypoint.z);
|
||||
if (distamceToThisNode < distanceToClosest)
|
||||
{
|
||||
@@ -2811,9 +2810,9 @@ void SmartScript::GetTargets(ObjectVector& targets, SmartScriptHolder const& e,
|
||||
case SMART_TARGET_VEHICLE_PASSENGER:
|
||||
{
|
||||
if (me && me->IsVehicle())
|
||||
for (auto seatItr = me->GetVehicleKit()->Seats.begin(); seatItr != me->GetVehicleKit()->Seats.end(); ++seatItr)
|
||||
if (!e.target.vehicle.seatMask || (e.target.vehicle.seatMask & (1 << seatItr->first)))
|
||||
if (Unit* u = ObjectAccessor::GetUnit(*me, seatItr->second.Passenger.Guid))
|
||||
for (std::pair<int8 const, VehicleSeat>& seat : me->GetVehicleKit()->Seats)
|
||||
if (!e.target.vehicle.seatMask || (e.target.vehicle.seatMask & (1 << seat.first)))
|
||||
if (Unit* u = ObjectAccessor::GetUnit(*me, seat.second.Passenger.Guid))
|
||||
targets.push_back(u);
|
||||
break;
|
||||
}
|
||||
@@ -3513,12 +3512,12 @@ void SmartScript::UpdateTimer(SmartScriptHolder& e, uint32 const diff)
|
||||
invoker = ObjectAccessor::GetUnit(*me, mTimedActionListInvoker);
|
||||
ProcessEvent(e, invoker);
|
||||
e.enableTimed = false;//disable event if it is in an ActionList and was processed once
|
||||
for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
|
||||
for (SmartScriptHolder& scriptholder : mTimedActionList)
|
||||
{
|
||||
//find the first event which is not the current one and enable it
|
||||
if (i->event_id > e.event_id)
|
||||
if (scriptholder.event_id > e.event_id)
|
||||
{
|
||||
i->enableTimed = true;
|
||||
scriptholder.enableTimed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3542,8 +3541,8 @@ void SmartScript::InstallEvents()
|
||||
{
|
||||
if (!mInstallEvents.empty())
|
||||
{
|
||||
for (SmartAIEventList::iterator i = mInstallEvents.begin(); i != mInstallEvents.end(); ++i)
|
||||
mEvents.push_back(*i);//must be before UpdateTimers
|
||||
for (SmartScriptHolder& installevent : mInstallEvents)
|
||||
mEvents.push_back(installevent);//must be before UpdateTimers
|
||||
|
||||
mInstallEvents.clear();
|
||||
}
|
||||
@@ -3612,8 +3611,8 @@ void SmartScript::OnUpdate(uint32 const diff)
|
||||
|
||||
InstallEvents();//before UpdateTimers
|
||||
|
||||
for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
|
||||
UpdateTimer(*i, diff);
|
||||
for (SmartScriptHolder& mEvent : mEvents)
|
||||
UpdateTimer(mEvent, diff);
|
||||
|
||||
if (!mStoredEvents.empty())
|
||||
{
|
||||
@@ -3629,11 +3628,11 @@ void SmartScript::OnUpdate(uint32 const diff)
|
||||
if (!mTimedActionList.empty())
|
||||
{
|
||||
isProcessingTimedActionList = true;
|
||||
for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
|
||||
for (SmartScriptHolder& scriptholder : mTimedActionList)
|
||||
{
|
||||
if ((*i).enableTimed)
|
||||
if (scriptholder.enableTimed)
|
||||
{
|
||||
UpdateTimer(*i, diff);
|
||||
UpdateTimer(scriptholder, diff);
|
||||
needCleanup = false;
|
||||
}
|
||||
}
|
||||
@@ -3676,25 +3675,25 @@ void SmartScript::FillScript(SmartAIEventList e, WorldObject* obj, AreaTriggerEn
|
||||
TC_LOG_DEBUG("scripts.ai", "SmartScript: EventMap for AreaTrigger %u is empty but is using SmartScript.", at->id);
|
||||
return;
|
||||
}
|
||||
for (SmartAIEventList::iterator i = e.begin(); i != e.end(); ++i)
|
||||
for (SmartScriptHolder& scriptholder : e)
|
||||
{
|
||||
#ifndef TRINITY_DEBUG
|
||||
if ((*i).event.event_flags & SMART_EVENT_FLAG_DEBUG_ONLY)
|
||||
if (scriptholder.event.event_flags & SMART_EVENT_FLAG_DEBUG_ONLY)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
if ((*i).event.event_flags & SMART_EVENT_FLAG_DIFFICULTY_ALL)//if has instance flag add only if in it
|
||||
if (scriptholder.event.event_flags & SMART_EVENT_FLAG_DIFFICULTY_ALL)//if has instance flag add only if in it
|
||||
{
|
||||
if (obj && obj->GetMap()->IsDungeon())
|
||||
{
|
||||
if ((1 << (obj->GetMap()->GetSpawnMode()+1)) & (*i).event.event_flags)
|
||||
if ((1 << (obj->GetMap()->GetSpawnMode()+1)) & scriptholder.event.event_flags)
|
||||
{
|
||||
mEvents.push_back((*i));
|
||||
mEvents.push_back(scriptholder);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
mEvents.push_back((*i));//NOTE: 'world(0)' events still get processed in ANY instance mode
|
||||
mEvents.push_back(scriptholder);//NOTE: 'world(0)' events still get processed in ANY instance mode
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3756,8 +3755,8 @@ void SmartScript::OnInitialize(WorldObject* obj, AreaTriggerEntry const* at)
|
||||
|
||||
GetScript();//load copy of script
|
||||
|
||||
for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
|
||||
InitTimer((*i));//calculate timers for first time use
|
||||
for (SmartScriptHolder& event : mEvents)
|
||||
InitTimer(event);//calculate timers for first time use
|
||||
|
||||
ProcessEventsFor(SMART_EVENT_AI_INIT);
|
||||
InstallEvents();
|
||||
|
||||
Reference in New Issue
Block a user