Add extended feature array with static current version values

This commit is contained in:
Jonathan G Rennison
2022-02-04 21:29:25 +00:00
parent bffff8e357
commit dacdb1137a
3 changed files with 17 additions and 0 deletions

View File

@@ -680,6 +680,7 @@ int openttd_main(int argc, char *argv[])
{ {
SetSelfAsMainThread(); SetSelfAsMainThread();
PerThreadSetup(); PerThreadSetup();
SlXvSetStaticCurrentVersions();
std::string musicdriver; std::string musicdriver;
std::string sounddriver; std::string sounddriver;
std::string videodriver; std::string videodriver;

View File

@@ -52,6 +52,7 @@
#include "../safeguards.h" #include "../safeguards.h"
uint16 _sl_xv_feature_versions[XSLFI_SIZE]; ///< array of all known feature types and their current versions 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_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_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? 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. * Check for "special" savegame versions (i.e. known patchpacks) and set correct savegame version, settings, etc.
*/ */

View File

@@ -140,6 +140,7 @@ enum SlXvFeatureIndex {
}; };
extern uint16 _sl_xv_feature_versions[XSLFI_SIZE]; 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 * Operator to use when combining traditional savegame number test with an extended feature version test
@@ -240,6 +241,7 @@ struct SlxiSubChunkInfo {
void SlXvResetState(); void SlXvResetState();
void SlXvSetCurrentState(); void SlXvSetCurrentState();
void SlXvSetStaticCurrentVersions();
bool SlXvCheckSpecialSavegameVersions(); bool SlXvCheckSpecialSavegameVersions();