Skip to content

Commit

Permalink
Core/Spell: Simplify Devour Magic cast check for dispellable auras.
Browse files Browse the repository at this point in the history
  • Loading branch information
robinsch committed Apr 16, 2015
1 parent 8cb2a1e commit 91fe6fe
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions src/server/game/Spells/Spell.cpp
Expand Up @@ -3863,34 +3863,10 @@ uint8 Spell::CanCast(bool strict)
if (m_spellInfo->Effect[i] == SPELL_EFFECT_DISPEL &&
m_spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK)
{
if (target)
if (Unit* target = m_targets.getUnitTarget())
{
// Fill possible dispell list
std::vector <Aura *> dispel_list;

Unit::AuraMap const& auras = target->GetAuras();
for (Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
{
Aura *aur = (*itr).second;
if (aur && (1 << aur->GetSpellProto()->Dispel) & dispelMask)
{
if (aur->GetSpellProto()->Dispel == DISPEL_MAGIC)
{
bool positive = true;
if (!aur->IsPositive())
positive = false;

// do not remove positive auras if friendly target
// negative auras if non-friendly target
if (aur->IsPositive() == target->IsFriendlyTo(m_caster))
continue;
}
// Add every aura stack to dispel list
for (uint32 stack_amount = 0; stack_amount < aur->GetStackAmount(); ++stack_amount)
dispel_list.push_back(aur);
}
}

target->GetDispellableAuraList(m_caster, dispelMask, dispel_list);
if (dispel_list.empty())
return SPELL_FAILED_NOTHING_TO_DISPEL;
}
Expand Down

0 comments on commit 91fe6fe

Please sign in to comment.