コード例 #1
0
ファイル: date.cpp プロジェクト: dolly22/openttd-sai
/**
 * Runs various procedures that have to be done yearly
 */
static void OnNewYear()
{
	CompaniesYearlyLoop();
	VehiclesYearlyLoop();
	TownsYearlyLoop();
	InvalidateWindowClassesData(WC_BUILD_STATION);
#ifdef ENABLE_NETWORK
	if (_network_server) NetworkServerYearlyLoop();
#endif /* ENABLE_NETWORK */

	if (_cur_year == _settings_client.gui.semaphore_build_before) ResetSignalVariant();

	/* check if we reached end of the game */
	if (_cur_year == ORIGINAL_END_YEAR) {
		ShowEndGameChart();
	/* check if we reached the maximum year, decrement dates by a year */
	} else if (_cur_year == MAX_YEAR + 1) {
		Vehicle *v;
		uint days_this_year;

		_cur_year--;
		days_this_year = IsLeapYear(_cur_year) ? DAYS_IN_LEAP_YEAR : DAYS_IN_YEAR;
		_date -= days_this_year;
		FOR_ALL_VEHICLES(v) v->date_of_last_service -= days_this_year;

#ifdef ENABLE_NETWORK
		/* Because the _date wraps here, and text-messages expire by game-days, we have to clean out
		 *  all of them if the date is set back, else those messages will hang for ever */
		NetworkInitChatMessage();
#endif /* ENABLE_NETWORK */
	}

	if (_settings_client.gui.auto_euro) CheckSwitchToEuro();
}
コード例 #2
0
ファイル: cheat_gui.cpp プロジェクト: xmirakulix/openttd-xmix
/**
 * Handle changing of the current year.
 * @param p1 Unused.
 * @param p2 +1 (increase) or -1 (decrease).
 * @return New year.
 */
static int32 ClickChangeDateCheat(int32 p1, int32 p2)
{
	YearMonthDay ymd;
	ConvertDateToYMD(_date, &ymd);

	p1 = Clamp(p1, MIN_YEAR, MAX_YEAR);
	if (p1 == _cur_year) return _cur_year;

	SetDate(ConvertYMDToDate(p1, ymd.month, ymd.day), _date_fract);
	EnginesMonthlyLoop();
	SetWindowDirty(WC_STATUS_BAR, 0);
	InvalidateWindowClassesData(WC_BUILD_STATION, 0);
	ResetSignalVariant();
	return _cur_year;
}