aboutsummaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/ThreatManager.cpp14
-rw-r--r--src/game/ThreatManager.h22
2 files changed, 36 insertions, 0 deletions
diff --git a/src/game/ThreatManager.cpp b/src/game/ThreatManager.cpp
index cf688cf163a..ad22ba6b5c1 100644
--- a/src/game/ThreatManager.cpp
+++ b/src/game/ThreatManager.cpp
@@ -537,3 +537,17 @@ bool ThreatManager::isNeedUpdateToClient(uint32 time)
return false;
}
+// Reset all aggro without modifying the threadlist.
+void ThreatManager::resetAllAggro()
+{
+ std::list<HostilReference*> &threatlist = getThreatList();
+ if (threatlist.empty())
+ return;
+
+ for (std::list<HostilReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
+ {
+ (*itr)->setThreat(0);
+ }
+
+ setDirty(true);
+}
diff --git a/src/game/ThreatManager.h b/src/game/ThreatManager.h
index 1c0e2708a5e..3dd444a065d 100644
--- a/src/game/ThreatManager.h
+++ b/src/game/ThreatManager.h
@@ -215,6 +215,28 @@ class TRINITY_DLL_SPEC ThreatManager
void setDirty(bool bDirty) { iThreatContainer.setDirty(bDirty); }
+ // Reset all aggro without modifying the threadlist.
+ void resetAllAggro();
+
+ // Reset all aggro of unit in threadlist satisfying the predicate.
+ template<class PREDICATE> void resetAggro(PREDICATE predicate)
+ {
+ std::list<HostilReference*> &threatlist = getThreatList();
+ if (threatlist.empty())
+ return;
+
+ for (std::list<HostilReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
+ {
+ HostilReference* ref = (*itr);
+
+ if (predicate(ref->getTarget()))
+ {
+ ref->setThreat(0);
+ setDirty(true);
+ }
+ }
+ }
+
// methods to access the lists from the outside to do some dirty manipulation (scriping and such)
// I hope they are used as little as possible.
std::list<HostilReference*>& getThreatList() { return iThreatContainer.getThreatList(); }