summaryrefslogtreecommitdiff
path: root/src/newgrf.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-12-29 20:36:12 +0000
committerrubidium <rubidium@openttd.org>2008-12-29 20:36:12 +0000
commit0d5ecc4d37f4f96189b0170a43bf68b2e9aa19ce (patch)
tree86b97261980f987ba30377075157b430a64cec6a /src/newgrf.cpp
parent73c98e98997fa62d7a8156923afcdc07d7c4a31e (diff)
downloadopenttd-0d5ecc4d37f4f96189b0170a43bf68b2e9aa19ce.tar.xz
(svn r14769) -Change: when loading games in "network" mode use the start date of the save game for the server and all clients when loading the NewGRFs instead of the current date. Prevents desyncs caused by action 7/9s skipping parts of the GRF based on the date or some other variables that can differ at NewGRF load time.
Diffstat (limited to 'src/newgrf.cpp')
-rw-r--r--src/newgrf.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 694aba073..91ed1a94a 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -6033,6 +6033,24 @@ static void AfterLoadGRFs()
void LoadNewGRF(uint load_index, uint file_index)
{
+ /* In case of networking we need to "sync" the start values
+ * so all NewGRFs are loaded equally. For this we use the
+ * start date of the game and we set the counters, etc. to
+ * 0 so they're the same too. */
+ Date date = _date;
+ Year year = _cur_year;
+ DateFract date_fract = _date_fract;
+ uint16 tick_counter = _tick_counter;
+ byte display_opt = _display_opt;
+
+ if (_networking) {
+ _cur_year = _settings_game.game_creation.starting_year;
+ _date = ConvertYMDToDate(_cur_year, 0, 1);
+ _date_fract = 0;
+ _tick_counter = 0;
+ _display_opt = 0;
+ }
+
InitializeGRFSpecial();
ResetNewGRFData();
@@ -6086,6 +6104,13 @@ void LoadNewGRF(uint load_index, uint file_index)
/* Call any functions that should be run after GRFs have been loaded. */
AfterLoadGRFs();
+
+ /* Now revert back to the original situation */
+ _cur_year = year;
+ _date = date;
+ _date_fract = date_fract;
+ _tick_counter = tick_counter;
+ _display_opt = display_opt;
}
bool HasGrfMiscBit(GrfMiscBit bit)