fix(Core/ObjectGuid): prevent creating copies when looping objects (#6852)

This commit is contained in:
Francesco Borzì
2021-07-10 15:54:16 +02:00
committed by GitHub
parent 2fcafa5f39
commit 4103fca5a4
40 changed files with 69 additions and 69 deletions

View File

@@ -279,7 +279,7 @@ public:
case INSTANCE_PROGRESS_CHAMPION_GROUP_DIED_3:
// revert to INSTANCE_PROGRESS_INITIAL
{
for (ObjectGuid const guid : VehicleList)
for (ObjectGuid const& guid : VehicleList)
if (Creature* veh = instance->GetCreature(guid))
{
veh->DespawnOrUnsummon();
@@ -567,7 +567,7 @@ public:
{
Counter = 0;
InstanceProgress = INSTANCE_PROGRESS_CHAMPIONS_UNMOUNTED;
for (ObjectGuid const guid : VehicleList)
for (ObjectGuid const& guid : VehicleList)
if (Creature* veh = instance->GetCreature(guid))
veh->DespawnOrUnsummon();
events.ScheduleEvent(EVENT_GRAND_CHAMPIONS_MOVE_SIDE, 0);

View File

@@ -200,7 +200,7 @@ public:
if( !IsHeroic() )
events.RescheduleEvent(EVENT_RESPAWN_SPHERE, 4000);
for (ObjectGuid guid : summons)
for (ObjectGuid const& guid : summons)
if (pInstance)
if (Creature* c = pInstance->instance->GetCreature(guid))
{

View File

@@ -73,7 +73,7 @@ public:
// move corpses
const ObjectGuid npcs[4] = { NPC_IcehowlGUID, NPC_JaraxxusGUID, NPC_LightbaneGUID, NPC_DarkbaneGUID };
for (const ObjectGuid i : npcs)
for (ObjectGuid const& i : npcs)
{
if (Creature* c = instance->GetCreature(i))
{
@@ -402,7 +402,7 @@ public:
InstanceProgress = INSTANCE_PROGRESS_FACTION_CHAMPIONS_DEAD;
events.RescheduleEvent(EVENT_SCENE_FACTION_CHAMPIONS_DEAD, 2500);
for (ObjectGuid guid : NPC_ChampionGUIDs)
for (ObjectGuid const& guid : NPC_ChampionGUIDs)
if (Creature* c = instance->GetCreature(guid))
c->DespawnOrUnsummon(15000);
NPC_ChampionGUIDs.clear();
@@ -455,7 +455,7 @@ public:
{
EncounterStatus = IN_PROGRESS;
AchievementTimer = 0;
for (ObjectGuid guid : NPC_ChampionGUIDs)
for (ObjectGuid const& guid : NPC_ChampionGUIDs)
if (Creature* c = instance->GetCreature(guid))
if (!c->IsInCombat())
if (Unit* target = c->SelectNearestTarget(200.0f))
@@ -1093,7 +1093,7 @@ public:
}
case EVENT_CHAMPIONS_ATTACK:
{
for (ObjectGuid guid : NPC_ChampionGUIDs)
for (ObjectGuid const& guid : NPC_ChampionGUIDs)
if (Creature* c = instance->GetCreature(guid))
{
c->SetReactState(REACT_AGGRESSIVE);
@@ -1493,7 +1493,7 @@ public:
case INSTANCE_PROGRESS_JARAXXUS_DEAD:
if( Creature* c = instance->GetCreature(NPC_BarrettGUID) )
c->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
for (ObjectGuid guid : NPC_ChampionGUIDs)
for (ObjectGuid const& guid : NPC_ChampionGUIDs)
if (Creature* c = instance->GetCreature(guid))
c->DespawnOrUnsummon();
NPC_ChampionGUIDs.clear();