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:
Shauren
2011-09-24 23:30:11 +02:00
parent da0229da8f
commit b07cc3751f
2 changed files with 11 additions and 1 deletions
+9
View File
@@ -255,6 +255,9 @@ SpellTargetSelector::SpellTargetSelector(Unit* caster, uint32 spellId) :
bool SpellTargetSelector::operator()(Unit const* target) const
{
if (!target)
return false;
if (_spellInfo->CheckTarget(_caster, target) != SPELL_CAST_OK)
return false;
@@ -289,5 +292,11 @@ bool SpellTargetSelector::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();
}
+2 -1
View File
@@ -116,11 +116,12 @@ struct SpellTargetSelector : public std::unary_function<Unit*, bool>
struct NonTankTargetSelector : public std::unary_function<Unit*, bool>
{
public:
explicit NonTankTargetSelector(Creature* source) : _source(source) { }
NonTankTargetSelector(Creature* source, bool playerOnly = true) : _source(source), _playerOnly(playerOnly) { }
bool operator()(Unit const* target) const;
private:
Creature const* _source;
bool _playerOnly;
};
class UnitAI