Core/Scripts: Added NULL checks to new target selectors, threat references aren't guaranteed to be valid always, also added (default true) player typeid check to NonTankTargetSelector
This commit is contained in:
@@ -255,6 +255,9 @@ SpellTargetSelector::SpellTargetSelector(Unit* caster, uint32 spellId) :
|
|||||||
|
|
||||||
bool SpellTargetSelector::operator()(Unit const* target) const
|
bool SpellTargetSelector::operator()(Unit const* target) const
|
||||||
{
|
{
|
||||||
|
if (!target)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (_spellInfo->CheckTarget(_caster, target) != SPELL_CAST_OK)
|
if (_spellInfo->CheckTarget(_caster, target) != SPELL_CAST_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -289,5 +292,11 @@ bool SpellTargetSelector::operator()(Unit const* target) const
|
|||||||
|
|
||||||
bool NonTankTargetSelector::operator()(Unit const* target) const
|
bool NonTankTargetSelector::operator()(Unit const* target) const
|
||||||
{
|
{
|
||||||
|
if (!target)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (_playerOnly && target->GetTypeId() != TYPEID_PLAYER)
|
||||||
|
return false;
|
||||||
|
|
||||||
return target != _source->getVictim();
|
return target != _source->getVictim();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,11 +116,12 @@ struct SpellTargetSelector : public std::unary_function<Unit*, bool>
|
|||||||
struct NonTankTargetSelector : public std::unary_function<Unit*, bool>
|
struct NonTankTargetSelector : public std::unary_function<Unit*, bool>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit NonTankTargetSelector(Creature* source) : _source(source) { }
|
NonTankTargetSelector(Creature* source, bool playerOnly = true) : _source(source), _playerOnly(playerOnly) { }
|
||||||
bool operator()(Unit const* target) const;
|
bool operator()(Unit const* target) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Creature const* _source;
|
Creature const* _source;
|
||||||
|
bool _playerOnly;
|
||||||
};
|
};
|
||||||
|
|
||||||
class UnitAI
|
class UnitAI
|
||||||
|
|||||||
Reference in New Issue
Block a user