1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Events serialization

This commit is contained in:
nordsoft
2023-09-10 01:54:55 +02:00
parent 52cbb613ae
commit 6e3817f18c
5 changed files with 49 additions and 5 deletions

View File

@@ -19,6 +19,7 @@ class RiverType;
class RoadType;
class CGObjectInstance;
class CGTownInstance;
class JsonSerializeFormat;
/// The map event is an event which e.g. gives or takes resources of a specific
/// amount to/from players and can appear regularly or once a time.
@@ -26,6 +27,7 @@ class DLL_LINKAGE CMapEvent
{
public:
CMapEvent();
virtual ~CMapEvent() = default;
bool earlierThan(const CMapEvent & other) const;
bool earlierThanOrEqual(const CMapEvent & other) const;
@@ -51,17 +53,18 @@ public:
h & firstOccurence;
h & nextOccurence;
}
virtual void serializeJson(JsonSerializeFormat & handler);
};
/// The castle event builds/adds buildings/creatures for a specific town.
class DLL_LINKAGE CCastleEvent: public CMapEvent
{
public:
CCastleEvent();
CCastleEvent() = default;
std::set<BuildingID> buildings;
std::vector<si32> creatures;
CGTownInstance * town;
template <typename Handler>
void serialize(Handler & h, const int version)
@@ -70,6 +73,8 @@ public:
h & buildings;
h & creatures;
}
void serializeJson(JsonSerializeFormat & handler) override;
};
/// The terrain tile describes the terrain type and the visual representation of the terrain.