1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fix serialization of rewardable objects

This commit is contained in:
Ivan Savenko 2023-03-06 13:21:28 +02:00
parent 5f396af14c
commit 0c847c85cc
3 changed files with 15 additions and 1 deletions

View File

@ -46,6 +46,11 @@ public:
void configureObject(CRewardableObject * object, CRandomGenerator & rng) const;
void init(const JsonNode & objectConfig);
template <typename Handler> void serialize(Handler &h, const int version)
{
h & parameters;
}
};
class DLL_LINKAGE CRewardableConstructor : public AObjectTypeHandler
@ -60,6 +65,14 @@ public:
void configureObject(CGObjectInstance * object, CRandomGenerator & rng) const override;
std::unique_ptr<IObjectInfo> getObjectInfo(std::shared_ptr<const ObjectTemplate> tmpl) const override;
template <typename Handler> void serialize(Handler &h, const int version)
{
AObjectTypeHandler::serialize(h, version);
if (version >= 816)
h & objectInfo;
}
};
VCMI_LIB_NAMESPACE_END

View File

@ -544,6 +544,7 @@ void CRewardableObject::newTurn(CRandomGenerator & rand) const
void CRewardableObject::initObj(CRandomGenerator & rand)
{
VLC->objtypeh->getHandlerFor(ID, subID)->configureObject(this, rand);
assert(!info.empty());
}
CRewardableObject::CRewardableObject():

View File

@ -14,7 +14,7 @@
VCMI_LIB_NAMESPACE_BEGIN
const ui32 SERIALIZATION_VERSION = 815;
const ui32 SERIALIZATION_VERSION = 816;
const ui32 MINIMAL_SERIALIZATION_VERSION = 813;
const std::string SAVEGAME_MAGIC = "VCMISVG";