*Fix a crash caused by unremoved spell mode. Thanks to Visagalis

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-31 00:14:45 -05:00
parent 9b0c712946
commit f5d4ee1e95
3 changed files with 30 additions and 30 deletions
+1 -4
View File
@@ -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
+21 -13
View File
@@ -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())
{
+8 -13
View File
@@ -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)