Change type of extended feature versions arrays
This commit is contained in:
@@ -51,17 +51,17 @@
|
|||||||
|
|
||||||
#include "../safeguards.h"
|
#include "../safeguards.h"
|
||||||
|
|
||||||
uint16 _sl_xv_feature_versions[XSLFI_SIZE]; ///< array of all known feature types and their current versions
|
std::array<uint16, XSLFI_SIZE> _sl_xv_feature_versions; ///< 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
|
std::array<uint16, XSLFI_SIZE> _sl_xv_feature_static_versions; ///< 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?
|
||||||
bool _sl_maybe_chillpp; ///< is this possibly a ChillPP v8 savegame?
|
bool _sl_maybe_chillpp; ///< is this possibly a ChillPP v8 savegame?
|
||||||
bool _sl_upstream_mode; ///< load game using upstream loader
|
bool _sl_upstream_mode; ///< load game using upstream loader
|
||||||
std::vector<uint32> _sl_xv_discardable_chunk_ids; ///< list of chunks IDs which we can discard if no chunk loader exists
|
std::vector<uint32> _sl_xv_discardable_chunk_ids; ///< list of chunks IDs which we can discard if no chunk loader exists
|
||||||
std::string _sl_xv_version_label; ///< optional SLXI version label
|
std::string _sl_xv_version_label; ///< optional SLXI version label
|
||||||
|
|
||||||
static const uint32 _sl_xv_slxi_chunk_version = 0; ///< current version of SLXI chunk
|
static const uint32 _sl_xv_slxi_chunk_version = 0; ///< current version of SLXI chunk
|
||||||
|
|
||||||
static void loadVL(const SlxiSubChunkInfo *info, uint32 length);
|
static void loadVL(const SlxiSubChunkInfo *info, uint32 length);
|
||||||
static uint32 saveVL(const SlxiSubChunkInfo *info, bool dry_run);
|
static uint32 saveVL(const SlxiSubChunkInfo *info, bool dry_run);
|
||||||
@@ -195,7 +195,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
|||||||
* and return the combination of the two tests using the operator defined in the constructor.
|
* and return the combination of the two tests using the operator defined in the constructor.
|
||||||
* Otherwise just returns the result of the savegame version test
|
* Otherwise just returns the result of the savegame version test
|
||||||
*/
|
*/
|
||||||
bool SlXvFeatureTest::IsFeaturePresent(uint16 feature_versions[XSLFI_SIZE], SaveLoadVersion savegame_version, SaveLoadVersion savegame_version_from, SaveLoadVersion savegame_version_to) const
|
bool SlXvFeatureTest::IsFeaturePresent(const std::array<uint16, XSLFI_SIZE> &feature_versions, SaveLoadVersion savegame_version, SaveLoadVersion savegame_version_from, SaveLoadVersion savegame_version_to) const
|
||||||
{
|
{
|
||||||
bool savegame_version_ok = savegame_version >= savegame_version_from && savegame_version < savegame_version_to;
|
bool savegame_version_ok = savegame_version >= savegame_version_from && savegame_version < savegame_version_to;
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ bool SlXvFeatureTest::IsFeaturePresent(uint16 feature_versions[XSLFI_SIZE], Save
|
|||||||
/**
|
/**
|
||||||
* Returns true if @p feature is present and has a version inclusively bounded by @p min_version and @p max_version
|
* Returns true if @p feature is present and has a version inclusively bounded by @p min_version and @p max_version
|
||||||
*/
|
*/
|
||||||
bool SlXvIsFeaturePresent(uint16 feature_versions[XSLFI_SIZE], SlXvFeatureIndex feature, uint16 min_version, uint16 max_version)
|
bool SlXvIsFeaturePresent(const std::array<uint16, XSLFI_SIZE> &feature_versions, SlXvFeatureIndex feature, uint16 min_version, uint16 max_version)
|
||||||
{
|
{
|
||||||
assert(feature < XSLFI_SIZE);
|
assert(feature < XSLFI_SIZE);
|
||||||
return feature_versions[feature] >= min_version && feature_versions[feature] <= max_version;
|
return feature_versions[feature] >= min_version && feature_versions[feature] <= max_version;
|
||||||
@@ -252,7 +252,7 @@ void SlXvResetState()
|
|||||||
_sl_maybe_chillpp = false;
|
_sl_maybe_chillpp = false;
|
||||||
_sl_upstream_mode = false;
|
_sl_upstream_mode = false;
|
||||||
_sl_xv_discardable_chunk_ids.clear();
|
_sl_xv_discardable_chunk_ids.clear();
|
||||||
memset(_sl_xv_feature_versions, 0, sizeof(_sl_xv_feature_versions));
|
std::fill(_sl_xv_feature_versions.begin(), _sl_xv_feature_versions.end(), 0);
|
||||||
_sl_xv_version_label.clear();
|
_sl_xv_version_label.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,7 +278,7 @@ void SlXvSetCurrentState()
|
|||||||
*/
|
*/
|
||||||
void SlXvSetStaticCurrentVersions()
|
void SlXvSetStaticCurrentVersions()
|
||||||
{
|
{
|
||||||
memset(_sl_xv_feature_static_versions, 0, sizeof(_sl_xv_feature_static_versions));
|
std::fill(_sl_xv_feature_static_versions.begin(), _sl_xv_feature_static_versions.end(), 0);
|
||||||
|
|
||||||
const SlxiSubChunkInfo *info = _sl_xv_sub_chunk_infos;
|
const SlxiSubChunkInfo *info = _sl_xv_sub_chunk_infos;
|
||||||
for (; info->index != XSLFI_NULL; ++info) {
|
for (; info->index != XSLFI_NULL; ++info) {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "../core/bitmath_func.hpp"
|
#include "../core/bitmath_func.hpp"
|
||||||
#include "../core/enum_type.hpp"
|
#include "../core/enum_type.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
enum SaveLoadVersion : uint16;
|
enum SaveLoadVersion : uint16;
|
||||||
@@ -152,8 +153,8 @@ enum SlXvFeatureIndex {
|
|||||||
XSLFI_SIZE, ///< Total count of features, including null feature
|
XSLFI_SIZE, ///< Total count of features, including null feature
|
||||||
};
|
};
|
||||||
|
|
||||||
extern uint16 _sl_xv_feature_versions[XSLFI_SIZE];
|
extern std::array<uint16, XSLFI_SIZE> _sl_xv_feature_versions;
|
||||||
extern uint16 _sl_xv_feature_static_versions[XSLFI_SIZE];
|
extern std::array<uint16, XSLFI_SIZE> _sl_xv_feature_static_versions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
@@ -167,7 +168,7 @@ enum SlXvFeatureTestOperator {
|
|||||||
* Structure to describe an extended feature version test, and how it combines with a traditional savegame version test
|
* Structure to describe an extended feature version test, and how it combines with a traditional savegame version test
|
||||||
*/
|
*/
|
||||||
struct SlXvFeatureTest {
|
struct SlXvFeatureTest {
|
||||||
using TestFunctorPtr = bool (*)(uint16, bool, uint16[XSLFI_SIZE]); ///< Return true if feature present, first parameter is standard savegame version, second is whether standard savegame version is within bounds
|
using TestFunctorPtr = bool (*)(uint16, bool, const std::array<uint16, XSLFI_SIZE> &); ///< Return true if feature present, first parameter is standard savegame version, second is whether standard savegame version is within bounds
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint16 min_version;
|
uint16 min_version;
|
||||||
@@ -186,7 +187,7 @@ struct SlXvFeatureTest {
|
|||||||
SlXvFeatureTest(TestFunctorPtr functor_)
|
SlXvFeatureTest(TestFunctorPtr functor_)
|
||||||
: min_version(0), max_version(0), feature(XSLFI_NULL), op(XSLFTO_OR), functor(functor_) { }
|
: min_version(0), max_version(0), feature(XSLFI_NULL), op(XSLFTO_OR), functor(functor_) { }
|
||||||
|
|
||||||
bool IsFeaturePresent(uint16 feature_versions[XSLFI_SIZE], SaveLoadVersion savegame_version, SaveLoadVersion savegame_version_from, SaveLoadVersion savegame_version_to) const;
|
bool IsFeaturePresent(const std::array<uint16, XSLFI_SIZE> &feature_versions, SaveLoadVersion savegame_version, SaveLoadVersion savegame_version_from, SaveLoadVersion savegame_version_to) const;
|
||||||
|
|
||||||
inline bool IsFeaturePresent(SaveLoadVersion savegame_version, SaveLoadVersion savegame_version_from, SaveLoadVersion savegame_version_to) const
|
inline bool IsFeaturePresent(SaveLoadVersion savegame_version, SaveLoadVersion savegame_version_from, SaveLoadVersion savegame_version_to) const
|
||||||
{
|
{
|
||||||
@@ -194,7 +195,7 @@ struct SlXvFeatureTest {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool SlXvIsFeaturePresent(uint16 feature_versions[XSLFI_SIZE], SlXvFeatureIndex feature, uint16 min_version = 1, uint16 max_version = 0xFFFF);
|
bool SlXvIsFeaturePresent(const std::array<uint16, XSLFI_SIZE> &feature_versions, SlXvFeatureIndex feature, uint16 min_version = 1, uint16 max_version = 0xFFFF);
|
||||||
|
|
||||||
inline bool SlXvIsFeaturePresent(SlXvFeatureIndex feature, uint16 min_version = 1, uint16 max_version = 0xFFFF)
|
inline bool SlXvIsFeaturePresent(SlXvFeatureIndex feature, uint16 min_version = 1, uint16 max_version = 0xFFFF)
|
||||||
{
|
{
|
||||||
@@ -212,7 +213,7 @@ inline bool SlXvIsFeatureMissing(SlXvFeatureIndex feature, uint16 min_version =
|
|||||||
/**
|
/**
|
||||||
* Returns true if @p feature is missing (i.e. has a version of 0, or less than the specified minimum version)
|
* Returns true if @p feature is missing (i.e. has a version of 0, or less than the specified minimum version)
|
||||||
*/
|
*/
|
||||||
inline bool SlXvIsFeatureMissing(uint16 feature_versions[XSLFI_SIZE], SlXvFeatureIndex feature, uint16 min_version = 1)
|
inline bool SlXvIsFeatureMissing(const std::array<uint16, XSLFI_SIZE> &feature_versions, SlXvFeatureIndex feature, uint16 min_version = 1)
|
||||||
{
|
{
|
||||||
return !SlXvIsFeaturePresent(feature_versions, feature, min_version);
|
return !SlXvIsFeaturePresent(feature_versions, feature, min_version);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -704,10 +704,10 @@ SaveLoadTable GetVehicleDescription(VehicleType vt)
|
|||||||
|
|
||||||
SLE_VAR(Vehicle, day_counter, SLE_UINT8),
|
SLE_VAR(Vehicle, day_counter, SLE_UINT8),
|
||||||
SLE_VAR(Vehicle, tick_counter, SLE_UINT8),
|
SLE_VAR(Vehicle, tick_counter, SLE_UINT8),
|
||||||
SLE_CONDVAR_X(Vehicle, running_ticks, SLE_FILE_U8 | SLE_VAR_U16, SLV_88, SL_MAX_VERSION, SlXvFeatureTest([](uint16 version, bool version_in_range, uint16 feature_versions[XSLFI_SIZE]) -> bool {
|
SLE_CONDVAR_X(Vehicle, running_ticks, SLE_FILE_U8 | SLE_VAR_U16, SLV_88, SL_MAX_VERSION, SlXvFeatureTest([](uint16 version, bool version_in_range, const std::array<uint16, XSLFI_SIZE> &feature_versions) -> bool {
|
||||||
return version_in_range && !(SlXvIsFeaturePresent(feature_versions, XSLFI_SPRINGPP, 3) || SlXvIsFeaturePresent(feature_versions, XSLFI_JOKERPP) || SlXvIsFeaturePresent(feature_versions, XSLFI_CHILLPP) || SlXvIsFeaturePresent(feature_versions, XSLFI_VARIABLE_DAY_LENGTH, 2));
|
return version_in_range && !(SlXvIsFeaturePresent(feature_versions, XSLFI_SPRINGPP, 3) || SlXvIsFeaturePresent(feature_versions, XSLFI_JOKERPP) || SlXvIsFeaturePresent(feature_versions, XSLFI_CHILLPP) || SlXvIsFeaturePresent(feature_versions, XSLFI_VARIABLE_DAY_LENGTH, 2));
|
||||||
})),
|
})),
|
||||||
SLE_CONDVAR_X(Vehicle, running_ticks, SLE_UINT16, SLV_88, SL_MAX_VERSION, SlXvFeatureTest([](uint16 version, bool version_in_range, uint16 feature_versions[XSLFI_SIZE]) -> bool {
|
SLE_CONDVAR_X(Vehicle, running_ticks, SLE_UINT16, SLV_88, SL_MAX_VERSION, SlXvFeatureTest([](uint16 version, bool version_in_range, const std::array<uint16, XSLFI_SIZE> &feature_versions) -> bool {
|
||||||
return version_in_range && (SlXvIsFeaturePresent(feature_versions, XSLFI_SPRINGPP, 2) || SlXvIsFeaturePresent(feature_versions, XSLFI_JOKERPP) || SlXvIsFeaturePresent(feature_versions, XSLFI_CHILLPP) || SlXvIsFeaturePresent(feature_versions, XSLFI_VARIABLE_DAY_LENGTH, 2));
|
return version_in_range && (SlXvIsFeaturePresent(feature_versions, XSLFI_SPRINGPP, 2) || SlXvIsFeaturePresent(feature_versions, XSLFI_JOKERPP) || SlXvIsFeaturePresent(feature_versions, XSLFI_CHILLPP) || SlXvIsFeaturePresent(feature_versions, XSLFI_VARIABLE_DAY_LENGTH, 2));
|
||||||
})),
|
})),
|
||||||
|
|
||||||
|
|||||||
@@ -1098,7 +1098,7 @@ var = linkgraph.recalc_not_scaled_by_daylength
|
|||||||
def = true
|
def = true
|
||||||
str = STR_CONFIG_SETTING_LINKGRAPH_NOT_DAYLENGTH_SCALED
|
str = STR_CONFIG_SETTING_LINKGRAPH_NOT_DAYLENGTH_SCALED
|
||||||
strhelp = STR_CONFIG_SETTING_LINKGRAPH_NOT_DAYLENGTH_SCALED_HELPTEXT
|
strhelp = STR_CONFIG_SETTING_LINKGRAPH_NOT_DAYLENGTH_SCALED_HELPTEXT
|
||||||
extver = SlXvFeatureTest([](uint16 version, bool version_in_range, uint16 feature_versions[XSLFI_SIZE]) -> bool { return version_in_range && SlXvIsFeaturePresent(feature_versions, XSLFI_LINKGRAPH_DAY_SCALE) && !SlXvIsFeaturePresent(feature_versions, XSLFI_JOKERPP); })
|
extver = SlXvFeatureTest([](uint16 version, bool version_in_range, const std::array<uint16, XSLFI_SIZE> &feature_versions) -> bool { return version_in_range && SlXvIsFeaturePresent(feature_versions, XSLFI_LINKGRAPH_DAY_SCALE) && !SlXvIsFeaturePresent(feature_versions, XSLFI_JOKERPP); })
|
||||||
patxname = ""linkgraph_day_scale.linkgraph.recalc_not_scaled_by_daylength""
|
patxname = ""linkgraph_day_scale.linkgraph.recalc_not_scaled_by_daylength""
|
||||||
|
|
||||||
[SDT_ENUM]
|
[SDT_ENUM]
|
||||||
|
|||||||
Reference in New Issue
Block a user