Exemplo n.º 1
0
/**
 * Increases the tick counter, increases date  and possibly calls
 * procedures that have to be called daily, monthly or yearly.
 */
void IncreaseDate()
{
	/* increase day, and check if a new day is there? */
	_tick_counter++;

	if (_game_mode == GM_MENU) return;

	_date_fract++;
	if (_date_fract < DAY_TICKS) return;
	_date_fract = 0;

	/* increase day counter and call various daily loops */
	_date++;
	OnNewDay();

	YearMonthDay ymd;

	/* check if we entered a new month? */
	ConvertDateToYMD(_date, &ymd);
	if (ymd.month == _cur_month) return;

	/* yes, call various monthly loops */
	_cur_month = ymd.month;
	OnNewMonth();

	/* check if we entered a new year? */
	if (ymd.year == _cur_year) return;

	/* yes, call various yearly loops */
	_cur_year = ymd.year;
	OnNewYear();
}
Exemplo n.º 2
0
/**
 * Increases the tick counter, increases date  and possibly calls
 * procedures that have to be called daily, monthly or yearly.
 */
void IncreaseDate()
{
	/* increase day, and check if a new day is there? */
	_tick_counter++;

	if (_game_mode == GM_MENU) return;

	_date_fract++;
	if (_date_fract < DAY_TICKS) return;
	_date_fract = 0;

	/* increase day counter */
	_date++;

	YearMonthDay ymd;
	ConvertDateToYMD(_date, &ymd);

	/* check if we entered a new month? */
	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 */
	if (new_month) OnNewMonth();

	/* yes, call various yearly loops */
	if (new_year) OnNewYear();
}