1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +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

@@ -923,9 +923,6 @@ bool CMapLoaderH3M::loadArtifactToSlot(CGHeroInstance * hero, int slot)
void CMapLoaderH3M::readTerrain()
{
map->initTerrain();
const auto & terrains = VLC->terrainTypeHandler->terrains();
const auto & rivers = VLC->terrainTypeHandler->rivers();
const auto & roads = VLC->terrainTypeHandler->roads();
// Read terrain
int3 pos;
@@ -937,14 +934,14 @@ void CMapLoaderH3M::readTerrain()
for(pos.x = 0; pos.x < map->width; pos.x++)
{
auto & tile = map->getTile(pos);
tile.terType = const_cast<TerrainType*>(&terrains[reader.readUInt8()]);
tile.terType = const_cast<TerrainType*>(VLC->terrainTypeHandler->getByIndex(reader.readUInt8()));
tile.terView = reader.readUInt8();
tile.riverType = const_cast<RiverType*>(&rivers[reader.readUInt8()]);
tile.riverType = const_cast<RiverType*>(VLC->riverTypeHandler->getByIndex(reader.readUInt8()));
tile.riverDir = reader.readUInt8();
tile.roadType = const_cast<RoadType*>(&roads[reader.readUInt8()]);
tile.roadType = const_cast<RoadType*>(VLC->roadTypeHandler->getByIndex(reader.readUInt8()));
tile.roadDir = reader.readUInt8();
tile.extTileFlags = reader.readUInt8();
tile.blocked = ((!tile.terType->isPassable() || tile.terType->id == Terrain::BORDER ) ? true : false); //underground tiles are always blocked
tile.blocked = ((!tile.terType->isPassable() || tile.terType->id == TerrainId::BORDER ) ? true : false); //underground tiles are always blocked
tile.visitable = 0;
}
}