Changeset - r19661:7686c3b3f2fe
[Not reviewed]
master
0 1 0
frosch - 12 years ago 2012-10-14 14:50:20
frosch@openttd.org
(svn r24592) -Codechange [FS#5241]: Set up the new date completely before calling various daily or monthly processings. (dihedral)
1 file changed with 15 insertions and 11 deletions:
0 comments (0 inline, 0 general)
src/date.cpp
Show inline comments
 
@@ -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;
 

	
 
	/* 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();
 
}
0 comments (0 inline, 0 general)