summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/date.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/date.cpp b/src/date.cpp
index d28dd36ca..db066263d 100644
--- a/src/date.cpp
+++ b/src/date.cpp
@@ -277,24 +277,28 @@ void IncreaseDate()
if (_date_fract < DAY_TICKS) return;
_date_fract = 0;
- /* increase day counter and call various daily loops */
+ /* increase day counter */
_date++;
- OnNewDay();
YearMonthDay ymd;
+ ConvertDateToYMD(_date, &ymd);
/* check if we entered a new month? */
- ConvertDateToYMD(_date, &ymd);
- if (ymd.month == _cur_month) return;
+ bool new_month = ymd.month != _cur_month;
- /* yes, call various monthly loops */
+ /* check if we entered a new year? */
+ bool new_year = ymd.year != _cur_year;
+
+ /* update internal variables before calling the daily/monthly/yearly loops */
_cur_month = ymd.month;
- OnNewMonth();
+ _cur_year = ymd.year;
- /* check if we entered a new year? */
- if (ymd.year == _cur_year) return;
+ /* yes, call various daily loops */
+ OnNewDay();
+
+ /* yes, call various monthly loops */
+ if (new_month) OnNewMonth();
/* yes, call various yearly loops */
- _cur_year = ymd.year;
- OnNewYear();
+ if (new_year) OnNewYear();
}