diff options
author | Treeston <treeston.mmoc@gmail.com> | 2018-02-26 00:10:21 +0100 |
---|---|---|
committer | funjoker <funjoker109@gmail.com> | 2021-08-08 21:21:34 +0200 |
commit | 74cdf260e1e37d54ac1ce2045f05a2e50f7eceaa (patch) | |
tree | f8fbd580f5eb3825943821f72ca6944b5ff8cf1f /src/server/game/Combat/ThreatManager.cpp | |
parent | 16255112ab6a35a254919ec7244a28705f5d8ba9 (diff) |
Core/Threat: Fix taunt logic relying on unspecified behavior by unordered boost heap iterators. Use ordered iterators instead, this is cheap for our use case anyway. This will make taunt behave consistently again.
Closes #21499.
(cherry picked from commit 71b5ed6832ac4162754ec50f53cd76305f8a187a)
Diffstat (limited to 'src/server/game/Combat/ThreatManager.cpp')
-rw-r--r-- | src/server/game/Combat/ThreatManager.cpp | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp index 9cc86ceb625..f0d7cd163b0 100644 --- a/src/server/game/Combat/ThreatManager.cpp +++ b/src/server/game/Combat/ThreatManager.cpp @@ -404,26 +404,16 @@ void ThreatManager::MatchUnitThreatToHighestThreat(Unit* target) if (_sortedThreatList.empty()) return; - auto it = _sortedThreatList.begin(), end = _sortedThreatList.end(); + auto it = _sortedThreatList.ordered_begin(), end = _sortedThreatList.ordered_end(); ThreatReference const* highest = *it; - if (!highest->IsOnline()) + if (!highest->IsAvailable()) return; - if (highest->_taunted) // might need to skip this - new max could be one of the preceding elements (heap property) since there is only one taunt element + if (highest->IsTaunting() && ((++it) != end)) // might need to skip this - max threat could be the preceding element (there is only one taunt element) { - if ((++it) != end) - { - ThreatReference const* a = *it; - if (a->IsOnline() && a->GetThreat() > highest->GetThreat()) - highest = a; - - if ((++it) != end) - { - a = *it; - if (a->IsOnline() && a->GetThreat() > highest->GetThreat()) - highest = a; - } - } + ThreatReference const* a = *it; + if (a->IsAvailable() && a->GetThreat() > highest->GetThreat()) + highest = a; } AddThreat(target, highest->GetThreat() - GetThreat(target, true), nullptr, true, true); @@ -440,7 +430,7 @@ void ThreatManager::TauntUpdate() auto threatIt = _myThreatListEntries.find((*it)->GetCasterGUID()); if (threatIt == threatEnd) continue; - if (!threatIt->second->IsOnline()) + if (!threatIt->second->IsAvailable()) continue; tauntRef = threatIt->second; break; @@ -722,7 +712,7 @@ void ThreatManager::PurgeThreatListRef(ObjectGuid const& guid, bool sendRemove) _currentVictimRef = nullptr; _sortedThreatList.erase(ref->_handle); - if (sendRemove && ref->IsOnline()) + if (sendRemove && ref->IsAvailable()) SendRemoveToClients(ref->_victim); } |