mirror of
https://github.com/mangosfour/server.git
synced 2025-12-19 13:37:01 +00:00
[11136] Add Creature::FillGuidsListFromThreatList for safe guid iteration from threat list.
Often not 100%-safe iterate by live threat list because called code can modify threat list (reset for example).
This commit is contained in:
parent
37afce30e0
commit
5858aae4d9
3 changed files with 19 additions and 1 deletions
|
|
@ -2392,3 +2392,18 @@ void Creature::ApplyGameEventSpells(GameEventCreatureData const* eventData, bool
|
|||
if (cast_spell)
|
||||
CastSpell(this, cast_spell, true);
|
||||
}
|
||||
|
||||
void Creature::FillGuidsListFromThreatList( std::vector<ObjectGuid>& guids, uint32 maxamount /*= 0*/ )
|
||||
{
|
||||
if (!CanHaveThreatList())
|
||||
return;
|
||||
|
||||
ThreatList const& threats = getThreatManager().getThreatList();
|
||||
|
||||
maxamount = maxamount > 0 ? std::min(maxamount,uint32(threats.size())) : threats.size();
|
||||
|
||||
guids.reserve(guids.size() + maxamount);
|
||||
|
||||
for (ThreatList::const_iterator itr = threats.begin(); maxamount && itr != threats.end(); ++itr, --maxamount)
|
||||
guids.push_back((*itr)->getUnitGuid());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -430,7 +430,10 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
|||
bool IsTrainerOf(Player* player, bool msg) const;
|
||||
bool CanInteractWithBattleMaster(Player* player, bool msg) const;
|
||||
bool CanTrainAndResetTalentsOf(Player* pPlayer) const;
|
||||
|
||||
bool IsOutOfThreatArea(Unit* pVictim) const;
|
||||
void FillGuidsListFromThreatList(std::vector<ObjectGuid>& guids, uint32 maxamount = 0);
|
||||
|
||||
bool IsImmuneToSpell(SpellEntry const* spellInfo);
|
||||
// redefine Unit::IsImmuneToSpell
|
||||
bool IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11135"
|
||||
#define REVISION_NR "11136"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue