mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-28 12:52:25 +01:00
Core/UnitAI: Removed unneccessary null checks in SpellTargetSelector. CID 1357405 (#17630)
This commit is contained in:
@@ -267,10 +267,7 @@ 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)
|
||||
if (!target || _spellInfo->CheckTarget(_caster, target) != SPELL_CAST_OK)
|
||||
return false;
|
||||
|
||||
// copypasta from Spell::CheckRange
|
||||
@@ -282,10 +279,7 @@ bool SpellTargetSelector::operator()(Unit const* target) const
|
||||
if (_spellInfo->RangeEntry->type & SPELL_RANGE_MELEE)
|
||||
{
|
||||
rangeMod = _caster->GetCombatReach() + 4.0f / 3.0f;
|
||||
if (target)
|
||||
rangeMod += target->GetCombatReach();
|
||||
else
|
||||
rangeMod += _caster->GetCombatReach();
|
||||
rangeMod += target->GetCombatReach();
|
||||
|
||||
rangeMod = std::max(rangeMod, NOMINAL_MELEE_RANGE);
|
||||
}
|
||||
@@ -295,10 +289,7 @@ bool SpellTargetSelector::operator()(Unit const* target) const
|
||||
if (_spellInfo->RangeEntry->type & SPELL_RANGE_RANGED)
|
||||
{
|
||||
meleeRange = _caster->GetCombatReach() + 4.0f / 3.0f;
|
||||
if (target)
|
||||
meleeRange += target->GetCombatReach();
|
||||
else
|
||||
meleeRange += _caster->GetCombatReach();
|
||||
meleeRange += target->GetCombatReach();
|
||||
|
||||
meleeRange = std::max(meleeRange, NOMINAL_MELEE_RANGE);
|
||||
}
|
||||
@@ -306,17 +297,14 @@ bool SpellTargetSelector::operator()(Unit const* target) const
|
||||
minRange = _caster->GetSpellMinRangeForTarget(target, _spellInfo) + meleeRange;
|
||||
maxRange = _caster->GetSpellMaxRangeForTarget(target, _spellInfo);
|
||||
|
||||
if (target)
|
||||
{
|
||||
rangeMod = _caster->GetCombatReach();
|
||||
rangeMod += target->GetCombatReach();
|
||||
rangeMod = _caster->GetCombatReach();
|
||||
rangeMod += target->GetCombatReach();
|
||||
|
||||
if (minRange > 0.0f && !(_spellInfo->RangeEntry->type & SPELL_RANGE_RANGED))
|
||||
minRange += rangeMod;
|
||||
}
|
||||
if (minRange > 0.0f && !(_spellInfo->RangeEntry->type & SPELL_RANGE_RANGED))
|
||||
minRange += rangeMod;
|
||||
}
|
||||
|
||||
if (target && _caster->isMoving() && target->isMoving() && !_caster->IsWalking() && !target->IsWalking() &&
|
||||
if (_caster->isMoving() && target->isMoving() && !_caster->IsWalking() && !target->IsWalking() &&
|
||||
(_spellInfo->RangeEntry->type & SPELL_RANGE_MELEE || target->GetTypeId() == TYPEID_PLAYER))
|
||||
rangeMod += 5.0f / 3.0f;
|
||||
}
|
||||
@@ -326,7 +314,7 @@ bool SpellTargetSelector::operator()(Unit const* target) const
|
||||
minRange *= minRange;
|
||||
maxRange *= maxRange;
|
||||
|
||||
if (target && target != _caster)
|
||||
if (target != _caster)
|
||||
{
|
||||
if (_caster->GetExactDistSq(target) > maxRange)
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user