diff --git a/apps/openmw/mwmechanics/magiceffects.cpp b/apps/openmw/mwmechanics/magiceffects.cpp index e75361628b..b01c5446a7 100644 --- a/apps/openmw/mwmechanics/magiceffects.cpp +++ b/apps/openmw/mwmechanics/magiceffects.cpp @@ -1,10 +1,20 @@ #include "magiceffects.hpp" +#include #include #include #include +namespace +{ + // Round value to prevent precision issues + void truncate(float& value) + { + value = std::roundf(value * 1024.f) / 1024.f; + } +} + namespace MWMechanics { EffectKey::EffectKey() : mId (0), mArg (-1) {} @@ -74,6 +84,7 @@ namespace MWMechanics { mModifier += param.mModifier; mBase += param.mBase; + truncate(mModifier); return *this; } @@ -81,6 +92,7 @@ namespace MWMechanics { mModifier -= param.mModifier; mBase -= param.mBase; + truncate(mModifier); return *this; }