diff --git a/src/daynightratio.h b/src/daynightratio.h index f959cdf6c..a7b93234e 100644 --- a/src/daynightratio.h +++ b/src/daynightratio.h @@ -52,15 +52,17 @@ inline u32 time_to_daynight_ratio(float time_of_day, bool smooth) return 1000; } + if (t <= 4625) // 4500 + 125 + return values[0][1]; + else if (t >= 6125) // 6000 + 125 + return 1000; for (u32 i=0; i < sizeof(values) / sizeof(*values); i++) { if (values[i][0] <= t) continue; - if (i == 0) - return values[i][1]; + float td0 = values[i][0] - values[i-1][0]; float f = (t - values[i-1][0]) / td0; return f * values[i][1] + (1.0 - f) * values[i-1][1]; } return 1000; - }