mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-13 01:20:34 +02:00
Moved roads and rivers to TerrainTypeHandler, by analogy to TerrainType.
This commit is contained in:
@ -135,22 +135,6 @@ EMapAnimRedrawStatus CMapHandler::drawTerrainRectNew(SDL_Surface * targetSurface
|
||||
|
||||
void CMapHandler::initTerrainGraphics()
|
||||
{
|
||||
static const std::map<std::string, std::string> ROAD_FILES =
|
||||
{
|
||||
{ROAD_NAMES[1], "dirtrd"},
|
||||
{ROAD_NAMES[2], "gravrd"},
|
||||
{ROAD_NAMES[3], "cobbrd"}
|
||||
};
|
||||
|
||||
static const std::map<std::string, std::string> RIVER_FILES =
|
||||
{
|
||||
{RIVER_NAMES[1], "clrrvr"},
|
||||
{RIVER_NAMES[2], "icyrvr"},
|
||||
{RIVER_NAMES[3], "mudrvr"},
|
||||
{RIVER_NAMES[4], "lavrvr"}
|
||||
};
|
||||
|
||||
|
||||
auto loadFlipped = [](TFlippedAnimations & animation, TFlippedCache & cache, const std::map<std::string, std::string> & files)
|
||||
{
|
||||
//no rotation and basic setup
|
||||
@ -190,14 +174,24 @@ void CMapHandler::initTerrainGraphics()
|
||||
|
||||
//TODO: use if as a key
|
||||
std::map<std::string, std::string> terrainFiles;
|
||||
std::map<std::string, std::string> riverFiles;
|
||||
std::map<std::string, std::string> roadFiles;
|
||||
for(const auto * terrain : VLC->terrainTypeHandler->terrains())
|
||||
{
|
||||
terrainFiles[terrain->name] = terrain->tilesFilename;
|
||||
}
|
||||
for(const auto * river : VLC->terrainTypeHandler->rivers())
|
||||
{
|
||||
riverFiles[river->fileName] = river->fileName;
|
||||
}
|
||||
for(const auto * road : VLC->terrainTypeHandler->roads())
|
||||
{
|
||||
roadFiles[road->fileName] = road->fileName;
|
||||
}
|
||||
|
||||
loadFlipped(terrainAnimations, terrainImages, terrainFiles);
|
||||
loadFlipped(roadAnimations, roadImages, ROAD_FILES);
|
||||
loadFlipped(riverAnimations, riverImages, RIVER_FILES);
|
||||
loadFlipped(riverAnimations, riverImages, riverFiles);
|
||||
loadFlipped(roadAnimations, roadImages, roadFiles);
|
||||
|
||||
// Create enough room for the whole map and its frame
|
||||
|
||||
@ -791,21 +785,21 @@ void CMapHandler::CMapBlitter::drawObjects(SDL_Surface * targetSurf, const Terra
|
||||
|
||||
void CMapHandler::CMapBlitter::drawRoad(SDL_Surface * targetSurf, const TerrainTile & tinfo, const TerrainTile * tinfoUpper) const
|
||||
{
|
||||
if (tinfoUpper && tinfoUpper->roadType != ROAD_NAMES[0])
|
||||
if (tinfoUpper && tinfoUpper->roadType->id != Road::NO_ROAD)
|
||||
{
|
||||
ui8 rotation = (tinfoUpper->extTileFlags >> 4) % 4;
|
||||
Rect source(0, tileSize / 2, tileSize, tileSize / 2);
|
||||
Rect dest(realPos.x, realPos.y, tileSize, tileSize / 2);
|
||||
drawElement(EMapCacheType::ROADS, parent->roadImages[tinfoUpper->roadType][tinfoUpper->roadDir][rotation],
|
||||
drawElement(EMapCacheType::ROADS, parent->roadImages[tinfoUpper->roadType->fileName][tinfoUpper->roadDir][rotation],
|
||||
&source, targetSurf, &dest);
|
||||
}
|
||||
|
||||
if(tinfo.roadType != ROAD_NAMES[0]) //print road from this tile
|
||||
if(tinfo.roadType->id != Road::NO_ROAD) //print road from this tile
|
||||
{
|
||||
ui8 rotation = (tinfo.extTileFlags >> 4) % 4;
|
||||
Rect source(0, 0, tileSize, halfTileSizeCeil);
|
||||
Rect dest(realPos.x, realPos.y + tileSize / 2, tileSize, tileSize / 2);
|
||||
drawElement(EMapCacheType::ROADS, parent->roadImages[tinfo.roadType][tinfo.roadDir][rotation],
|
||||
drawElement(EMapCacheType::ROADS, parent->roadImages[tinfo.roadType->fileName][tinfo.roadDir][rotation],
|
||||
&source, targetSurf, &dest);
|
||||
}
|
||||
}
|
||||
@ -814,7 +808,7 @@ void CMapHandler::CMapBlitter::drawRiver(SDL_Surface * targetSurf, const Terrain
|
||||
{
|
||||
Rect destRect(realTileRect);
|
||||
ui8 rotation = (tinfo.extTileFlags >> 2) % 4;
|
||||
drawElement(EMapCacheType::RIVERS, parent->riverImages[tinfo.riverType][tinfo.riverDir][rotation], nullptr, targetSurf, &destRect);
|
||||
drawElement(EMapCacheType::RIVERS, parent->riverImages[tinfo.riverType->fileName][tinfo.riverDir][rotation], nullptr, targetSurf, &destRect);
|
||||
}
|
||||
|
||||
void CMapHandler::CMapBlitter::drawFow(SDL_Surface * targetSurf) const
|
||||
@ -865,7 +859,7 @@ void CMapHandler::CMapBlitter::blit(SDL_Surface * targetSurf, const MapDrawingIn
|
||||
if(isVisible || info->showAllTerrain)
|
||||
{
|
||||
drawTileTerrain(targetSurf, tinfo, tile);
|
||||
if(tinfo.riverType != RIVER_NAMES[0])
|
||||
if(tinfo.riverType->id != River::NO_RIVER)
|
||||
drawRiver(targetSurf, tinfo);
|
||||
drawRoad(targetSurf, tinfo, tinfoUpper);
|
||||
}
|
||||
|
Reference in New Issue
Block a user