Core/Auras: Fix refresh of auras with spellmodifiers applied to currently cast spell.

This commit is contained in:
QAston
2011-06-21 19:59:17 +02:00
parent 65233f8e66
commit c4818f1892
5 changed files with 25 additions and 4 deletions
+11 -1
View File
@@ -19609,7 +19609,7 @@ void Player::AddSpellMod(SpellModifier* mod, bool apply)
}
// Restore spellmods in case of failed cast
void Player::RestoreSpellMods(Spell* spell, uint32 ownerAuraId)
void Player::RestoreSpellMods(Spell* spell, uint32 ownerAuraId, Aura* aura)
{
if (!spell || spell->m_appliedMods.empty())
return;
@@ -19628,6 +19628,9 @@ void Player::RestoreSpellMods(Spell* spell, uint32 ownerAuraId)
if (ownerAuraId && (ownerAuraId != mod->ownerAura->GetSpellProto()->Id))
continue;
if (aura && mod->ownerAura != aura)
continue;
// check if mod affected this spell
Spell::UsedSpellMods::iterator iterMod = spell->m_appliedMods.find(mod->ownerAura);
if (iterMod == spell->m_appliedMods.end())
@@ -19653,6 +19656,13 @@ void Player::RestoreSpellMods(Spell* spell, uint32 ownerAuraId)
}
}
void Player::RestoreAllSpellMods(uint32 ownerAuraId, Aura* aura)
{
for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
if (m_currentSpells[i])
RestoreSpellMods(m_currentSpells[i], ownerAuraId, aura);
}
void Player::RemoveSpellMods(Spell* spell)
{
if (!spell)
+2 -1
View File
@@ -1658,7 +1658,8 @@ class Player : public Unit, public GridObject<Player>
bool IsAffectedBySpellmod(SpellEntry const *spellInfo, SpellModifier *mod, Spell* spell = NULL);
template <class T> T ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell* spell = NULL);
void RemoveSpellMods(Spell* spell);
void RestoreSpellMods(Spell* spell, uint32 ownerAuraId=0);
void RestoreSpellMods(Spell* spell, uint32 ownerAuraId = 0, Aura* aura = NULL);
void RestoreAllSpellMods(uint32 ownerAuraId = 0, Aura* aura = NULL);
void DropModCharge(SpellModifier* mod, Spell* spell);
void SetSpellModTakingSpell(Spell* spell, bool apply);
+2 -2
View File
@@ -2115,6 +2115,8 @@ class Unit : public WorldObject
bool m_isSorted;
uint32 m_transform;
Spell* m_currentSpells[CURRENT_MAX_SPELL];
AuraMap m_ownedAuras;
AuraApplicationMap m_appliedAuras;
AuraList m_removedAuras;
@@ -2185,8 +2187,6 @@ class Unit : public WorldObject
uint32 m_CombatTimer;
uint32 m_lastManaUse; // msecs
Spell* m_currentSpells[CURRENT_MAX_SPELL];
Diminishing m_Diminishing;
// Manage all Units that are threatened by us
HostileRefManager m_HostileRefManager;
@@ -826,6 +826,7 @@ bool Aura::ModStackAmount(int32 num, AuraRemoveMode removeMode)
if (refresh)
{
RefreshSpellMods();
RefreshTimers();
// reset charges
@@ -835,6 +836,13 @@ bool Aura::ModStackAmount(int32 num, AuraRemoveMode removeMode)
return false;
}
void Aura::RefreshSpellMods()
{
for (Aura::ApplicationMap::const_iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
if (Player * player = appIter->second->GetTarget()->ToPlayer())
player->RestoreAllSpellMods(0, this);
}
bool Aura::IsPassive() const
{
return IsPassiveSpell(GetSpellProto());
@@ -142,6 +142,8 @@ class Aura
void SetStackAmount(uint8 num);
bool ModStackAmount(int32 num, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
void RefreshSpellMods();
uint8 GetCasterLevel() const { return m_casterLevel; }
bool IsPassive() const;