1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

Add fallback for empty terrain types. Still it's a workaround and does not solve the root cause.

This commit is contained in:
Tomasz Zieliński
2023-03-18 17:00:50 +01:00
parent d9fac6d6fb
commit 23a5a32756

View File

@@ -134,7 +134,16 @@ void initTerrainType(Zone & zone, CMapGenerator & gen)
}
else
{
zone.setTerrainType(*RandomGeneratorUtil::nextItem(zone.getTerrainTypes(), gen.rand));
auto terrainTypes = zone.getTerrainTypes();
if (terrainTypes.empty())
{
logGlobal->warn("No terrain types found, falling back to DIRT");
zone.setTerrainType(ETerrainId::DIRT);
}
else
{
zone.setTerrainType(*RandomGeneratorUtil::nextItem(terrainTypes, gen.rand));
}
}
//Now, replace disallowed terrains on surface and in the underground