Core/Spell: kill old charge restoring system. Mods are fully handled by proc system now.

- Fixes an edge case of spell failing due to out of range and re-adding charges to an existing aura.
This commit is contained in:
ariel- authored and roc13x committed 2017-05-04 04:00:58 +01:00
1 parent c1accd4537
commit 69625f32fe
5 files changed
+12 -87

No files matched your search

@@ -21302,61 +21302,6 @@ void Player::AddSpellMod(SpellModifier* mod, bool apply)
m_spellMods[mod->op].erase(mod);
}
// Restore spellmods in case of failed cast
void Player::RestoreSpellMods(Spell* spell, uint32 ownerAuraId /*= 0*/, Aura* aura /*= nullptr*/)
{
if (!spell || spell->m_appliedMods.empty())
return;
std::list<Aura*> aurasQueue;
for (uint8 i = 0; i < MAX_SPELLMOD; ++i)
{
for (auto itr = m_spellMods[i].begin(); itr != m_spellMods[i].end(); ++itr)
{
SpellModifier* mod = *itr;
// Spellmods without charged aura cannot be charged
if (!mod->ownerAura->IsUsingCharges())
continue;
// Restore only specific owner aura mods
if (ownerAuraId && mod->spellId != ownerAuraId)
continue;
if (aura && mod->ownerAura != aura)
continue;
// Check if mod affected this spell
// First, check if the mod aura applied at least one spellmod to this spell
Spell::UsedSpellMods::iterator iterMod = spell->m_appliedMods.find(mod->ownerAura);
if (iterMod == spell->m_appliedMods.end())
continue;
// Second, check if the current mod is one of those applied by the mod aura
if (!(mod->mask & spell->m_spellInfo->SpellFamilyFlags))
continue;
// remove from list - This will be done after all mods have been gone through
// to ensure we iterate over all mods of an aura before removing said aura
// from applied mods (Else, an aura with two mods on the current spell would
// only see the first of its modifier restored)
aurasQueue.push_back(mod->ownerAura);
// add charges back to aura
mod->ownerAura->ModCharges(1);
}
}
for (Aura* aura : aurasQueue)
spell->m_appliedMods.erase(aura);
}
void Player::RestoreAllSpellMods(uint32 ownerAuraId /*= 0*/, Aura* aura /*= nullptr*/)
{
for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
if (Spell* spell = m_currentSpells[i])
RestoreSpellMods(spell, ownerAuraId, aura);
}
bool Player::HasSpellModApplied(SpellModifier* mod, Spell* spell)
{
if (!spell)