Core/Threat: Only send SMSG_THREAT_UPDATE if the threat list actually changed
Port From (https://github.com/TrinityCore/TrinityCore/commit/b6f4b5340792bfdf5f73c6bccd3a5f4a926f00fa)
This commit is contained in:
@@ -34,6 +34,7 @@ namespace Game.Combat
|
|||||||
bool _ownerCanHaveThreatList;
|
bool _ownerCanHaveThreatList;
|
||||||
bool _ownerEngaged;
|
bool _ownerEngaged;
|
||||||
|
|
||||||
|
public bool NeedClientUpdate;
|
||||||
uint _updateTimer;
|
uint _updateTimer;
|
||||||
List<ThreatReference> _sortedThreatList = new();
|
List<ThreatReference> _sortedThreatList = new();
|
||||||
Dictionary<ObjectGuid, ThreatReference> _myThreatListEntries = new();
|
Dictionary<ObjectGuid, ThreatReference> _myThreatListEntries = new();
|
||||||
@@ -415,10 +416,14 @@ namespace Game.Combat
|
|||||||
void UpdateVictim()
|
void UpdateVictim()
|
||||||
{
|
{
|
||||||
ThreatReference newVictim = ReselectVictim();
|
ThreatReference newVictim = ReselectVictim();
|
||||||
bool newHighest = (newVictim != _currentVictimRef);
|
bool newHighest = newVictim != null && (newVictim != _currentVictimRef);
|
||||||
|
|
||||||
_currentVictimRef = newVictim;
|
_currentVictimRef = newVictim;
|
||||||
SendThreatListToClients(newVictim != null && newHighest);
|
if (newHighest || NeedClientUpdate)
|
||||||
|
{
|
||||||
|
SendThreatListToClients(newHighest);
|
||||||
|
NeedClientUpdate = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -688,6 +693,7 @@ namespace Game.Combat
|
|||||||
|
|
||||||
void PutThreatListRef(ObjectGuid guid, ThreatReference refe)
|
void PutThreatListRef(ObjectGuid guid, ThreatReference refe)
|
||||||
{
|
{
|
||||||
|
NeedClientUpdate = true;
|
||||||
Cypher.Assert(!_myThreatListEntries.ContainsKey(guid), $"Duplicate threat reference being inserted on {_owner.GetGUID()} for {guid}!");
|
Cypher.Assert(!_myThreatListEntries.ContainsKey(guid), $"Duplicate threat reference being inserted on {_owner.GetGUID()} for {guid}!");
|
||||||
_myThreatListEntries[guid] = refe;
|
_myThreatListEntries[guid] = refe;
|
||||||
_sortedThreatList.Add(refe);
|
_sortedThreatList.Add(refe);
|
||||||
@@ -813,6 +819,7 @@ namespace Game.Combat
|
|||||||
|
|
||||||
_baseAmount = Math.Max(_baseAmount + amount, 0.0f);
|
_baseAmount = Math.Max(_baseAmount + amount, 0.0f);
|
||||||
ListNotifyChanged();
|
ListNotifyChanged();
|
||||||
|
_mgr.NeedClientUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ScaleThreat(float factor)
|
public void ScaleThreat(float factor)
|
||||||
@@ -822,6 +829,7 @@ namespace Game.Combat
|
|||||||
|
|
||||||
_baseAmount *= factor;
|
_baseAmount *= factor;
|
||||||
ListNotifyChanged();
|
ListNotifyChanged();
|
||||||
|
_mgr.NeedClientUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateOffline()
|
public void UpdateOffline()
|
||||||
@@ -897,6 +905,7 @@ namespace Game.Combat
|
|||||||
Extensions.Swap(ref state, ref _taunted);
|
Extensions.Swap(ref state, ref _taunted);
|
||||||
|
|
||||||
ListNotifyChanged();
|
ListNotifyChanged();
|
||||||
|
_mgr.NeedClientUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearThreat()
|
public void ClearThreat()
|
||||||
|
|||||||
Reference in New Issue
Block a user