diff --git a/src/openttd.cpp b/src/openttd.cpp index 969d2d8c00..5d47752131 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -680,6 +680,7 @@ int openttd_main(int argc, char *argv[]) { SetSelfAsMainThread(); PerThreadSetup(); + SlXvSetStaticCurrentVersions(); std::string musicdriver; std::string sounddriver; std::string videodriver; diff --git a/src/saveload/extended_ver_sl.cpp b/src/saveload/extended_ver_sl.cpp index 77bde8e69f..4c8c4e1d29 100644 --- a/src/saveload/extended_ver_sl.cpp +++ b/src/saveload/extended_ver_sl.cpp @@ -52,6 +52,7 @@ #include "../safeguards.h" uint16 _sl_xv_feature_versions[XSLFI_SIZE]; ///< array of all known feature types and their current versions +uint16 _sl_xv_feature_static_versions[XSLFI_SIZE]; ///< array of all known feature types and their static current version versions bool _sl_is_ext_version; ///< is this an extended savegame version, with more info in the SLXI chunk? bool _sl_is_faked_ext; ///< is this a faked extended savegame version, with no SLXI chunk? See: SlXvCheckSpecialSavegameVersions. bool _sl_maybe_springpp; ///< is this possibly a SpringPP savegame? @@ -259,6 +260,19 @@ void SlXvSetCurrentState() } } +/** + * Set all extended feature versions in the current static version array to their currently enabled versions, i.e. versions suitable for saving + */ +void SlXvSetStaticCurrentVersions() +{ + memset(_sl_xv_feature_static_versions, 0, sizeof(_sl_xv_feature_static_versions)); + + const SlxiSubChunkInfo *info = _sl_xv_sub_chunk_infos; + for (; info->index != XSLFI_NULL; ++info) { + _sl_xv_feature_static_versions[info->index] = info->save_version; + } +} + /** * Check for "special" savegame versions (i.e. known patchpacks) and set correct savegame version, settings, etc. */ diff --git a/src/saveload/extended_ver_sl.h b/src/saveload/extended_ver_sl.h index e6c7b93245..189a4b2431 100644 --- a/src/saveload/extended_ver_sl.h +++ b/src/saveload/extended_ver_sl.h @@ -140,6 +140,7 @@ enum SlXvFeatureIndex { }; extern uint16 _sl_xv_feature_versions[XSLFI_SIZE]; +extern uint16 _sl_xv_feature_static_versions[XSLFI_SIZE]; /** * Operator to use when combining traditional savegame number test with an extended feature version test @@ -240,6 +241,7 @@ struct SlxiSubChunkInfo { void SlXvResetState(); void SlXvSetCurrentState(); +void SlXvSetStaticCurrentVersions(); bool SlXvCheckSpecialSavegameVersions();