diff options
author | megamage <none@none> | 2009-08-31 00:14:45 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-08-31 00:14:45 -0500 |
commit | f5d4ee1e9535326993e33c7088804d846494d8f9 (patch) | |
tree | 327dd74355129f37275e375bb80a0e8a65c8a9e2 /src | |
parent | 9b0c7129465bfc98e13d6f7b0596d1e0c089ef01 (diff) |
*Fix a crash caused by unremoved spell mode. Thanks to Visagalis
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Player.cpp | 5 | ||||
-rw-r--r-- | src/game/Spell.cpp | 34 | ||||
-rw-r--r-- | src/game/SpellAuras.cpp | 21 |
3 files changed, 30 insertions, 30 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 3e536625887..577887b18e3 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -17592,10 +17592,7 @@ void Player::SetSpellModTakingSpell(Spell * spell, bool apply) if (apply && spell->getState() == SPELL_STATE_FINISHED) return; - if (apply) - m_spellModTakingSpell = spell; - else - m_spellModTakingSpell = NULL; + m_spellModTakingSpell = apply ? spell : NULL; } // send Proficiency diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 3eada04fe42..64758d62f94 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -2814,6 +2814,7 @@ void Spell::cast(bool skipCheck) if (m_caster->GetTypeId()==TYPEID_PLAYER) { // Set spell which will drop charges for triggered cast spells + // if not successfully casted, will be remove in finish(false) ((Player*)m_caster)->SetSpellModTakingSpell(this, true); } @@ -2825,6 +2826,14 @@ void Spell::cast(bool skipCheck) { SendCastResult(castResult); SendInterrupted(0); + //restore spell mods + if (m_caster->GetTypeId() == TYPEID_PLAYER) + { + ((Player*)m_caster)->RestoreSpellMods(this); + // cleanup after mod system + // triggered spell pointer can be not removed in some cases + ((Player*)m_caster)->SetSpellModTakingSpell(this, false); + } finish(false); SetExecutedCurrently(false); return; @@ -2837,6 +2846,15 @@ void Spell::cast(bool skipCheck) if(m_spellState == SPELL_STATE_FINISHED) { SendInterrupted(0); + //restore spell mods + if (m_caster->GetTypeId() == TYPEID_PLAYER) + { + ((Player*)m_caster)->RestoreSpellMods(this); + // cleanup after mod system + // triggered spell pointer can be not removed in some cases + ((Player*)m_caster)->SetSpellModTakingSpell(this, false); + } + finish(false); SetExecutedCurrently(false); return; } @@ -3046,6 +3064,9 @@ uint64 Spell::handle_delayed(uint64 t_offset) } } + if (m_caster->GetTypeId()==TYPEID_PLAYER) + ((Player*)m_caster)->SetSpellModTakingSpell(this, false); + // All targets passed - need finish phase if (next_time == 0) { @@ -3059,9 +3080,6 @@ uint64 Spell::handle_delayed(uint64 t_offset) } else { - if (m_caster->GetTypeId()==TYPEID_PLAYER) - ((Player*)m_caster)->SetSpellModTakingSpell(this, false); - // spell is unfinished, return next execution time return next_time; } @@ -3315,17 +3333,7 @@ void Spell::finish(bool ok) } if(!ok) - { - //restore spell mods - if (m_caster->GetTypeId() == TYPEID_PLAYER) - { - ((Player*)m_caster)->RestoreSpellMods(this); - // cleanup after mod system - // triggered spell pointer can be not removed in some cases - ((Player*)m_caster)->SetSpellModTakingSpell(this, false); - } return; - } if (m_caster->GetTypeId()==TYPEID_UNIT && ((Creature*)m_caster)->isSummon()) { diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 22c540ef9db..d8cbb6ba140 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -665,23 +665,18 @@ void Aura::Update(uint32 diff) // Apply charged spellmods for channeled auras // used for example when triggered spell of spell:10 is modded - Spell * modSpell = NULL; - Unit* caster = NULL; - if (IS_PLAYER_GUID(GetCasterGUID())) - { - caster = GetCaster(); - if (caster) - { - modSpell = ((Player*)caster)->FindCurrentSpellBySpellId(GetId()); - ((Player*)caster)->SetSpellModTakingSpell(modSpell, true); - } - } + Spell *modSpell = NULL; + Player *modOwner = NULL; + if(IS_PLAYER_GUID(GetCasterGUID()) && (modOwner = (Player*)GetCaster()) + && (modSpell = modOwner->FindCurrentSpellBySpellId(GetId()))) + modOwner->SetSpellModTakingSpell(modSpell, true); + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) if (m_partAuras[i]) m_partAuras[i]->Update(diff); - if (caster) - ((Player*)caster)->SetSpellModTakingSpell(modSpell, false); + if (modOwner) + modOwner->SetSpellModTakingSpell(modSpell, false); } void AuraEffect::Update(uint32 diff) |