1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Converted terrainTypeHandler into proper handler class

This commit is contained in:
Ivan Savenko
2022-12-20 16:14:06 +02:00
parent 01811317f9
commit 1468f6aded
43 changed files with 410 additions and 590 deletions

View File

@@ -119,9 +119,9 @@ void initTerrainType(Zone & zone, CMapGenerator & gen)
{
//collect all water terrain types
std::vector<TerrainId> waterTerrains;
for(const auto & terrain : VLC->terrainTypeHandler->terrains())
if(terrain.isWater())
waterTerrains.push_back(terrain.id);
for(const auto & terrain : VLC->terrainTypeHandler->objects)
if(terrain->isWater())
waterTerrains.push_back(terrain->id);
zone.setTerrainType(*RandomGeneratorUtil::nextItem(waterTerrains, gen.rand));
}
@@ -137,20 +137,20 @@ void initTerrainType(Zone & zone, CMapGenerator & gen)
}
//Now, replace disallowed terrains on surface and in the underground
const auto & terrainType = VLC->terrainTypeHandler->terrains()[zone.getTerrainType()];
const auto & terrainType = VLC->terrainTypeHandler->getById(zone.getTerrainType());
if(zone.isUnderground())
{
if(!terrainType.isUnderground())
if(!terrainType->isUnderground())
{
zone.setTerrainType(Terrain::SUBTERRANEAN);
zone.setTerrainType(TerrainId::SUBTERRANEAN);
}
}
else
{
if (!terrainType.isSurface())
if (!terrainType->isSurface())
{
zone.setTerrainType(Terrain::DIRT);
zone.setTerrainType(TerrainId::DIRT);
}
}
}