summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cheat_gui.cpp2
-rw-r--r--src/date.cpp6
-rw-r--r--src/date_func.h2
-rw-r--r--src/genworld.cpp7
-rw-r--r--src/misc.cpp9
-rw-r--r--src/saveload/afterload.cpp2
-rw-r--r--src/toolbar_gui.cpp4
7 files changed, 15 insertions, 17 deletions
diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp
index 94b9e64a3..cc7bbd574 100644
--- a/src/cheat_gui.cpp
+++ b/src/cheat_gui.cpp
@@ -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);
diff --git a/src/date.cpp b/src/date.cpp
index bdf4dd0fc..bc3c1d106 100644
--- a/src/date.cpp
+++ b/src/date.cpp
@@ -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;
diff --git a/src/date_func.h b/src/date_func.h
index 43c858379..38e310a87 100644
--- a/src/date_func.h
+++ b/src/date_func.h
@@ -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);
diff --git a/src/genworld.cpp b/src/genworld.cpp
index 36604bf54..0e920af8b 100644
--- a/src/genworld.cpp
+++ b/src/genworld.cpp
@@ -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();
diff --git a/src/misc.cpp b/src/misc.cpp
index 6d6fa7232..75ec9f305 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -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();
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index f9e229485..bce5e0451 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -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;
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index b4553fd73..9ceecf4ad 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -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;
}