aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWarpten <vertozor@gmail.com>2013-12-08 15:06:10 +0100
committerWarpten <vertozor@gmail.com>2013-12-08 15:06:10 +0100
commit98d2dbbd3fffb3ece8cf8f1ea2174cfe4191013d (patch)
treed02475510dada425cbc3c9a05d26a1af7f360916 /src
parent0447806812f1a80b2177e777fd25122be3899066 (diff)
Core/Spells: Fixed rare issues where spell modifiers would not be correctly restored.
Happens in case of a spell having more than one modifier granted by an aura.
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Player/Player.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 2eed8e95e53..91e2e9f1834 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -20709,13 +20709,15 @@ void Player::RestoreSpellMods(Spell* spell, uint32 ownerAuraId, Aura* aura)
if (!spell || spell->m_appliedMods.empty())
return;
+ std::list<Aura*> aurasQueue;
+
for (uint8 i=0; i<MAX_SPELLMOD; ++i)
{
for (SpellModList::iterator itr = m_spellMods[i].begin(); itr != m_spellMods[i].end(); ++itr)
{
SpellModifier* mod = *itr;
- // spellmods without aura set cannot be charged
+ // Spellmods without aura set cannot be charged
if (!mod->ownerAura || !mod->ownerAura->IsUsingCharges())
continue;
@@ -20726,17 +20728,20 @@ void Player::RestoreSpellMods(Spell* spell, uint32 ownerAuraId, Aura* aura)
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
+ // 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;
- // secondly, check if the current mod is one of the spellmods applied by the mod aura
+ // 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
- spell->m_appliedMods.erase(iterMod);
+ // 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 mod charges back to mod
if (mod->charges == -1)
@@ -20744,15 +20749,22 @@ void Player::RestoreSpellMods(Spell* spell, uint32 ownerAuraId, Aura* aura)
else
mod->charges++;
- // Do not set more spellmods than avalible
+ // Do not set more spellmods than available
if (mod->ownerAura->GetCharges() < mod->charges)
mod->charges = mod->ownerAura->GetCharges();
// Skip this check for now - aura charges may change due to various reason
- /// @todo trac these changes correctly
+ /// @todo track these changes correctly
//ASSERT (mod->ownerAura->GetCharges() <= mod->charges);
}
}
+
+ for (std::list<Aura*>::iterator itr = aurasQueue.begin(); itr != aurasQueue.end(); ++itr)
+ {
+ Spell::UsedSpellMods::iterator iterMod = spell->m_appliedMods.find(*itr);
+ if (iterMod != spell->m_appliedMods.end())
+ spell->m_appliedMods.erase(iterMod);
+ }
}
void Player::RestoreAllSpellMods(uint32 ownerAuraId, Aura* aura)