1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Changed logic for zone placement.

Now every zone can be surface, underground, or both. This is separate from water <-> land distinction.

Iand type is now a combination of flags and can take multiple values: "type": ["LAND", "WATER", "SURFACE", "SUB", "ROCK"]. In nothing is specified, terrains get LAND | SURFACE flags by default.

Non-surface zones will default to DIRT, and non-underground zones will default to SUBTERRA.
This commit is contained in:
Tomasz Zieliński
2022-09-22 18:23:31 +02:00
parent e53613caa7
commit 6aaf77812b
8 changed files with 54 additions and 52 deletions

View File

@@ -134,26 +134,22 @@ void initTerrainType(Zone & zone, CMapGenerator & gen)
zone.setTerrainType(*RandomGeneratorUtil::nextItem(zone.getTerrainTypes(), gen.rand));
}
//Now, replace disallowed terrains on surface and in the underground
//TODO: allow new types of terrain?
const auto* terrainType = VLC->terrainTypeHandler->terrains()[zone.getTerrainType()];
if(zone.isUnderground())
{
if(zone.isUnderground())
if(!terrainType->isUnderground())
{
if(!vstd::contains(gen.getConfig().terrainUndergroundAllowed, zone.getTerrainType()))
{
//collect all underground terrain types
std::vector<TTerrain> undegroundTerrains;
for(const auto * terrain : VLC->terrainTypeHandler->terrains())
if(terrain->isUnderground())
undegroundTerrains.push_back(terrain->id);
zone.setTerrainType(*RandomGeneratorUtil::nextItem(undegroundTerrains, gen.rand));
}
zone.setTerrainType(Terrain::SUBTERRANEAN);
}
else
}
else
{
if (!terrainType->isSurface())
{
const auto* terrainType = VLC->terrainTypeHandler->terrains()[zone.getTerrainType()];
if(vstd::contains(gen.getConfig().terrainGroundProhibit, zone.getTerrainType()) || terrainType->isUnderground())
zone.setTerrainType(Terrain::DIRT);
zone.setTerrainType(Terrain::DIRT);
}
}
}