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

Allow "notLikeZone" to be vector

This commit is contained in:
Tomasz Zieliński
2025-03-09 09:21:05 +01:00
parent 6e7dfc6ee4
commit 38a46d4b3f
4 changed files with 38 additions and 9 deletions

View File

@@ -109,7 +109,6 @@ void ZoneOptions::CTownInfo::serializeJson(JsonSerializeFormat & handler)
ZoneOptions::CTownHints::CTownHints()
: likeZone(NO_ZONE),
notLikeZone(NO_ZONE),
relatedToZoneTerrain(NO_ZONE)
{
@@ -118,7 +117,23 @@ ZoneOptions::CTownHints::CTownHints()
void ZoneOptions::CTownHints::serializeJson(JsonSerializeFormat & handler)
{
handler.serializeInt("likeZone", likeZone, NO_ZONE);
handler.serializeInt("notLikeZone", notLikeZone, NO_ZONE);
auto node = handler.getCurrent();
if (node["notLikeZone"].isVector())
{
// TODO: Utility to serialize vector of ints?
auto notLikeZoneData = handler.enterArray("notLikeZone");
notLikeZone.resize(notLikeZoneData.size());
for (size_t i = 0; i < notLikeZoneData.size(); ++i)
{
notLikeZoneData.serializeInt(i, notLikeZone[i]);
}
}
else
{
int temp;
handler.serializeInt("notLikeZone", temp, NO_ZONE);
notLikeZone.push_back(temp);
}
handler.serializeInt("relatedToZoneTerrain", relatedToZoneTerrain, NO_ZONE);
}