diff --git a/changelog.txt b/changelog.txt index 6933c973b..8eba54bed 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- == 11/03/2014 == Secrets: Fixed an overflow in melee lifetap calculations (int16 vs int32) +Secrets: Fixed overflow on AC and ATK values that can go out of range. == 11/02/2014 == Akkadius: Added out of range checking for Spell Save/Loads diff --git a/zone/attack.cpp b/zone/attack.cpp index eac3b0aa2..d13dafb2a 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -665,7 +665,7 @@ void Mob::MeleeMitigation(Mob *attacker, int32 &damage, int32 minhit, ExtraAttac //////////////////////////////////////////////////////// // Scorpious2k: Include AC in the calculation // use serverop variables to set values - int myac = GetAC(); + int32 myac = GetAC(); if(opts) { myac *= (1.0f - opts->armor_pen_percent); myac -= opts->armor_pen_flat; @@ -696,7 +696,7 @@ void Mob::MeleeMitigation(Mob *attacker, int32 &damage, int32 minhit, ExtraAttac } if (acreduction>0) { - damage -= (int) (GetAC() * acreduction/100.0f); + damage -= (int32) (GetAC() * acreduction/100.0f); } if (acrandom>0) { damage -= (myac * MakeRandomInt(0, acrandom) / 10000); diff --git a/zone/client.h b/zone/client.h index 7dfaee9e8..da3d8c1ea 100644 --- a/zone/client.h +++ b/zone/client.h @@ -403,9 +403,9 @@ public: virtual void CalcBonuses(); //these are all precalculated now - inline virtual int16 GetAC() const { return AC; } - inline virtual int16 GetATK() const { return ATK + itembonuses.ATK + spellbonuses.ATK + ((GetSTR() + GetSkill(SkillOffense)) * 9 / 10); } - inline virtual int16 GetATKBonus() const { return itembonuses.ATK + spellbonuses.ATK; } + inline virtual int32 GetAC() const { return AC; } + inline virtual int32 GetATK() const { return ATK + itembonuses.ATK + spellbonuses.ATK + ((GetSTR() + GetSkill(SkillOffense)) * 9 / 10); } + inline virtual int32 GetATKBonus() const { return itembonuses.ATK + spellbonuses.ATK; } inline virtual int GetHaste() const { return Haste; } int GetRawACNoShield(int &shield_ac) const; diff --git a/zone/mob.h b/zone/mob.h index 636d6b26c..f0f5a1691 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -340,9 +340,9 @@ public: inline Mob* GetTarget() const { return target; } virtual void SetTarget(Mob* mob); virtual inline float GetHPRatio() const { return max_hp == 0 ? 0 : ((float)cur_hp/max_hp*100); } - inline virtual int16 GetAC() const { return AC + itembonuses.AC + spellbonuses.AC; } - inline virtual int16 GetATK() const { return ATK + itembonuses.ATK + spellbonuses.ATK; } - inline virtual int16 GetATKBonus() const { return itembonuses.ATK + spellbonuses.ATK; } + inline virtual int32 GetAC() const { return AC + itembonuses.AC + spellbonuses.AC; } + inline virtual int32 GetATK() const { return ATK + itembonuses.ATK + spellbonuses.ATK; } + inline virtual int32 GetATKBonus() const { return itembonuses.ATK + spellbonuses.ATK; } inline virtual int16 GetSTR() const { return STR + itembonuses.STR + spellbonuses.STR; } inline virtual int16 GetSTA() const { return STA + itembonuses.STA + spellbonuses.STA; } inline virtual int16 GetDEX() const { return DEX + itembonuses.DEX + spellbonuses.DEX; }