diff options
author | frosch <frosch@openttd.org> | 2020-01-12 17:23:04 +0100 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2020-01-12 19:08:38 +0100 |
commit | a4be4514c9206355af120106e00c18eca8b5d75a (patch) | |
tree | 09b828bdb5e1164a2a797fe394e685b0aeba0d6e /src/saveload/saveload.cpp | |
parent | 41163331aa882765e528c0e716f6e49cee2411cb (diff) | |
download | openttd-a4be4514c9206355af120106e00c18eca8b5d75a.tar.xz |
Fix #7925: Reset temporary saveload data at the start of loading a savegame instead of at the end.
Otherwise temporary data may be passed from an aborted load action to the next load action.
Diffstat (limited to 'src/saveload/saveload.cpp')
-rw-r--r-- | src/saveload/saveload.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index d652f0d25..aeaa7a5ed 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -2378,6 +2378,16 @@ extern bool AfterLoadGame(); extern bool LoadOldSaveGame(const char *file); /** + * Clear temporary data that is passed between various saveload phases. + */ +static void ResetSaveloadData() +{ + ResetTempEngineData(); + ResetLabelMaps(); + ResetOldWaypoints(); +} + +/** * Clear/free saveload state. */ static inline void ClearSaveLoadState() @@ -2623,6 +2633,8 @@ static SaveOrLoadResult DoLoad(LoadFilter *reader, bool load_check) _next_offs = 0; if (!load_check) { + ResetSaveloadData(); + /* Old maps were hardcoded to 256x256 and thus did not contain * any mapsize information. Pre-initialize to 256x256 to not to * confuse old games */ @@ -2727,6 +2739,8 @@ SaveOrLoadResult SaveOrLoad(const char *filename, SaveLoadOperation fop, Detaile try { /* Load a TTDLX or TTDPatch game */ if (fop == SLO_LOAD && dft == DFT_OLD_GAME_FILE) { + ResetSaveloadData(); + InitializeGame(256, 256, true, true); // set a mapsize of 256x256 for TTDPatch games or it might get confused /* TTD/TTO savegames have no NewGRFs, TTDP savegame have them |