1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-20 03:29:32 +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 getModDir(std::string name);
static std::string getModFile(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: private:
void loadLocalData(const JsonNode & data); void loadLocalData(const JsonNode & data);
}; };
@ -374,41 +361,33 @@ public:
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
if(version < 806) if(h.saving)
{ {
h & allMods; //don't serialize mods
h & activeMods; h & activeMods;
for(auto & m : activeMods)
h & allMods[m].version;
} }
else else
{ {
if(h.saving) std::vector<TModID> newActiveMods;
h & newActiveMods;
for(auto & m : newActiveMods)
{ {
h & activeMods; if(!allMods.count(m))
for(auto & m : activeMods) throw Incompatibility(m + " unkown mod");
h & allMods[m].version;
} CModInfo::Version mver;
else h & mver;
{ if(!allMods[m].version.isNull() && !mver.isNull() && !allMods[m].version.compatible(mver))
std::vector<TModID> newActiveMods;
h & newActiveMods;
for(auto & m : newActiveMods)
{ {
if(!allMods.count(m)) std::string err = allMods[m].name +
throw Incompatibility(m + " unkown mod"); ": version needed " + mver.toString() +
"but you have installed " + allMods[m].version.toString();
CModInfo::Version mver; throw Incompatibility(err);
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::swap(activeMods, newActiveMods); allMods[m].enabled = true;
} }
std::swap(activeMods, newActiveMods);
} }
h & settings; h & settings;

View File

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