Fix possible division by zero in the fatigue calculation (bug #4510)

pull/1806/head
Andrei Kortunov 6 years ago
parent 0bd6078826
commit 30716344f2

@ -67,6 +67,7 @@
Bug #4496: SpellTurnLeft and SpellTurnRight animation groups are unused
Bug #4497: File names starting with x or X are not classified as animation
Bug #4503: Cast and ExplodeSpell commands increase alteration skill
Bug #4510: Division by zero in MWMechanics::CreatureStats::setAttribute
Feature #2606: Editor: Implemented (optional) case sensitive global search
Feature #3083: Play animation when NPC is casting spell via script
Feature #3276: Editor: Search- Show number of (remaining) search results and indicate a search without any results

@ -157,7 +157,7 @@ namespace MWMechanics
int endurance = getAttribute(ESM::Attribute::Endurance).getModified();
DynamicStat<float> fatigue = getFatigue();
float diff = (strength+willpower+agility+endurance) - fatigue.getBase();
float currentToBaseRatio = (fatigue.getCurrent() / fatigue.getBase());
float currentToBaseRatio = fatigue.getBase() > 0 ? (fatigue.getCurrent() / fatigue.getBase()) : 0;
fatigue.setModified(fatigue.getModified() + diff, 0);
fatigue.setCurrent(fatigue.getBase() * currentToBaseRatio);
setFatigue(fatigue);

Loading…
Cancel
Save