Skip to content

Commit 100790c

Browse files
committed
Core/Combat: add new getter to count Players in the threatlist
1 parent 9e53591 commit 100790c

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/server/game/Combat/ThreatManager.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,17 @@ size_t ThreatManager::GetThreatListSize() const
281281
return _sortedThreatList->size();
282282
}
283283

284+
uint32 ThreatManager::GetThreatListPlayerCount(bool includeOffline/* = false*/) const
285+
{
286+
if (includeOffline)
287+
return uint32(_sortedThreatList->size());
288+
uint32 returnValue = 0;
289+
for (ThreatReference const* ref : *_sortedThreatList)
290+
if (ref->IsAvailable() && ref->GetOwner()->GetTypeId() == TYPEID_PLAYER)
291+
++returnValue;
292+
return returnValue;
293+
}
294+
284295
Trinity::IteratorPair<ThreatManager::ThreatListIterator, std::nullptr_t> ThreatManager::GetUnsortedThreatList() const
285296
{
286297
auto itr = _myThreatListEntries.begin();

src/server/game/Combat/ThreatManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class TC_GAME_API ThreatManager
116116
// returns ThreatReference amount if a ref exists, 0.0f otherwise
117117
float GetThreat(Unit const* who, bool includeOffline = false) const;
118118
size_t GetThreatListSize() const;
119+
uint32 GetThreatListPlayerCount(bool includeOffline = false) const;
119120
// fastest of the three threat list getters - gets the threat list in "arbitrary" order
120121
// iterators will invalidate on adding/removing entries from the threat list; slightly less finicky than GetSorted.
121122
Trinity::IteratorPair<ThreatListIterator, std::nullptr_t> GetUnsortedThreatList() const;

0 commit comments

Comments
 (0)