|
|
@ -179,6 +179,88 @@ static const Month _autosave_months[] = {
|
|
|
|
12, ///< every 12 months
|
|
|
|
12, ///< every 12 months
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 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();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Runs various procedures that have to be done monthly
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void OnNewMonth()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_debug_desync_level > 2) {
|
|
|
|
|
|
|
|
char name[MAX_PATH];
|
|
|
|
|
|
|
|
snprintf(name, lengthof(name), "dmp_cmds_%08x_%08x.sav", _settings_game.game_creation.generation_seed, _date);
|
|
|
|
|
|
|
|
SaveOrLoad(name, SL_SAVE, AUTOSAVE_DIR);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_settings_client.gui.autosave != 0 && (_cur_month % _autosave_months[_settings_client.gui.autosave]) == 0) {
|
|
|
|
|
|
|
|
_do_autosave = true;
|
|
|
|
|
|
|
|
RedrawAutosave();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InvalidateWindowClasses(WC_CHEATS);
|
|
|
|
|
|
|
|
CompaniesMonthlyLoop();
|
|
|
|
|
|
|
|
SubsidyMonthlyLoop();
|
|
|
|
|
|
|
|
EnginesMonthlyLoop();
|
|
|
|
|
|
|
|
TownsMonthlyLoop();
|
|
|
|
|
|
|
|
IndustryMonthlyLoop();
|
|
|
|
|
|
|
|
StationMonthlyLoop();
|
|
|
|
|
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
|
|
|
|
|
if (_network_server) NetworkServerMonthlyLoop();
|
|
|
|
|
|
|
|
#endif /* ENABLE_NETWORK */
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Runs various procedures that have to be done daily
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void OnNewDay()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
|
|
|
|
|
NetworkChatMessageDailyLoop();
|
|
|
|
|
|
|
|
#endif /* ENABLE_NETWORK */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DisasterDailyLoop();
|
|
|
|
|
|
|
|
IndustryDailyLoop();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InvalidateWindowWidget(WC_STATUS_BAR, 0, 0);
|
|
|
|
|
|
|
|
EnginesDailyLoop();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Runs the day_proc for every DAY_TICKS vehicle starting at daytick.
|
|
|
|
* Runs the day_proc for every DAY_TICKS vehicle starting at daytick.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -195,10 +277,12 @@ static void RunVehicleDayProc(uint daytick)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Increases the tick counter, increases date and possibly calls
|
|
|
|
|
|
|
|
* procedures that have to be called daily, monthly or yearly.
|
|
|
|
|
|
|
|
*/
|
|
|
|
void IncreaseDate()
|
|
|
|
void IncreaseDate()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
YearMonthDay ymd;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_game_mode == GM_MENU) {
|
|
|
|
if (_game_mode == GM_MENU) {
|
|
|
|
_tick_counter++;
|
|
|
|
_tick_counter++;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -213,85 +297,24 @@ void IncreaseDate()
|
|
|
|
if (_date_fract < DAY_TICKS) return;
|
|
|
|
if (_date_fract < DAY_TICKS) return;
|
|
|
|
_date_fract = 0;
|
|
|
|
_date_fract = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/* yeah, increase day counter and call various daily loops */
|
|
|
|
/* increase day counter and call various daily loops */
|
|
|
|
_date++;
|
|
|
|
_date++;
|
|
|
|
|
|
|
|
OnNewDay();
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
|
YearMonthDay ymd;
|
|
|
|
NetworkChatMessageDailyLoop();
|
|
|
|
|
|
|
|
#endif /* ENABLE_NETWORK */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DisasterDailyLoop();
|
|
|
|
|
|
|
|
IndustryDailyLoop();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_game_mode != GM_MENU) {
|
|
|
|
|
|
|
|
InvalidateWindowWidget(WC_STATUS_BAR, 0, 0);
|
|
|
|
|
|
|
|
EnginesDailyLoop();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* check if we entered a new month? */
|
|
|
|
/* check if we entered a new month? */
|
|
|
|
ConvertDateToYMD(_date, &ymd);
|
|
|
|
ConvertDateToYMD(_date, &ymd);
|
|
|
|
if (ymd.month == _cur_month) return;
|
|
|
|
if (ymd.month == _cur_month) return;
|
|
|
|
_cur_month = ymd.month;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* yes, call various monthly loops */
|
|
|
|
/* yes, call various monthly loops */
|
|
|
|
if (_game_mode != GM_MENU) {
|
|
|
|
_cur_month = ymd.month;
|
|
|
|
if (_debug_desync_level > 2) {
|
|
|
|
OnNewMonth();
|
|
|
|
char name[MAX_PATH];
|
|
|
|
|
|
|
|
snprintf(name, lengthof(name), "dmp_cmds_%08x_%08x.sav", _settings_game.game_creation.generation_seed, _date);
|
|
|
|
|
|
|
|
SaveOrLoad(name, SL_SAVE, AUTOSAVE_DIR);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_settings_client.gui.autosave != 0 && (_cur_month % _autosave_months[_settings_client.gui.autosave]) == 0) {
|
|
|
|
|
|
|
|
_do_autosave = true;
|
|
|
|
|
|
|
|
RedrawAutosave();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InvalidateWindowClasses(WC_CHEATS);
|
|
|
|
|
|
|
|
CompaniesMonthlyLoop();
|
|
|
|
|
|
|
|
SubsidyMonthlyLoop();
|
|
|
|
|
|
|
|
EnginesMonthlyLoop();
|
|
|
|
|
|
|
|
TownsMonthlyLoop();
|
|
|
|
|
|
|
|
IndustryMonthlyLoop();
|
|
|
|
|
|
|
|
StationMonthlyLoop();
|
|
|
|
|
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
|
|
|
|
|
if (_network_server) NetworkServerMonthlyLoop();
|
|
|
|
|
|
|
|
#endif /* ENABLE_NETWORK */
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* check if we entered a new year? */
|
|
|
|
/* check if we entered a new year? */
|
|
|
|
if (ymd.year == _cur_year) return;
|
|
|
|
if (ymd.year == _cur_year) return;
|
|
|
|
_cur_year = ymd.year;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* yes, call various yearly loops */
|
|
|
|
/* yes, call various yearly loops */
|
|
|
|
CompaniesYearlyLoop();
|
|
|
|
_cur_year = ymd.year;
|
|
|
|
VehiclesYearlyLoop();
|
|
|
|
OnNewYear();
|
|
|
|
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();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|