diff options
Diffstat (limited to 'src/daynightratio.h')
-rw-r--r-- | src/daynightratio.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/daynightratio.h b/src/daynightratio.h index 3b71ee84e..f959cdf6c 100644 --- a/src/daynightratio.h +++ b/src/daynightratio.h @@ -50,16 +50,17 @@ inline u32 time_to_daynight_ratio(float time_of_day, bool smooth) return values[i][1]; } return 1000; - } else { - for(u32 i=0; i<sizeof(values)/sizeof(*values); i++){ - if(values[i][0] <= t) + } + + for (u32 i=0; i < sizeof(values) / sizeof(*values); i++) { + if (values[i][0] <= t) continue; - if(i == 0) + 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; - } + } |