From 30716344f2355258ff41e9c63e320d8ebb592989 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Mon, 16 Jul 2018 13:08:34 +0400 Subject: [PATCH] Fix possible division by zero in the fatigue calculation (bug #4510) --- CHANGELOG.md | 1 + apps/openmw/mwmechanics/creaturestats.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fde57f39..8c1f1dbe9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 31724bcbc..49823d7a5 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -157,7 +157,7 @@ namespace MWMechanics int endurance = getAttribute(ESM::Attribute::Endurance).getModified(); DynamicStat 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);