Mercurial > hg > openttd
changeset 19683:fbd8b0e6d196 draft
(svn r24592) -Codechange [FS#5241]: Set up the new date completely before calling various daily or monthly processings. (dihedral)
author | frosch <frosch@openttd.org> |
---|---|
date | Sun, 14 Oct 2012 14:50:20 +0000 |
parents | 190fabeeaf1f |
children | 1a33aa7515fb |
files | src/date.cpp |
diffstat | 1 files changed, 15 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/date.cpp +++ b/src/date.cpp @@ -277,24 +277,28 @@ 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; + + /* 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; + _cur_year = ymd.year; + + /* yes, call various daily loops */ + OnNewDay(); /* yes, call various monthly loops */ - _cur_month = ymd.month; - OnNewMonth(); - - /* check if we entered a new year? */ - if (ymd.year == _cur_year) return; + if (new_month) OnNewMonth(); /* yes, call various yearly loops */ - _cur_year = ymd.year; - OnNewYear(); + if (new_year) OnNewYear(); }