From 25688fc8ebbc6dd17c9199e0b7ea019837df556c Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Fri, 11 Dec 2009 02:32:36 +0300 Subject: [PATCH] [8967] Fixed division by zero in Unit::CalcAbsorbResist. This also fix spell 31662 work. Signed-off-by: VladimirMangos --- src/game/Unit.cpp | 20 +++++++++++--------- src/shared/revision_nr.h | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 76dd4b20f..b5112b6df 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -1994,13 +1994,18 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe 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)->GetModifier()->m_amount -= currentAbsorb; if((*i)->GetModifier()->m_amount <= 0) @@ -2009,9 +2014,6 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe next = vManaShield.begin(); } - int32 manaReduction = int32(currentAbsorb * manaMultiplier); - pVictim->ApplyPowerMod(POWER_MANA, manaReduction, false); - RemainingDamage -= currentAbsorb; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 751323b36..1de986d24 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8966" + #define REVISION_NR "8967" #endif // __REVISION_NR_H__