Handle zero and negative loop increment offset

This commit is contained in:
Aussiemon 2025-04-05 00:07:37 -06:00
parent 647db01978
commit 3aab3f5839

View file

@ -479,7 +479,8 @@ namespace MWWorld
// This formula finds the number of missed increments necessary to make the rise hour a 24-day loop.
// The offset increases on the first day of the loop and is multiplied by the number of completed loops.
float incrementOffset = (24.0f - (24.0f / mDailyIncrement)) * std::floor((gameDay + startDay) / 24.0f);
float incrementOffset = (mDailyIncrement == 0.0f) ?
0.0f : (24.0f - std::abs(24.0f / mDailyIncrement)) * std::floor((gameDay + startDay) / 24.0f);
// This odd formula arises from the fact that on 16 Last Seed, 17 increments have occurred, meaning
// that upon starting a new game, it must only calculate the moon phase as far back as 1 Last Seed.