mirror of https://github.com/OpenTTD/OpenTTD
(svn r24592) -Codechange [FS#5241]: Set up the new date completely before calling various daily or monthly processings. (dihedral)
parent
7f80642aa7
commit
b5a485825b
26
src/date.cpp
26
src/date.cpp
|
@ -277,24 +277,28 @@ void IncreaseDate()
|
||||||
if (_date_fract < DAY_TICKS) return;
|
if (_date_fract < DAY_TICKS) return;
|
||||||
_date_fract = 0;
|
_date_fract = 0;
|
||||||
|
|
||||||
/* increase day counter and call various daily loops */
|
/* increase day counter */
|
||||||
_date++;
|
_date++;
|
||||||
OnNewDay();
|
|
||||||
|
|
||||||
YearMonthDay ymd;
|
YearMonthDay ymd;
|
||||||
|
ConvertDateToYMD(_date, &ymd);
|
||||||
|
|
||||||
/* check if we entered a new month? */
|
/* check if we entered a new month? */
|
||||||
ConvertDateToYMD(_date, &ymd);
|
bool new_month = ymd.month != _cur_month;
|
||||||
if (ymd.month == _cur_month) return;
|
|
||||||
|
|
||||||
/* yes, call various monthly loops */
|
|
||||||
_cur_month = ymd.month;
|
|
||||||
OnNewMonth();
|
|
||||||
|
|
||||||
/* check if we entered a new year? */
|
/* check if we entered a new year? */
|
||||||
if (ymd.year == _cur_year) return;
|
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 */
|
||||||
|
if (new_month) OnNewMonth();
|
||||||
|
|
||||||
/* yes, call various yearly loops */
|
/* yes, call various yearly loops */
|
||||||
_cur_year = ymd.year;
|
if (new_year) OnNewYear();
|
||||||
OnNewYear();
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue