refactor(Core/Combat): DeleteThreatLists() become ClearAllThreat() (#11824)

refactor(Chore/Combat): DeleteThreatLists() become ClearAllThreat()
This commit is contained in:
Maelthyr
2022-05-23 10:51:52 +02:00
committed by GitHub
parent ae3ecb0f1a
commit dfc6adb081
40 changed files with 62 additions and 63 deletions

View File

@@ -43,14 +43,14 @@ void GuardAI::EnterEvadeMode(EvadeReason /*why*/)
{
me->GetMotionMaster()->MoveIdle();
me->CombatStop(true);
me->DeleteThreatList();
me->GetThreatMgr().ClearAllThreat();
return;
}
LOG_DEBUG("entities.unit", "Guard entry: {} enters evade mode.", me->GetEntry());
me->RemoveAllAuras();
me->DeleteThreatList();
me->GetThreatMgr().ClearAllThreat();
me->CombatStop(true);
// Remove ChaseMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead

View File

@@ -563,7 +563,7 @@ void PetAI::HandleReturnMovement()
me->GetCharmInfo()->SetForcedTargetGUID();
// xinef: remember that npcs summoned by npcs can also be pets
me->DeleteThreatList();
me->GetThreatMgr().ClearAllThreat();
me->ClearInPetCombat();
}

View File

@@ -305,7 +305,7 @@ bool CreatureAI::_EnterEvadeMode(EvadeReason /*why*/)
me->ClearComboPointHolders(); // Remove all combo points targeting this unit
// sometimes bosses stuck in combat?
me->DeleteThreatList();
me->GetThreatMgr().ClearAllThreat();
me->CombatStop(true);
me->LoadCreaturesAddon(true);
me->SetLootRecipient(nullptr);

View File

@@ -201,7 +201,7 @@ void npc_escortAI::ReturnToLastPoint()
void npc_escortAI::EnterEvadeMode(EvadeReason /*why*/)
{
me->RemoveAllAuras();
me->DeleteThreatList();
me->GetThreatMgr().ClearAllThreat();
me->CombatStop(true);
me->SetLootRecipient(nullptr);

View File

@@ -153,7 +153,7 @@ void FollowerAI::JustRespawned()
void FollowerAI::EnterEvadeMode(EvadeReason /*why*/)
{
me->RemoveAllAuras();
me->DeleteThreatList();
me->GetThreatMgr().ClearAllThreat();
me->CombatStop(true);
me->SetLootRecipient(nullptr);

View File

@@ -406,6 +406,13 @@ ThreatMgr::ThreatMgr(Unit* owner) : iCurrentVictim(nullptr), iOwner(owner), iUpd
{
}
void ThreatMgr::ClearAllThreat()
{
if (iOwner->CanHaveThreatList() && !isThreatListEmpty())
iOwner->SendClearThreatListOpcode();
clearReferences();
}
//============================================================
void ThreatMgr::clearReferences()

View File

@@ -236,6 +236,8 @@ public:
// -- compatibility layer for combat rewrite
void ResetAllThreat() { resetAllAggro(); }
void ClearAllThreat();
// Reset all aggro of unit in threadlist satisfying the predicate.
template<class PREDICATE> void resetAggro(PREDICATE predicate)
{

View File

@@ -13917,7 +13917,7 @@ void Unit::setDeathState(DeathState s, bool despawn)
if (s != ALIVE && s != JUST_RESPAWNED)
{
CombatStop();
DeleteThreatList();
GetThreatMgr().ClearAllThreat();
getHostileRefMgr().deleteReferences();
ClearComboPointHolders(); // any combo points pointed to unit lost at it death
@@ -14018,15 +14018,6 @@ void Unit::AddThreat(Unit* victim, float fThreat, SpellSchoolMask schoolMask, Sp
//======================================================================
void Unit::DeleteThreatList()
{
if (CanHaveThreatList() && !m_ThreatMgr.isThreatListEmpty())
SendClearThreatListOpcode();
m_ThreatMgr.clearReferences();
}
//======================================================================
void Unit::TauntApply(Unit* taunter)
{
ASSERT(GetTypeId() == TYPEID_UNIT);
@@ -15097,7 +15088,7 @@ void Unit::CleanupBeforeRemoveFromMap(bool finalCleanup)
CombatStop();
ClearComboPoints();
ClearComboPointHolders();
DeleteThreatList();
GetThreatMgr().ClearAllThreat();
getHostileRefMgr().deleteReferences();
GetMotionMaster()->Clear(false); // remove different non-standard movement generators.
}
@@ -17446,7 +17437,7 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp
if (!creature->IsPet() && creature->GetLootMode() > 0)
{
creature->DeleteThreatList();
creature->GetThreatMgr().ClearAllThreat();
// must be after setDeathState which resets dynamic flags
if (!creature->loot.isLooted())

View File

@@ -2105,7 +2105,6 @@ public:
[[nodiscard]] bool CanHaveThreatList() const;
void AddThreat(Unit* victim, float fThreat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellInfo const* threatSpell = nullptr);
float ApplyTotalThreatModifier(float fThreat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL);
void DeleteThreatList();
void TauntApply(Unit* victim);
void TauntFadeOut(Unit* taunter);
ThreatMgr& GetThreatMgr() { return m_ThreatMgr; }