diff options
author | rubidium <rubidium@openttd.org> | 2008-12-29 20:36:12 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-12-29 20:36:12 +0000 |
commit | 9f4132c7397f8b9a824455f3ef6d36496f796b91 (patch) | |
tree | 86b97261980f987ba30377075157b430a64cec6a /src | |
parent | d38d7f1297a3a7867e9ea1e49c43b0fe4388e823 (diff) | |
download | openttd-9f4132c7397f8b9a824455f3ef6d36496f796b91.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')
-rw-r--r-- | src/newgrf.cpp | 25 |
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) |