diff options
| author | spp <none@none> | 2009-12-13 09:52:56 +0100 |
|---|---|---|
| committer | spp <none@none> | 2009-12-13 09:52:56 +0100 |
| commit | 56e0e57c99910381098c72e779ff607074781449 (patch) | |
| tree | f9d7af81908a1b94d829562453ed8da6328da076 /src | |
| parent | df76273dd0f6fdfd2d3e2ba7f04e2a089ba8d4b8 (diff) | |
Prevent a crash in Unit::CalcAbsorbResist. By Sarjuuk (Mangos merge), closes #735
--HG--
branch : trunk
Diffstat (limited to 'src')
| -rw-r--r-- | src/game/Unit.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 6170f2a04fa..884588e0456 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; } |
