1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Cosmetic changes for json map reader

This commit is contained in:
nordsoft 2023-09-28 03:02:46 +02:00
parent 9098126684
commit 65f696b018
2 changed files with 8 additions and 6 deletions

View File

@ -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]);
}
}

View File

@ -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;