mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +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
a27c25749f
commit
0318ddc279
@ -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;
|
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();
|
EnginesMonthlyLoop();
|
||||||
SetWindowDirty(WC_STATUS_BAR, 0);
|
SetWindowDirty(WC_STATUS_BAR, 0);
|
||||||
InvalidateWindowClassesData(WC_BUILD_STATION, 0);
|
InvalidateWindowClassesData(WC_BUILD_STATION, 0);
|
||||||
|
@ -30,12 +30,14 @@ uint16 _tick_counter; ///< Ever incrementing (and sometimes wrapping) tick coun
|
|||||||
/**
|
/**
|
||||||
* Set the date.
|
* 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;
|
YearMonthDay ymd;
|
||||||
|
|
||||||
_date = date;
|
_date = date;
|
||||||
|
_date_fract = fract;
|
||||||
ConvertDateToYMD(date, &ymd);
|
ConvertDateToYMD(date, &ymd);
|
||||||
_cur_year = ymd.year;
|
_cur_year = ymd.year;
|
||||||
_cur_month = ymd.month;
|
_cur_month = ymd.month;
|
||||||
|
@ -20,7 +20,7 @@ extern Date _date;
|
|||||||
extern DateFract _date_fract;
|
extern DateFract _date_fract;
|
||||||
extern uint16 _tick_counter;
|
extern uint16 _tick_counter;
|
||||||
|
|
||||||
void SetDate(Date date);
|
void SetDate(Date date, DateFract fract);
|
||||||
void ConvertDateToYMD(Date date, YearMonthDay *ymd);
|
void ConvertDateToYMD(Date date, YearMonthDay *ymd);
|
||||||
Date ConvertYMDToDate(Year year, Month month, Day day);
|
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 */
|
/* This disables some commands and stuff */
|
||||||
SetLocalCompany(COMPANY_SPECTATOR);
|
SetLocalCompany(COMPANY_SPECTATOR);
|
||||||
|
|
||||||
/* Set the date before loading sprites as some newgrfs check it */
|
InitializeGame(_gw.size_x, _gw.size_y, true, reset_settings);
|
||||||
SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1));
|
|
||||||
|
|
||||||
InitializeGame(_gw.size_x, _gw.size_y, false, reset_settings);
|
|
||||||
PrepareGenerateWorldProgress();
|
PrepareGenerateWorldProgress();
|
||||||
|
|
||||||
/* Load the right landscape stuff */
|
/* Load the right landscape stuff, and the NewGRFs! */
|
||||||
GfxLoadSprites();
|
GfxLoadSprites();
|
||||||
LoadStringWidthTable();
|
LoadStringWidthTable();
|
||||||
|
|
||||||
|
@ -67,19 +67,18 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settin
|
|||||||
_pause_mode = PM_UNPAUSED;
|
_pause_mode = PM_UNPAUSED;
|
||||||
_fast_forward = 0;
|
_fast_forward = 0;
|
||||||
_tick_counter = 0;
|
_tick_counter = 0;
|
||||||
_date_fract = 0;
|
|
||||||
_cur_tileloop_tile = 0;
|
_cur_tileloop_tile = 0;
|
||||||
_thd.redsq = INVALID_TILE;
|
_thd.redsq = INVALID_TILE;
|
||||||
if (reset_settings) MakeNewgameSettingsLive();
|
if (reset_settings) MakeNewgameSettingsLive();
|
||||||
|
|
||||||
InitializeSound();
|
|
||||||
InitializeMusic();
|
|
||||||
|
|
||||||
if (reset_date) {
|
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();
|
InitializeOldNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InitializeSound();
|
||||||
|
InitializeMusic();
|
||||||
|
|
||||||
InitializeEngineRenews();
|
InitializeEngineRenews();
|
||||||
InitializeVehicles();
|
InitializeVehicles();
|
||||||
InitializeDepots();
|
InitializeDepots();
|
||||||
|
@ -571,7 +571,7 @@ bool AfterLoadGame()
|
|||||||
|
|
||||||
/* Update current year
|
/* Update current year
|
||||||
* must be done before loading sprites as some newgrfs check it */
|
* 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 */
|
/* Force dynamic engines off when loading older savegames */
|
||||||
if (CheckSavegameVersion(95)) _settings_game.vehicle.dynamic_engines = 0;
|
if (CheckSavegameVersion(95)) _settings_game.vehicle.dynamic_engines = 0;
|
||||||
|
@ -825,7 +825,7 @@ static void ToolbarScenDateBackward(Window *w)
|
|||||||
w->SetDirty();
|
w->SetDirty();
|
||||||
|
|
||||||
_settings_game.game_creation.starting_year = Clamp(_settings_game.game_creation.starting_year - 1, MIN_YEAR, MAX_YEAR);
|
_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;
|
_left_button_clicked = false;
|
||||||
}
|
}
|
||||||
@ -838,7 +838,7 @@ static void ToolbarScenDateForward(Window *w)
|
|||||||
w->SetDirty();
|
w->SetDirty();
|
||||||
|
|
||||||
_settings_game.game_creation.starting_year = Clamp(_settings_game.game_creation.starting_year + 1, MIN_YEAR, MAX_YEAR);
|
_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;
|
_left_button_clicked = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user