# HG changeset patch # User rubidium # Date 1282468681 0 # Node ID 33fed3e36d65cae526ef42390728b670f216a67e # Parent 6fe686bcda0c1a00234dccb5526c61fdd631bbfe (svn r20591) -Codechange: make sure _date_fract is set when SetDate is called. Some places wouldn't reset _date_fract correctly at all diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -101,7 +101,7 @@ if ((ymd.year == MIN_YEAR && p2 == -1) || (ymd.year == MAX_YEAR && p2 == 1)) return _cur_year; - SetDate(ConvertYMDToDate(_cur_year + p2, ymd.month, ymd.day)); + SetDate(ConvertYMDToDate(_cur_year + p2, ymd.month, ymd.day), _date_fract); EnginesMonthlyLoop(); SetWindowDirty(WC_STATUS_BAR, 0); InvalidateWindowClassesData(WC_BUILD_STATION, 0); diff --git a/src/date.cpp b/src/date.cpp --- a/src/date.cpp +++ b/src/date.cpp @@ -29,13 +29,15 @@ /** * Set the date. - * @param date New date + * @param date New date + * @param fract The number of ticks that have passed on this date. */ -void SetDate(Date date) +void SetDate(Date date, DateFract fract) { YearMonthDay ymd; _date = date; + _date_fract = fract; ConvertDateToYMD(date, &ymd); _cur_year = ymd.year; _cur_month = ymd.month; diff --git a/src/date_func.h b/src/date_func.h --- a/src/date_func.h +++ b/src/date_func.h @@ -20,7 +20,7 @@ extern DateFract _date_fract; extern uint16 _tick_counter; -void SetDate(Date date); +void SetDate(Date date, DateFract fract); void ConvertDateToYMD(Date date, YearMonthDay *ymd); Date ConvertYMDToDate(Year year, Month month, Day day); diff --git a/src/genworld.cpp b/src/genworld.cpp --- a/src/genworld.cpp +++ b/src/genworld.cpp @@ -296,13 +296,10 @@ /* This disables some commands and stuff */ SetLocalCompany(COMPANY_SPECTATOR); - /* Set the date before loading sprites as some newgrfs check it */ - SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1)); - - InitializeGame(_gw.size_x, _gw.size_y, false, reset_settings); + InitializeGame(_gw.size_x, _gw.size_y, true, reset_settings); PrepareGenerateWorldProgress(); - /* Load the right landscape stuff */ + /* Load the right landscape stuff, and the NewGRFs! */ GfxLoadSprites(); LoadStringWidthTable(); diff --git a/src/misc.cpp b/src/misc.cpp --- a/src/misc.cpp +++ b/src/misc.cpp @@ -67,19 +67,18 @@ _pause_mode = PM_UNPAUSED; _fast_forward = 0; _tick_counter = 0; - _date_fract = 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(); + } + InitializeSound(); InitializeMusic(); - if (reset_date) { - SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1)); - InitializeOldNames(); - } - InitializeEngineRenews(); InitializeVehicles(); InitializeDepots(); diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -571,7 +571,7 @@ /* Update current year * must be done before loading sprites as some newgrfs check it */ - SetDate(_date); + SetDate(_date, _date_fract); /* Force dynamic engines off when loading older savegames */ if (CheckSavegameVersion(95)) _settings_game.vehicle.dynamic_engines = 0; diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -825,7 +825,7 @@ w->SetDirty(); _settings_game.game_creation.starting_year = Clamp(_settings_game.game_creation.starting_year - 1, MIN_YEAR, MAX_YEAR); - SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1)); + SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1), 0); } _left_button_clicked = false; } @@ -838,7 +838,7 @@ w->SetDirty(); _settings_game.game_creation.starting_year = Clamp(_settings_game.game_creation.starting_year + 1, MIN_YEAR, MAX_YEAR); - SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1)); + SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1), 0); } _left_button_clicked = false; }