1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2026-02-07 08:28:28 +00:00

fix potential miscalculation

This commit is contained in:
Kindi 2023-10-15 21:26:47 +08:00
parent 58a16dacbe
commit 7e087707cd

View file

@ -90,13 +90,9 @@ namespace MWLua
ptr.getClass().setRemainingUsageTime(ptr, cond);
else if (ptr.getClass().hasItemHealth(ptr))
{
const float lastChargeRemainder = ptr.getCellRef().getChargeIntRemainder();
// if the value set is less than 0, chargeInt and chargeIntRemainder is set to 0
ptr.getCellRef().setChargeIntRemainder(std::max(0.f, std::modf(cond, &cond)));
ptr.getCellRef().setCharge(std::max(0.f, cond));
// resolve the remaining charge remainder to be subtracted
if (lastChargeRemainder < 0)
ptr.getCellRef().applyChargeRemainderToBeSubtracted(lastChargeRemainder);
}
else
invalidPropErr(prop, ptr);