1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-10-08 23:22:25 +02:00

fix deserializion of ResourceSet for compatibility

This commit is contained in:
Laserlicht
2025-10-03 18:27:55 +02:00
parent 1c819edc32
commit 967283beb6
2 changed files with 21 additions and 2 deletions

View File

@@ -214,7 +214,25 @@ public:
template <typename Handler> void serialize(Handler &h)
{
h & container;
if (h.version >= Handler::Version::CONFIGURABLE_RESOURCES)
h & container;
else
{
if (h.saving)
{
std::array<TResource, 8> tmp = {};
for (size_t i = 0; i < 7; ++i)
tmp[i] = container[i];
tmp[7] = TResource{};
h & tmp;
}
else
{
std::array<TResource, 8> tmp = {};
h & tmp;
container = std::vector<TResource>(tmp.begin(), tmp.begin() + 7);
}
}
}
DLL_LINKAGE void serializeJson(JsonSerializeFormat & handler, const std::string & fieldName);

View File

@@ -49,8 +49,9 @@ enum class ESerializationVersion : int32_t
CAMPAIGN_BONUSES, // new format for scenario bonuses in campaigns
BONUS_HIDDEN, // hidden bonus
MORE_MAP_LAYERS, // more map layers
CONFIGURABLE_RESOURCES, // configurable resources
CURRENT = MORE_MAP_LAYERS,
CURRENT = CONFIGURABLE_RESOURCES,
};
static_assert(ESerializationVersion::MINIMAL <= ESerializationVersion::CURRENT, "Invalid serialization version definition!");