mirror of
https://github.com/vcmi/vcmi.git
synced 2025-10-08 23:22:25 +02:00
Merge pull request #6204 from Laserlicht/res_fix
fix deserializion of ResourceSet for compatibility
This commit is contained in:
@@ -214,7 +214,25 @@ public:
|
|||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h)
|
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);
|
DLL_LINKAGE void serializeJson(JsonSerializeFormat & handler, const std::string & fieldName);
|
||||||
|
@@ -49,8 +49,9 @@ enum class ESerializationVersion : int32_t
|
|||||||
CAMPAIGN_BONUSES, // new format for scenario bonuses in campaigns
|
CAMPAIGN_BONUSES, // new format for scenario bonuses in campaigns
|
||||||
BONUS_HIDDEN, // hidden bonus
|
BONUS_HIDDEN, // hidden bonus
|
||||||
MORE_MAP_LAYERS, // more map layers
|
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!");
|
static_assert(ESerializationVersion::MINIMAL <= ESerializationVersion::CURRENT, "Invalid serialization version definition!");
|
||||||
|
Reference in New Issue
Block a user