diff options
author | treeston <treeston.mmoc@gmail.com> | 2017-07-03 17:33:34 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2020-08-18 18:53:13 +0200 |
commit | 2c88d9f162ca158e73bdb03c5ad46c8b6a451d2f (patch) | |
tree | 63fdda8787f44bd1bfcda2ee094be032d552c875 /src/server | |
parent | bacc5ef94ec0f064248b871646d88955da04b725 (diff) |
Some more refactoring prep for combat/threat (#19930).
(cherry picked from commit 2739a5c5f5d5a359eee4eef1a6486ddcaf24faaf)
Diffstat (limited to 'src/server')
13 files changed, 17 insertions, 20 deletions
diff --git a/src/server/game/Combat/ThreatManager.h b/src/server/game/Combat/ThreatManager.h index e2d4b35e750..7066794e5b7 100644 --- a/src/server/game/Combat/ThreatManager.h +++ b/src/server/game/Combat/ThreatManager.h @@ -221,6 +221,7 @@ class TC_GAME_API ThreatManager // -- compatibility layer for combat rewrite (PR #19930) Trinity::IteratorPair<std::list<ThreatReference*>::const_iterator> GetSortedThreatList() const { auto& list = iThreatContainer.getThreatList(); return { list.cbegin(), list.cend() }; } Trinity::IteratorPair<std::list<ThreatReference*>::const_iterator> GetUnsortedThreatList() const { return GetSortedThreatList(); } + std::list<ThreatReference*> GetModifiableThreatList() const { return iThreatContainer.getThreatList(); } Unit* SelectVictim() { return getHostilTarget(); } Unit* GetCurrentVictim() const { if (ThreatReference* ref = getCurrentVictim()) return ref->GetVictim(); else return nullptr; } bool IsThreatListEmpty(bool includeOffline = false) const { return includeOffline ? areThreatListsEmpty() : isThreatListEmpty(); } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp index bc3b08b1ad8..a70793dd572 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp @@ -318,7 +318,7 @@ public: Unit* tank = me->GetThreatManager().GetCurrentVictim(); std::vector<Unit*> targets; - for (ThreatReference* ref : me->GetThreatManager().GetUnsortedThreatList()) + for (ThreatReference const* ref : me->GetThreatManager().GetUnsortedThreatList()) { Unit* target = ref->GetVictim(); if (target != tank && target->IsAlive() && target->GetTypeId() == TYPEID_PLAYER) diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp index e2f9588173e..9ed81e6f526 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp @@ -992,7 +992,7 @@ public: if (FelfirePortalTimer <= diff) { if (Creature* pPortal = DoSpawnCreature(NPC_FELFIRE_PORTAL, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 20000)) - for (ThreatReference* ref : me->GetThreatManager().GetUnsortedThreatList()) + for (ThreatReference const* ref : me->GetThreatManager().GetUnsortedThreatList()) AddThreat(ref->GetVictim(), 1.0f, pPortal); FelfirePortalTimer = 20000; } else FelfirePortalTimer -= diff; diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp index e6b496f5868..934ddbd4df6 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp @@ -148,7 +148,7 @@ class boss_moam : public CreatureScript { std::list<Unit*> targetList; { - for (ThreatReference* ref : me->GetThreatManager().GetUnsortedThreatList()) + for (ThreatReference const* ref : me->GetThreatManager().GetUnsortedThreatList()) if (ref->GetVictim()->GetTypeId() == TYPEID_PLAYER && ref->GetVictim()->GetPowerType() == POWER_MANA) targetList.push_back(ref->GetVictim()); } diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp index 151187a38fe..45e50529481 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp @@ -649,7 +649,7 @@ public: //Place all units in threat list on outside of stomach Stomach_Map.clear(); - for (ThreatReference* ref : me->GetThreatManager().GetUnsortedThreatList()) + for (ThreatReference const* ref : me->GetThreatManager().GetUnsortedThreatList()) Stomach_Map[ref->GetVictim()->GetGUID()] = false; //Outside stomach //Spawn 2 flesh tentacles diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp index 01b8ce4ad73..40301954ecb 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp @@ -610,7 +610,7 @@ struct boss_faction_championsAI : public BossAI void UpdateThreat() { - for (ThreatReference* ref : me->GetThreatManager().GetUnsortedThreatList()) + for (ThreatReference* ref : me->GetThreatManager().GetModifiableThreatList()) if (Player* victim = ref->GetVictim()->ToPlayer()) ref->SetThreat(1000000.0f * CalculateThreat(me->GetDistance2d(victim), victim->GetArmor(), victim->GetHealth())); } @@ -695,7 +695,7 @@ struct boss_faction_championsAI : public BossAI uint32 EnemiesInRange(float distance) { uint32 count = 0; - for (ThreatReference* ref : me->GetThreatManager().GetUnsortedThreatList()) + for (ThreatReference const* ref : me->GetThreatManager().GetUnsortedThreatList()) if (me->GetDistance2d(ref->GetVictim()) < distance) ++count; return count; diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp index 5b839e2e77e..5fa460e3370 100644 --- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp @@ -960,12 +960,9 @@ class npc_jaina_or_sylvanas_escape_hor : public CreatureScript void DeleteAllFromThreatList(Unit* target, ObjectGuid except) { - std::vector<ThreatReference*> toClear; - for (ThreatReference* ref : target->GetThreatManager().GetUnsortedThreatList()) + for (ThreatReference* ref : target->GetThreatManager().GetModifiableThreatList()) if (ref->GetVictim()->GetGUID() != except) - toClear.push_back(ref); - for (ThreatReference* ref : toClear) - ref->ClearThreat(); + ref->ClearThreat(); } void UpdateAI(uint32 diff) override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp index bb394bdbafc..33978ff7e16 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp @@ -490,7 +490,7 @@ class boss_blood_queen_lana_thel : public CreatureScript std::list<Player*> tempTargets; Unit* maintank = me->GetThreatManager().GetCurrentVictim(); - for (ThreatReference* ref : me->GetThreatManager().GetUnsortedThreatList()) + for (ThreatReference const* ref : me->GetThreatManager().GetUnsortedThreatList()) if (Player* refTarget = ref->GetVictim()->ToPlayer()) if (refTarget != maintank && (includeOfftank || (refTarget->GetGUID() != _offtankGUID))) tempTargets.push_back(refTarget->ToPlayer()); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index 47cfb36b759..9eec05cf352 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -505,7 +505,7 @@ class boss_professor_putricide : public CreatureScript { std::list<Unit*> targetList; { - for (ThreatReference* ref : me->GetThreatManager().GetUnsortedThreatList()) + for (ThreatReference const* ref : me->GetThreatManager().GetUnsortedThreatList()) if (Player* target = ref->GetVictim()->ToPlayer()) targetList.push_back(target); } diff --git a/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp b/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp index e6fd7ea3e15..85b51f14b12 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp @@ -124,8 +124,8 @@ public: ThreatManager const& mgr = me->GetThreatManager(); Unit* currentVictim = mgr.GetCurrentVictim(); - auto const& pair = mgr.GetSortedThreatList(); - auto it = pair.begin(), end = pair.end(); + auto list = mgr.GetModifiableThreatList(); + auto it = list.begin(), end = list.end(); if (it == end) EnterEvadeMode(EVADE_REASON_NO_HOSTILES); @@ -151,8 +151,7 @@ public: DoCast(pHatefulTarget, SPELL_HATEFUL_STRIKE, true); // add threat to highest threat targets - if (me->GetVictim() && me->IsWithinMeleeRange(me->GetVictim())) - AddThreat(me->GetVictim(), HATEFUL_THREAT_AMT); + AddThreat(currentVictim, HATEFUL_THREAT_AMT); if (secondThreat) secondThreat->AddThreat(HATEFUL_THREAT_AMT); if (thirdThreat) diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp index 2dbcaa7af95..a2cb29d53c8 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp @@ -1831,7 +1831,7 @@ class spell_malygos_vortex_visual : public SpellScriptLoader { if (Creature* caster = GetCaster()->ToCreature()) { - for (ThreatReference* ref : caster->GetThreatManager().GetUnsortedThreatList()) + for (ThreatReference const* ref : caster->GetThreatManager().GetUnsortedThreatList()) { if (Player* targetPlayer = ref->GetVictim()->ToPlayer()) { diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_blackheart_the_inciter.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_blackheart_the_inciter.cpp index c5e8f9fbba8..f7ece3c01e1 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_blackheart_the_inciter.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_blackheart_the_inciter.cpp @@ -109,7 +109,7 @@ class boss_blackheart_the_inciter : public CreatureScript { DoCast(me, SPELL_INCITE_CHAOS); - for (ThreatReference* ref : me->GetThreatManager().GetUnsortedThreatList()) + for (ThreatReference const* ref : me->GetThreatManager().GetUnsortedThreatList()) if (ref->GetVictim()->GetTypeId() == TYPEID_PLAYER) me->CastSpell(ref->GetVictim(), SPELL_INCITE_CHAOS_B, true); diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp index 73b6596edfc..a3c4c9d74ce 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp @@ -527,7 +527,7 @@ public: ThreatManager const& mgr = me->GetThreatManager(); std::list<Unit*> TargetList; Unit* currentVictim = mgr.GetCurrentVictim(); - for (ThreatReference* ref : mgr.GetSortedThreatList()) + for (ThreatReference const* ref : mgr.GetSortedThreatList()) { if (Player* tempTarget = ref->GetVictim()->ToPlayer()) if (tempTarget != currentVictim && TargetList.size()<5) |