1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-17 00:07:41 +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

@ -56,9 +56,37 @@ bool CMapEvent::earlierThanOrEqual(const CMapEvent & other) const
return firstOccurence <= other.firstOccurence;
}
CCastleEvent::CCastleEvent() : town(nullptr)
void CMapEvent::serializeJson(JsonSerializeFormat & handler)
{
handler.serializeString("name", name);
handler.serializeString("message", message);
handler.serializeInt("players", players);
handler.serializeInt("humanAffected", humanAffected);
handler.serializeInt("computerAffected", computerAffected);
handler.serializeInt("firstOccurence", firstOccurence);
handler.serializeInt("nextOccurence", nextOccurence);
resources.serializeJson(handler, "resources");
}
void CCastleEvent::serializeJson(JsonSerializeFormat & handler)
{
CMapEvent::serializeJson(handler);
{
std::vector<BuildingID> temp(buildings.begin(), buildings.end());
auto a = handler.enterArray("buildings");
a.syncSize(temp);
for(int i = 0; i < temp.size(); ++i)
{
a.serializeInt(i, temp[i]);
buildings.insert(temp[i]);
}
}
{
auto a = handler.enterArray("creatures");
a.syncSize(creatures);
for(int i = 0; i < creatures.size(); ++i)
a.serializeInt(i, creatures[i]);
}
}
TerrainTile::TerrainTile():