1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-17 00:07:41 +02:00

Terrain/Road/River handler are now in compileable state

This commit is contained in:
Ivan Savenko
2022-12-20 18:35:40 +02:00
parent 1468f6aded
commit e1799379dd
35 changed files with 303 additions and 205 deletions

View File

@ -16,6 +16,7 @@
#include "../mapping/CMap.h"
#include "../VCMI_Lib.h"
#include "../CTownHandler.h"
#include "../CModHandler.h"
#include "../Terrain.h"
#include "../serializer/JsonSerializeFormat.h"
#include "../StringConstants.h"
@ -69,13 +70,12 @@ class TerrainEncoder
public:
static si32 decode(const std::string & identifier)
{
return VLC->terrainTypeHandler->getInfoByCode(identifier)->id;
return *VLC->modh->identifiers.getIdentifier(VLC->modh->scopeGame(), "terrain", identifier);
}
static std::string encode(const si32 index)
{
const auto& terrains = VLC->terrainTypeHandler->objects;
return (index >=0 && index < terrains.size()) ? terrains[index]->name : "<INVALID TERRAIN>";
return VLC->terrainTypeHandler->getByIndex(index)->name;
}
};
@ -377,7 +377,8 @@ void ZoneOptions::serializeJson(JsonSerializeFormat & handler)
terrainTypes.clear();
for(auto ttype : node.Vector())
{
terrainTypes.emplace(VLC->terrainTypeHandler->getInfoByName(ttype.String())->id);
auto identifier = VLC->modh->identifiers.getIdentifier("terrain", ttype);
terrainTypes.emplace(*identifier);
}
}
}