diff options
author | frosch <frosch@openttd.org> | 2012-10-14 14:50:20 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2012-10-14 14:50:20 +0000 |
commit | b5a485825b3ba6046bb0dc4c81540b6063cbb5b6 (patch) | |
tree | 08deb164d1ec00a648de99fd5188d20a8f97675f | |
parent | 7f80642aa7b83a86b90e8106f12d64e9a8be38fa (diff) | |
download | openttd-b5a485825b3ba6046bb0dc4c81540b6063cbb5b6.tar.xz |
(svn r24592) -Codechange [FS#5241]: Set up the new date completely before calling various daily or monthly processings. (dihedral)
-rw-r--r-- | src/date.cpp | 24 |
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(); } |