aboutsummaryrefslogtreecommitdiff
path: root/src/game/Unit.cpp
diff options
context:
space:
mode:
authorQAston <none@none>2009-07-02 00:03:57 +0200
committerQAston <none@none>2009-07-02 00:03:57 +0200
commit69f36d7af4724b68c7a3a104b2913d1e2743971b (patch)
treee36624b856ec14cf17384860e2d4fb05079dc7d1 /src/game/Unit.cpp
parentfd86e6a369b03d496988673f97409c5b74e99c52 (diff)
*Send threat messages to client - thanks to megamage for research.
--HG-- branch : trunk
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r--src/game/Unit.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 6da5ae063d4..80eb7c665bb 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -211,6 +211,9 @@ void Unit::Update( uint32 p_time )
m_Events.Update( p_time );
_UpdateSpells( p_time );
+ if (CanHaveThreatList() && getThreatManager().isNeedUpdateToClient(p_time))
+ SendThreatListUpdate();
+
// update combat timer only for players and pets
if (isInCombat() && IsControlledByPlayer())
{
@@ -11186,6 +11189,8 @@ void Unit::AddThreat(Unit* pVictim, float threat, SpellSchoolMask schoolMask, Sp
void Unit::DeleteThreatList()
{
+ if(CanHaveThreatList() && !m_ThreatManager.isThreatListEmpty())
+ SendClearThreatListOpcode();
m_ThreatManager.clearReferences();
}
@@ -14861,3 +14866,58 @@ void Unit::NearTeleportTo( float x, float y, float z, float orientation, bool ca
//SendMessageToSet(&data, false);
}
}
+
+void Unit::SendThreatListUpdate()
+{
+ if (uint32 count = getThreatManager().getThreatList().size())
+ {
+ sLog.outDebug( "WORLD: Send SMSG_THREAT_UPDATE Message" );
+ WorldPacket data(SMSG_THREAT_UPDATE, 8 + count * 8);
+ data.append(GetPackGUID());
+ data << uint32(count);
+ std::list<HostilReference*>& tlist = getThreatManager().getThreatList();
+ for (std::list<HostilReference*>::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr)
+ {
+ data.appendPackGUID((*itr)->getUnitGuid());
+ data << uint32((*itr)->getThreat());
+ }
+ SendMessageToSet(&data, false);
+ }
+}
+
+
+void Unit::SendChangeCurrentVictimOpcode(HostilReference* pHostilReference)
+{
+ if (uint32 count = getThreatManager().getThreatList().size())
+ {
+ sLog.outDebug( "WORLD: Send SMSG_HIGHEST_THREAT_UPDATE Message" );
+ WorldPacket data(SMSG_HIGHEST_THREAT_UPDATE, 8 + 8 + count * 8);
+ data.append(GetPackGUID());
+ data.appendPackGUID(pHostilReference->getUnitGuid());
+ data << uint32(count);
+ std::list<HostilReference*>& tlist = getThreatManager().getThreatList();
+ for (std::list<HostilReference*>::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr)
+ {
+ data.appendPackGUID((*itr)->getUnitGuid());
+ data << uint32((*itr)->getThreat());
+ }
+ SendMessageToSet(&data, false);
+ }
+}
+
+void Unit::SendClearThreatListOpcode()
+{
+ sLog.outDebug( "WORLD: Send SMSG_THREAT_CLEAR Message" );
+ WorldPacket data(SMSG_THREAT_CLEAR, 8);
+ data.append(GetPackGUID());
+ SendMessageToSet(&data, false);
+}
+
+void Unit::SendRemoveFromThreatListOpcode(HostilReference* pHostilReference)
+{
+ sLog.outDebug( "WORLD: Send SMSG_THREAT_REMOVE Message" );
+ WorldPacket data(SMSG_THREAT_REMOVE, 8 + 8);
+ data.append(GetPackGUID());
+ data.appendPackGUID(pHostilReference->getUnitGuid());
+ SendMessageToSet(&data, false);
+}