(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.

This commit is contained in:
rubidium 2008-12-29 20:36:12 +00:00
parent d38d7f1297
commit 9f4132c739
1 changed files with 25 additions and 0 deletions

View File

@ -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)