Core/Combat: reset the ThreatManager update interval upon engaging the creature and move ThreatClear packet sending into the update cycle to mimic retail behavior
Port From (https://github.com/TrinityCore/TrinityCore/commit/24bda9c73dcd89d4da4e871e00fd83a24b8275d2)
This commit is contained in:
@@ -20,6 +20,7 @@ namespace Game.Combat
|
||||
bool _ownerCanHaveThreatList;
|
||||
|
||||
public bool NeedClientUpdate;
|
||||
bool _needThreatClearUpdate;
|
||||
uint _updateTimer;
|
||||
List<ThreatReference> _sortedThreatList = new();
|
||||
Dictionary<ObjectGuid, ThreatReference> _myThreatListEntries = new();
|
||||
@@ -73,18 +74,35 @@ namespace Game.Combat
|
||||
|
||||
public void Update(uint tdiff)
|
||||
{
|
||||
if (!CanHaveThreatList() || IsThreatListEmpty(true))
|
||||
if (!CanHaveThreatList())
|
||||
return;
|
||||
|
||||
if (_updateTimer <= tdiff)
|
||||
{
|
||||
UpdateVictim();
|
||||
if (_needThreatClearUpdate)
|
||||
{
|
||||
SendClearAllThreatToClients();
|
||||
_needThreatClearUpdate = false;
|
||||
}
|
||||
|
||||
if (!IsThreatListEmpty(true))
|
||||
UpdateVictim();
|
||||
|
||||
_updateTimer = THREAT_UPDATE_INTERVAL;
|
||||
}
|
||||
else
|
||||
_updateTimer -= tdiff;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// called from Creature::AtEngage
|
||||
/// should not be called from anywhere else
|
||||
/// </summary>
|
||||
public void ResetUpdateTimer()
|
||||
{
|
||||
_updateTimer = THREAT_UPDATE_INTERVAL;
|
||||
}
|
||||
|
||||
public Unit GetCurrentVictim()
|
||||
{
|
||||
if (_currentVictimRef == null || _currentVictimRef.ShouldBeOffline())
|
||||
|
||||
Reference in New Issue
Block a user