Esempio n. 1
0
/**
 * 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();
}
Esempio n. 2
0
void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settings)
{
	/* Make sure there isn't any window that can influence anything
	 * related to the new game we're about to start/load. */
	UnInitWindowSystem();

	AllocateMap(size_x, size_y);

	_pause_mode = PM_UNPAUSED;
	_fast_forward = 0;
	_tick_counter = 0;
	_cur_tileloop_tile = 0;
	_thd.redsq = INVALID_TILE;
	if (reset_settings) MakeNewgameSettingsLive();

	if (reset_date) {
		SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1), 0);
		InitializeOldNames();
	}

	PoolBase::Clean(PT_NORMAL);

	ResetPersistentNewGRFData();

	InitializeSound();
	InitializeMusic();

	InitializeVehicles();

	InitNewsItemStructs();
	InitializeLandscape();
	InitializeRailGui();
	InitializeRoadGui();
	InitializeAirportGui();
	InitializeDockGui();
	InitializeObjectGui();
	InitializeAIGui();
	InitializeTrees();
	InitializeIndustries();
	InitializeObjects();
	InitializeBuildingCounts();

	InitializeNPF();

	InitializeCompanies();
	AI::Initialize();
	Game::Initialize();
	InitializeCheats();

	InitTextEffects();
#ifdef ENABLE_NETWORK
	NetworkInitChatMessage();
#endif /* ENABLE_NETWORK */
	InitializeAnimatedTiles();

	InitializeEconomy();

	ResetObjectToPlace();

	GamelogReset();
	GamelogStartAction(GLAT_START);
	GamelogRevision();
	GamelogMode();
	GamelogGRFAddList(_grfconfig);
	GamelogStopAction();
}