From 56e0e57c99910381098c72e779ff607074781449 Mon Sep 17 00:00:00 2001 From: spp Date: Sun, 13 Dec 2009 09:52:56 +0100 Subject: [PATCH] Prevent a crash in Unit::CalcAbsorbResist. By Sarjuuk (Mangos merge), closes #735 --HG-- branch : trunk --- src/game/Unit.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 6170f2a04f..884588e045 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -2066,13 +2066,18 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff else currentAbsorb = RemainingDamage; - float manaMultiplier = (*i)->GetSpellProto()->EffectMultipleValue[(*i)->GetEffIndex()]; - if (Player *modOwner = pVictim->GetSpellModOwner()) - modOwner->ApplySpellMod((*i)->GetId(), SPELLMOD_MULTIPLE_VALUE, manaMultiplier); + if (float manaMultiplier = (*i)->GetSpellProto()->EffectMultipleValue[(*i)->GetEffIndex()]) + { + if(Player *modOwner = pVictim->GetSpellModOwner()) + modOwner->ApplySpellMod((*i)->GetId(), SPELLMOD_MULTIPLE_VALUE, manaMultiplier); - int32 maxAbsorb = int32(pVictim->GetPower(POWER_MANA) / manaMultiplier); - if (currentAbsorb > maxAbsorb) - currentAbsorb = maxAbsorb; + int32 maxAbsorb = int32(pVictim->GetPower(POWER_MANA) / manaMultiplier); + if (currentAbsorb > maxAbsorb) + currentAbsorb = maxAbsorb; + + int32 manaReduction = int32(currentAbsorb * manaMultiplier); + pVictim->ApplyPowerMod(POWER_MANA, manaReduction, false); + } (*i)->SetAmount((*i)->GetAmount()-currentAbsorb); if ((*i)->GetAmount() <= 0) @@ -2081,9 +2086,6 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff next = vManaShield.begin(); } - int32 manaReduction = int32(currentAbsorb * manaMultiplier); - pVictim->ApplyPowerMod(POWER_MANA, manaReduction, false); - RemainingDamage -= currentAbsorb; }