diff options
author | Treeston <treeston.mmoc@gmail.com> | 2018-05-04 10:36:56 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-09-26 16:07:40 +0200 |
commit | 4634cfaa9f1e7064147f2c81a146234405f4e121 (patch) | |
tree | 84b2a0c425dcb7031ab3d132422c6f0f991cf0ed /src/server/game/Combat/ThreatManager.cpp | |
parent | f1ac141f25500a0f6ffd3c32b1185de2d9f9c940 (diff) |
Core/Threat: Fix taunt behavior in some edge cases
(cherry picked from commit 1b7ec4bc841cd51e17bb21a3d4b774102f195c46)
Diffstat (limited to 'src/server/game/Combat/ThreatManager.cpp')
-rw-r--r-- | src/server/game/Combat/ThreatManager.cpp | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp index d6c744dd43b..d9f3d0d4b4b 100644 --- a/src/server/game/Combat/ThreatManager.cpp +++ b/src/server/game/Combat/ThreatManager.cpp @@ -106,26 +106,28 @@ ThreatReference::OnlineState ThreatReference::SelectOnlineState() return ONLINE_STATE_ONLINE; } -void ThreatReference::UpdateTauntState(bool victimIsTaunting) +void ThreatReference::UpdateTauntState(TauntState state) { - if (victimIsTaunting) + if (state < TAUNT_STATE_TAUNT) // not taunting { - _taunted = TAUNT_STATE_TAUNT; - HeapNotifyIncreased(); - return; + // Check for SPELL_AURA_MOD_DETAUNT (applied from owner to victim) + for (AuraEffect const* eff : _victim->GetAuraEffectsByType(SPELL_AURA_MOD_DETAUNT)) + if (eff->GetCasterGUID() == _owner->GetGUID()) + { + state = TAUNT_STATE_DETAUNT; + break; + } } - // Check for SPELL_AURA_MOD_DETAUNT (applied from owner to victim) - for (AuraEffect const* eff : _victim->GetAuraEffectsByType(SPELL_AURA_MOD_DETAUNT)) - if (eff->GetCasterGUID() == _owner->GetGUID()) - { - _taunted = TAUNT_STATE_DETAUNT; - HeapNotifyDecreased(); - return; - } + if (state == _taunted) + return; + + std::swap(state, _taunted); - _taunted = TAUNT_STATE_NONE; - HeapNotifyChanged(); + if (_taunted < state) + HeapNotifyDecreased(); + else + HeapNotifyIncreased(); } void ThreatReference::ClearThreat(bool sendRemove) @@ -422,21 +424,21 @@ void ThreatManager::MatchUnitThreatToHighestThreat(Unit* target) void ThreatManager::TauntUpdate() { std::list<AuraEffect*> const& tauntEffects = _owner->GetAuraEffectsByType(SPELL_AURA_MOD_TAUNT); - auto threatEnd = _myThreatListEntries.end(); - ThreatReference* tauntRef = nullptr; + + uint32 state = ThreatReference::TAUNT_STATE_TAUNT; + std::unordered_map<ObjectGuid, ThreatReference::TauntState> tauntStates; // Only the last taunt effect applied by something still on our threat list is considered - for (auto it = tauntEffects.rbegin(), end = tauntEffects.rend(); it != end; ++it) + for (auto it = tauntEffects.begin(), end = tauntEffects.end(); it != end; ++it) + tauntStates[(*it)->GetCasterGUID()] = ThreatReference::TauntState(state++); + + for (auto const& pair : _myThreatListEntries) { - auto threatIt = _myThreatListEntries.find((*it)->GetCasterGUID()); - if (threatIt == threatEnd) - continue; - if (!threatIt->second->IsAvailable()) - continue; - tauntRef = threatIt->second; - break; + auto it = tauntStates.find(pair.first); + if (it != tauntStates.end()) + pair.second->UpdateTauntState(it->second); + else + pair.second->UpdateTauntState(); } - for (auto const& pair : _myThreatListEntries) - pair.second->UpdateTauntState(pair.second == tauntRef); } void ThreatManager::ResetAllThreat() |