aboutsummaryrefslogtreecommitdiff
path: root/src/game/ThreatManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/ThreatManager.cpp')
-rw-r--r--src/game/ThreatManager.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/game/ThreatManager.cpp b/src/game/ThreatManager.cpp
index a0459aa81dc..e982cbbfe22 100644
--- a/src/game/ThreatManager.cpp
+++ b/src/game/ThreatManager.cpp
@@ -346,7 +346,7 @@ HostilReference* ThreatContainer::selectNextVictim(Creature* pAttacker, HostilRe
//=================== ThreatManager ==========================
//============================================================
-ThreatManager::ThreatManager(Unit* owner) : iCurrentVictim(NULL), iOwner(owner)
+ThreatManager::ThreatManager(Unit* owner) : iCurrentVictim(NULL), iOwner(owner), iUpdateTimer(THREAT_UPDATE_INTERVAL)
{
}
@@ -357,6 +357,7 @@ void ThreatManager::clearReferences()
iThreatContainer.clearReferences();
iThreatOfflineContainer.clearReferences();
iCurrentVictim = NULL;
+ iUpdateTimer = THREAT_UPDATE_INTERVAL;
}
//============================================================
@@ -470,6 +471,10 @@ void ThreatManager::tauntFadeOut(Unit *pTaunter)
void ThreatManager::setCurrentVictim(HostilReference* pHostilReference)
{
+ if (pHostilReference && pHostilReference != iCurrentVictim)
+ {
+ iOwner->SendChangeCurrentVictimOpcode(pHostilReference);
+ }
iCurrentVictim = pHostilReference;
}
@@ -515,6 +520,7 @@ void ThreatManager::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStat
setCurrentVictim(NULL);
setDirty(true);
}
+ iOwner->SendRemoveFromThreatListOpcode(hostilReference);
if(hostilReference->isOnline())
iThreatContainer.remove(hostilReference);
else
@@ -523,3 +529,16 @@ void ThreatManager::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStat
}
}
+bool ThreatManager::isNeedUpdateToClient(uint32 time)
+{
+ if (isThreatListEmpty())
+ return false;
+ if (time >= iUpdateTimer)
+ {
+ iUpdateTimer = THREAT_UPDATE_INTERVAL;
+ return true;
+ }
+ iUpdateTimer -= time;
+ return false;
+}
+