*Properly cast uint32 damage and healing as int32 to prevent overflow errors, by RammboNr5. Closes #94

--HG--
branch : trunk
This commit is contained in:
maximius
2009-11-18 16:31:21 -08:00
parent 0134b7fee8
commit e59ec6d814
+5 -5
View File
@@ -9515,14 +9515,14 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
DoneTotal += DoneAdvertisedBenefit * coeff * coeff2;
}
float tmpDamage = (pdamage + DoneTotal) * DoneTotalMod;
float tmpDamage = (int32(pdamage) + DoneTotal) * DoneTotalMod;
// apply spellmod to Done damage (flat and pct)
if (Player* modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, tmpDamage);
tmpDamage = (tmpDamage + TakenTotal) * TakenTotalMod;
return tmpDamage > 0 ? uint32(tmpDamage) : 0;
return uint32(std::max(tmpDamage, 0.0f));
}
int32 Unit::SpellBaseDamageBonus(SpellSchoolMask schoolMask)
@@ -10036,7 +10036,7 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint
}
// use float as more appropriate for negative values and percent applying
float heal = (healamount + DoneTotal)*DoneTotalMod;
float heal = (int32(healamount) + DoneTotal) * DoneTotalMod;
// apply spellmod to Done amount
if(Player* modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, heal);
@@ -10087,9 +10087,9 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint
if (GetGUID()==(*i)->GetCasterGUID() && (*i)->isAffectedOnSpell(spellProto) )
TakenTotalMod *= ((*i)->GetAmount() + 100.0f) / 100.0f;
heal = (heal + TakenTotal) * TakenTotalMod;
heal = (int32(heal) + TakenTotal) * TakenTotalMod;
return heal < 0 ? 0 : uint32(heal);
return uint32(std::max(heal, 0.0f));
}
int32 Unit::SpellBaseHealingBonus(SpellSchoolMask schoolMask)