From 65f696b01896e40108ea50c5b4ecf4fd8a5a3bb5 Mon Sep 17 00:00:00 2001 From: nordsoft Date: Thu, 28 Sep 2023 03:02:46 +0200 Subject: [PATCH] Cosmetic changes for json map reader --- lib/mapping/MapFormatJson.cpp | 13 +++++++------ lib/mapping/MapFormatJson.h | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/mapping/MapFormatJson.cpp b/lib/mapping/MapFormatJson.cpp index b6da8d13b..6f739eb1c 100644 --- a/lib/mapping/MapFormatJson.cpp +++ b/lib/mapping/MapFormatJson.cpp @@ -346,6 +346,7 @@ const int CMapFormatJson::VERSION_MINOR = 3; const std::string CMapFormatJson::HEADER_FILE_NAME = "header.json"; const std::string CMapFormatJson::OBJECTS_FILE_NAME = "objects.json"; +const std::string CMapFormatJson::TERRAIN_FILE_NAMES[2] = {"surface_terrain.json", "underground_terrain.json"}; CMapFormatJson::CMapFormatJson(): fileVersionMajor(0), fileVersionMinor(0), @@ -424,10 +425,10 @@ void CMapFormatJson::serializeHeader(JsonSerializeFormat & handler) handler.serializeLIC("allowedHeroes", &HeroTypeID::decode, &HeroTypeID::encode, VLC->heroh->getDefaultAllowed(), mapHeader->allowedHeroes); -// handler.serializeString("victoryString", mapHeader->victoryMessage); + handler.serializeStruct("victoryMessage", mapHeader->victoryMessage); handler.serializeInt("victoryIconIndex", mapHeader->victoryIconIndex); -// handler.serializeString("defeatString", mapHeader->defeatMessage); + handler.serializeStruct("defeatMessage", mapHeader->defeatMessage); handler.serializeInt("defeatIconIndex", mapHeader->defeatIconIndex); } @@ -1122,12 +1123,12 @@ void CMapLoaderJson::readTerrainLevel(const JsonNode & src, const int index) void CMapLoaderJson::readTerrain() { { - const JsonNode surface = getFromArchive("surface_terrain.json"); + const JsonNode surface = getFromArchive(TERRAIN_FILE_NAMES[0]); readTerrainLevel(surface, 0); } if(map->twoLevel) { - const JsonNode underground = getFromArchive("underground_terrain.json"); + const JsonNode underground = getFromArchive(TERRAIN_FILE_NAMES[1]); readTerrainLevel(underground, 1); } @@ -1388,12 +1389,12 @@ void CMapSaverJson::writeTerrain() //todo: multilevel map save support JsonNode surface = writeTerrainLevel(0); - addToArchive(surface, "surface_terrain.json"); + addToArchive(surface, TERRAIN_FILE_NAMES[0]); if(map->twoLevel) { JsonNode underground = writeTerrainLevel(1); - addToArchive(underground, "underground_terrain.json"); + addToArchive(underground, TERRAIN_FILE_NAMES[1]); } } diff --git a/lib/mapping/MapFormatJson.h b/lib/mapping/MapFormatJson.h index d23d06be0..af89f89eb 100644 --- a/lib/mapping/MapFormatJson.h +++ b/lib/mapping/MapFormatJson.h @@ -42,6 +42,7 @@ public: static const std::string HEADER_FILE_NAME; static const std::string OBJECTS_FILE_NAME; + static const std::string TERRAIN_FILE_NAMES[2]; int fileVersionMajor; int fileVersionMinor;