diff options
author | megamage <none@none> | 2009-04-12 17:25:12 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-04-12 17:25:12 -0500 |
commit | 772e0eb72293c492fb716aead4bed3878fea2452 (patch) | |
tree | b77ca259a31da58ceafaeeac46498e8de4c1f540 /src | |
parent | 785dc693186357250b808825b6026abaec1c3e8f (diff) |
*Try to fix the crash caused by aura update (only add two return after m_target->RemoveAura(this))
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/SpellAuras.cpp | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 008ba1278a5..bf1540375a5 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -607,29 +607,39 @@ void Aura::Update(uint32 diff) m_duration -= diff; if (m_duration < 0) m_duration = 0; - m_timeCla -= diff; // all spells with manaPerSecond/manaPerSecondPerLevel have aura in effect 0 + if(m_timeCla > 0) + m_timeCla -= diff; if(m_timeCla <= 0) { if(Unit* caster = GetCaster()) { - Powers powertype = Powers(m_spellProto->powerType); - int32 manaPerSecond = m_spellProto->manaPerSecond + m_spellProto->manaPerSecondPerLevel * caster->getLevel(); - m_timeCla = 1000; - if (manaPerSecond) + if(int32 manaPerSecond = m_spellProto->manaPerSecond + m_spellProto->manaPerSecondPerLevel * caster->getLevel()) { - if(powertype==POWER_HEALTH) + m_timeCla = 1000; + + Powers powertype = Powers(m_spellProto->powerType); + if(powertype == POWER_HEALTH) { - if (caster->GetHealth()>manaPerSecond) + if (caster->GetHealth() > manaPerSecond) caster->ModifyHealth(-manaPerSecond); else + { m_target->RemoveAura(this); + return; + } } - else if (caster->GetPower(powertype)>=manaPerSecond) - caster->ModifyPower(powertype,-manaPerSecond); else - m_target->RemoveAura(this); + { + if (caster->GetPower(powertype) >= manaPerSecond) + caster->ModifyPower(powertype, -manaPerSecond); + else + { + m_target->RemoveAura(this); + return; + } + } } } } @@ -825,32 +835,21 @@ void AreaAuraEffect::Update(uint32 diff) void PersistentAreaAuraEffect::Update(uint32 diff) { - bool remove = false; - - // remove the aura if its caster or the dynamic object causing it was removed - // or if the target moves too far from the dynamic object - Unit *caster = GetCaster(); - if (caster) + if(Unit *caster = GetCaster()) { - DynamicObject *dynObj = caster->GetDynObject(GetId(), GetEffIndex()); - if (dynObj) + if(DynamicObject *dynObj = caster->GetDynObject(GetId(), GetEffIndex())) { - if (!m_target->IsWithinDistInMap(dynObj, dynObj->GetRadius())) - remove = true; + if(m_target->IsWithinDistInMap(dynObj, dynObj->GetRadius())) + { + AuraEffect::Update(diff); + return; + } } - else - remove = true; } - else - remove = true; - if(remove) - { - m_target->RemoveAura(GetParentAura()); - return; - } - - AuraEffect::Update(diff); + // remove the aura if its caster or the dynamic object causing it was removed + // or if the target moves too far from the dynamic object + m_target->RemoveAura(GetParentAura()); } void AuraEffect::ApplyModifier(bool apply, bool Real) |