mirror of
https://github.com/vcmi/vcmi.git
synced 2025-12-01 23:12:49 +02:00
First version that compiles
This commit is contained in:
@@ -67,12 +67,13 @@ class TerrainEncoder
|
||||
public:
|
||||
static si32 decode(const std::string & identifier)
|
||||
{
|
||||
return vstd::find_pos(VLC->terrainTypeHandler::terrains(), identifier);
|
||||
return VLC->terrainTypeHandler->getInfoByCode(identifier)->id;
|
||||
}
|
||||
|
||||
static std::string encode(const si32 index)
|
||||
{
|
||||
return (index >=0 && index < VLC->terrainTypeHandler::terrains().size()) ? static_cast<std::string>(VLC->terrainTypeHandler::terrains()[index]) : "<INVALID TERRAIN>";
|
||||
const auto& terrains = VLC->terrainTypeHandler->terrains();
|
||||
return (index >=0 && index < terrains.size()) ? terrains[index]->name : "<INVALID TERRAIN>";
|
||||
}
|
||||
};
|
||||
|
||||
@@ -149,9 +150,9 @@ ZoneOptions::ZoneOptions()
|
||||
terrainTypeLikeZone(NO_ZONE),
|
||||
treasureLikeZone(NO_ZONE)
|
||||
{
|
||||
for(auto & terr : VLC->terrainTypeHandler::terrains())
|
||||
if(terr.isLand() && terr.isPassable())
|
||||
terrainTypes.insert(terr);
|
||||
for(const auto * terr : VLC->terrainTypeHandler->terrains())
|
||||
if(terr->isLand() && terr->isPassable())
|
||||
terrainTypes.insert(terr->id);
|
||||
}
|
||||
|
||||
ZoneOptions & ZoneOptions::operator=(const ZoneOptions & other)
|
||||
@@ -214,12 +215,12 @@ boost::optional<int> ZoneOptions::getOwner() const
|
||||
return owner;
|
||||
}
|
||||
|
||||
const std::set<Terrain> & ZoneOptions::getTerrainTypes() const
|
||||
const std::set<TTerrain> & ZoneOptions::getTerrainTypes() const
|
||||
{
|
||||
return terrainTypes;
|
||||
}
|
||||
|
||||
void ZoneOptions::setTerrainTypes(const std::set<Terrain> & value)
|
||||
void ZoneOptions::setTerrainTypes(const std::set<TTerrain> & value)
|
||||
{
|
||||
//assert(value.find(ETerrainType::WRONG) == value.end() && value.find(ETerrainType::BORDER) == value.end() &&
|
||||
// value.find(ETerrainType::WATER) == value.end() && value.find(ETerrainType::ROCK) == value.end());
|
||||
@@ -374,7 +375,7 @@ void ZoneOptions::serializeJson(JsonSerializeFormat & handler)
|
||||
terrainTypes.clear();
|
||||
for(auto ttype : node.Vector())
|
||||
{
|
||||
terrainTypes.emplace(ttype.String());
|
||||
terrainTypes.emplace(VLC->terrainTypeHandler->getInfoByName(ttype.String())->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user