1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-04 00:15:53 +02:00

Remove backward compatibility with non-existing version

This commit is contained in:
nordsoft 2022-09-13 03:35:35 +04:00
parent 1705d7e43f
commit 2d5d616af0
2 changed files with 19 additions and 40 deletions

View File

@ -240,19 +240,6 @@ public:
static std::string getModDir(std::string name);
static std::string getModFile(std::string name);
//TODO: remove as soon as backward compatilibity for versions earlier 806 is not preserved.
template <typename Handler> void serialize(Handler &h, const int ver)
{
h & identifier;
h & description;
h & name;
h & dependencies;
h & conflicts;
h & config;
h & checksum;
h & validation;
h & enabled;
}
private:
void loadLocalData(const JsonNode & data);
};
@ -374,41 +361,33 @@ public:
template <typename Handler> void serialize(Handler &h, const int version)
{
if(version < 806)
if(h.saving)
{
h & allMods; //don't serialize mods
h & activeMods;
for(auto & m : activeMods)
h & allMods[m].version;
}
else
{
if(h.saving)
std::vector<TModID> newActiveMods;
h & newActiveMods;
for(auto & m : newActiveMods)
{
h & activeMods;
for(auto & m : activeMods)
h & allMods[m].version;
}
else
{
std::vector<TModID> newActiveMods;
h & newActiveMods;
for(auto & m : newActiveMods)
if(!allMods.count(m))
throw Incompatibility(m + " unkown mod");
CModInfo::Version mver;
h & mver;
if(!allMods[m].version.isNull() && !mver.isNull() && !allMods[m].version.compatible(mver))
{
if(!allMods.count(m))
throw Incompatibility(m + " unkown mod");
CModInfo::Version mver;
h & mver;
if(!allMods[m].version.isNull() && !mver.isNull() && !allMods[m].version.compatible(mver))
{
std::string err = allMods[m].name +
": version needed " + mver.toString() +
"but you have installed " + allMods[m].version.toString();
throw Incompatibility(err);
}
allMods[m].enabled = true;
std::string err = allMods[m].name +
": version needed " + mver.toString() +
"but you have installed " + allMods[m].version.toString();
throw Incompatibility(err);
}
std::swap(activeMods, newActiveMods);
allMods[m].enabled = true;
}
std::swap(activeMods, newActiveMods);
}
h & settings;

View File

@ -12,7 +12,7 @@
#include "../ConstTransitivePtr.h"
#include "../GameConstants.h"
const ui32 SERIALIZATION_VERSION = 806;
const ui32 SERIALIZATION_VERSION = 805;
const ui32 MINIMAL_SERIALIZATION_VERSION = 805;
const std::string SAVEGAME_MAGIC = "VCMISVG";