1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-06 18:40:23 +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);