mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Threat: Only send SMSG_THREAT_UPDATE if the threat list actually changed
(cherry picked from commit 4e5d1b7021)
This commit is contained in:
@@ -39,6 +39,7 @@ void ThreatReference::AddThreat(float amount)
|
||||
HeapNotifyIncreased();
|
||||
else
|
||||
HeapNotifyDecreased();
|
||||
_mgr._needClientUpdate = true;
|
||||
}
|
||||
|
||||
void ThreatReference::ScaleThreat(float factor)
|
||||
@@ -50,6 +51,7 @@ void ThreatReference::ScaleThreat(float factor)
|
||||
HeapNotifyIncreased();
|
||||
else
|
||||
HeapNotifyDecreased();
|
||||
_mgr._needClientUpdate = true;
|
||||
}
|
||||
|
||||
void ThreatReference::UpdateOffline()
|
||||
@@ -123,6 +125,8 @@ void ThreatReference::UpdateTauntState(TauntState state)
|
||||
HeapNotifyDecreased();
|
||||
else
|
||||
HeapNotifyIncreased();
|
||||
|
||||
_mgr._needClientUpdate = true;
|
||||
}
|
||||
|
||||
void ThreatReference::ClearThreat()
|
||||
@@ -155,7 +159,7 @@ void ThreatReference::UnregisterAndFree()
|
||||
return true;
|
||||
}
|
||||
|
||||
ThreatManager::ThreatManager(Unit* owner) : _owner(owner), _ownerCanHaveThreatList(false), _ownerEngaged(false), _updateTimer(THREAT_UPDATE_INTERVAL), _currentVictimRef(nullptr), _fixateRef(nullptr)
|
||||
ThreatManager::ThreatManager(Unit* owner) : _owner(owner), _ownerCanHaveThreatList(false), _ownerEngaged(false), _needClientUpdate(false), _updateTimer(THREAT_UPDATE_INTERVAL), _currentVictimRef(nullptr), _fixateRef(nullptr)
|
||||
{
|
||||
for (int8 i = 0; i < MAX_SPELL_SCHOOL; ++i)
|
||||
_singleSchoolModifiers[i] = 1.0f;
|
||||
@@ -363,7 +367,6 @@ void ThreatManager::AddThreat(Unit* target, float amount, SpellInfo const* spell
|
||||
if (it != _myThreatListEntries.end())
|
||||
{
|
||||
ThreatReference* const ref = it->second;
|
||||
|
||||
// causing threat causes SUPPRESSED threat states to stop being suppressed
|
||||
if (ref->GetOnlineState() == ThreatReference::ONLINE_STATE_SUPPRESSED)
|
||||
if (!ref->ShouldBeSuppressed())
|
||||
@@ -496,10 +499,14 @@ Unit* ThreatManager::GetFixateTarget() const
|
||||
void ThreatManager::UpdateVictim()
|
||||
{
|
||||
ThreatReference const* const newVictim = ReselectVictim();
|
||||
bool const newHighest = (newVictim != _currentVictimRef);
|
||||
bool const newHighest = newVictim && (newVictim != _currentVictimRef);
|
||||
|
||||
_currentVictimRef = newVictim;
|
||||
SendThreatListToClients(newVictim && newHighest);
|
||||
if (newHighest || _needClientUpdate)
|
||||
{
|
||||
SendThreatListToClients(newHighest);
|
||||
_needClientUpdate = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -766,6 +773,7 @@ void ThreatManager::SendThreatListToClients(bool newHighest) const
|
||||
|
||||
void ThreatManager::PutThreatListRef(ObjectGuid const& guid, ThreatReference* ref)
|
||||
{
|
||||
_needClientUpdate = true;
|
||||
auto& inMap = _myThreatListEntries[guid];
|
||||
ASSERT(!inMap, "Duplicate threat reference at %p being inserted on %s for %s - memory leak!", ref, _owner->GetGUID().ToString().c_str(), guid.ToString().c_str());
|
||||
inMap = ref;
|
||||
|
||||
@@ -203,6 +203,7 @@ class TC_GAME_API ThreatManager
|
||||
void PutThreatListRef(ObjectGuid const& guid, ThreatReference* ref);
|
||||
void PurgeThreatListRef(ObjectGuid const& guid);
|
||||
|
||||
bool _needClientUpdate;
|
||||
uint32 _updateTimer;
|
||||
threat_list_heap _sortedThreatList;
|
||||
std::unordered_map<ObjectGuid, ThreatReference*> _myThreatListEntries;
|
||||
|
||||
Reference in New Issue
Block a user