mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r20591) -Codechange: make sure _date_fract is set when SetDate is called. Some places wouldn't reset _date_fract correctly at all
This commit is contained in:
parent
fba7ce392d
commit
56a263070f
@ -101,7 +101,7 @@ static int32 ClickChangeDateCheat(int32 p1, int32 p2)
|
||||
|
||||
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);
|
||||
|
@ -29,13 +29,15 @@ uint16 _tick_counter; ///< Ever incrementing (and sometimes wrapping) tick coun
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
@ -20,7 +20,7 @@ extern Date _date;
|
||||
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);
|
||||
|
||||
|
@ -296,13 +296,10 @@ void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_setti
|
||||
/* 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();
|
||||
|
||||
|
@ -67,19 +67,18 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settin
|
||||
_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();
|
||||
|
||||
InitializeSound();
|
||||
InitializeMusic();
|
||||
|
||||
if (reset_date) {
|
||||
SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1));
|
||||
SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1), 0);
|
||||
InitializeOldNames();
|
||||
}
|
||||
|
||||
InitializeSound();
|
||||
InitializeMusic();
|
||||
|
||||
InitializeEngineRenews();
|
||||
InitializeVehicles();
|
||||
InitializeDepots();
|
||||
|
@ -571,7 +571,7 @@ bool AfterLoadGame()
|
||||
|
||||
/* 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;
|
||||
|
@ -825,7 +825,7 @@ static void ToolbarScenDateBackward(Window *w)
|
||||
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 @@ static void ToolbarScenDateForward(Window *w)
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user