summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-10-14 14:50:20 +0000
committerfrosch <frosch@openttd.org>2012-10-14 14:50:20 +0000
commitb5a485825b3ba6046bb0dc4c81540b6063cbb5b6 (patch)
tree08deb164d1ec00a648de99fd5188d20a8f97675f /src
parent7f80642aa7b83a86b90e8106f12d64e9a8be38fa (diff)
downloadopenttd-b5a485825b3ba6046bb0dc4c81540b6063cbb5b6.tar.xz
(svn r24592) -Codechange [FS#5241]: Set up the new date completely before calling various daily or monthly processings. (dihedral)
Diffstat (limited to 'src')
-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();
}