Merge branch 'save_ext' into enhanced_viewport_overlay

# Conflicts:
#	src/industry_cmd.cpp
#	src/vehicle.cpp
This commit is contained in:
Jonathan G Rennison
2018-03-11 22:16:19 +00:00
155 changed files with 7373 additions and 1175 deletions

View File

@@ -61,6 +61,8 @@ bool SlXvFeatureTest::IsFeaturePresent(uint16 savegame_version, uint16 savegame_
{
bool savegame_version_ok = savegame_version >= savegame_version_from && savegame_version <= savegame_version_to;
if (this->functor) return (*this->functor)(savegame_version, savegame_version_ok);
if (this->feature == XSLFI_NULL) return savegame_version_ok;
bool feature_ok = SlXvIsFeaturePresent(this->feature, this->min_version, this->max_version);

View File

@@ -40,11 +40,14 @@ enum SlXvFeatureTestOperator {
* Structure to describe an extended feature version test, and how it combines with a traditional savegame version test
*/
struct SlXvFeatureTest {
using TestFunctorPtr = bool (*)(uint16, bool); ///< Return true if feature present, first parameter is standard savegame version, second is whether standard savegame version is within bounds
private:
uint16 min_version;
uint16 max_version;
SlXvFeatureIndex feature;
SlXvFeatureTestOperator op;
TestFunctorPtr functor = nullptr;
public:
SlXvFeatureTest()
@@ -53,6 +56,9 @@ struct SlXvFeatureTest {
SlXvFeatureTest(SlXvFeatureTestOperator op_, SlXvFeatureIndex feature_, uint16 min_version_ = 1, uint16 max_version_ = 0xFFFF)
: min_version(min_version_), max_version(max_version_), feature(feature_), op(op_) { }
SlXvFeatureTest(TestFunctorPtr functor_)
: min_version(0), max_version(0), feature(XSLFI_NULL), op(XSLFTO_OR), functor(functor_) { }
bool IsFeaturePresent(uint16 savegame_version, uint16 savegame_version_from, uint16 savegame_version_to) const;
};

View File

@@ -57,7 +57,7 @@ static const SaveLoad _industry_desc[] = {
SLEG_CONDARR(_old_ind_persistent_storage.storage, SLE_UINT32, 16, 76, 160),
SLE_CONDREF(Industry, psa, REF_STORAGE, 161, SL_MAX_VERSION),
SLE_CONDVAR(Industry, random_triggers, SLE_UINT8, 82, SL_MAX_VERSION),
SLE_CONDNULL(1, 82, 196), // random_triggers
SLE_CONDVAR(Industry, random, SLE_UINT16, 82, SL_MAX_VERSION),
SLE_CONDNULL(32, 2, 143), // old reserved space

View File

@@ -269,8 +269,9 @@
* 194 26881 1.5.x, 1.6.0
* 195 27572 1.6.x
* 196 27778 1.7.x
* 197 27978
*/
extern const uint16 SAVEGAME_VERSION = 196; ///< Current savegame version of OpenTTD.
extern const uint16 SAVEGAME_VERSION = 197; ///< Current savegame version of OpenTTD.
const uint16 SAVEGAME_VERSION_EXT = 0x8000; ///< Savegame extension indicator mask
SavegameType _savegame_type; ///< type of savegame we are loading