*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) if (apply && spell->getState() == SPELL_STATE_FINISHED)
return; return;
if (apply) m_spellModTakingSpell = apply ? spell : NULL;
m_spellModTakingSpell = spell;
else
m_spellModTakingSpell = NULL;
} }
// send Proficiency // send Proficiency
+21 -13
View File
@@ -2814,6 +2814,7 @@ void Spell::cast(bool skipCheck)
if (m_caster->GetTypeId()==TYPEID_PLAYER) if (m_caster->GetTypeId()==TYPEID_PLAYER)
{ {
// Set spell which will drop charges for triggered cast spells // 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); ((Player*)m_caster)->SetSpellModTakingSpell(this, true);
} }
@@ -2825,6 +2826,14 @@ void Spell::cast(bool skipCheck)
{ {
SendCastResult(castResult); SendCastResult(castResult);
SendInterrupted(0); 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); finish(false);
SetExecutedCurrently(false); SetExecutedCurrently(false);
return; return;
@@ -2837,6 +2846,15 @@ void Spell::cast(bool skipCheck)
if(m_spellState == SPELL_STATE_FINISHED) if(m_spellState == SPELL_STATE_FINISHED)
{ {
SendInterrupted(0); 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); SetExecutedCurrently(false);
return; 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 // All targets passed - need finish phase
if (next_time == 0) if (next_time == 0)
{ {
@@ -3059,9 +3080,6 @@ uint64 Spell::handle_delayed(uint64 t_offset)
} }
else else
{ {
if (m_caster->GetTypeId()==TYPEID_PLAYER)
((Player*)m_caster)->SetSpellModTakingSpell(this, false);
// spell is unfinished, return next execution time // spell is unfinished, return next execution time
return next_time; return next_time;
} }
@@ -3315,17 +3333,7 @@ void Spell::finish(bool ok)
} }
if(!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; return;
}
if (m_caster->GetTypeId()==TYPEID_UNIT && ((Creature*)m_caster)->isSummon()) if (m_caster->GetTypeId()==TYPEID_UNIT && ((Creature*)m_caster)->isSummon())
{ {
+7 -12
View File
@@ -666,22 +666,17 @@ void Aura::Update(uint32 diff)
// Apply charged spellmods for channeled auras // Apply charged spellmods for channeled auras
// used for example when triggered spell of spell:10 is modded // used for example when triggered spell of spell:10 is modded
Spell *modSpell = NULL; Spell *modSpell = NULL;
Unit* caster = NULL; Player *modOwner = NULL;
if (IS_PLAYER_GUID(GetCasterGUID())) if(IS_PLAYER_GUID(GetCasterGUID()) && (modOwner = (Player*)GetCaster())
{ && (modSpell = modOwner->FindCurrentSpellBySpellId(GetId())))
caster = GetCaster(); modOwner->SetSpellModTakingSpell(modSpell, true);
if (caster)
{
modSpell = ((Player*)caster)->FindCurrentSpellBySpellId(GetId());
((Player*)caster)->SetSpellModTakingSpell(modSpell, true);
}
}
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (m_partAuras[i]) if (m_partAuras[i])
m_partAuras[i]->Update(diff); m_partAuras[i]->Update(diff);
if (caster) if (modOwner)
((Player*)caster)->SetSpellModTakingSpell(modSpell, false); modOwner->SetSpellModTakingSpell(modSpell, false);
} }
void AuraEffect::Update(uint32 diff) void AuraEffect::Update(uint32 diff)