|
@@ -135,22 +135,6 @@ EMapAnimRedrawStatus CMapHandler::drawTerrainRectNew(SDL_Surface * targetSurface
|
|
|
|
|
|
|
|
void CMapHandler::initTerrainGraphics()
|
|
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)
|
|
auto loadFlipped = [](TFlippedAnimations & animation, TFlippedCache & cache, const std::map<std::string, std::string> & files)
|
|
|
{
|
|
{
|
|
|
//no rotation and basic setup
|
|
//no rotation and basic setup
|
|
@@ -190,14 +174,24 @@ void CMapHandler::initTerrainGraphics()
|
|
|
|
|
|
|
|
//TODO: use if as a key
|
|
//TODO: use if as a key
|
|
|
std::map<std::string, std::string> terrainFiles;
|
|
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())
|
|
for(const auto * terrain : VLC->terrainTypeHandler->terrains())
|
|
|
{
|
|
{
|
|
|
terrainFiles[terrain->name] = terrain->tilesFilename;
|
|
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(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
|
|
// 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
|
|
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;
|
|
ui8 rotation = (tinfoUpper->extTileFlags >> 4) % 4;
|
|
|
Rect source(0, tileSize / 2, tileSize, tileSize / 2);
|
|
Rect source(0, tileSize / 2, tileSize, tileSize / 2);
|
|
|
Rect dest(realPos.x, realPos.y, 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);
|
|
&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;
|
|
ui8 rotation = (tinfo.extTileFlags >> 4) % 4;
|
|
|
Rect source(0, 0, tileSize, halfTileSizeCeil);
|
|
Rect source(0, 0, tileSize, halfTileSizeCeil);
|
|
|
Rect dest(realPos.x, realPos.y + tileSize / 2, tileSize, tileSize / 2);
|
|
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);
|
|
&source, targetSurf, &dest);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -814,7 +808,7 @@ void CMapHandler::CMapBlitter::drawRiver(SDL_Surface * targetSurf, const Terrain
|
|
|
{
|
|
{
|
|
|
Rect destRect(realTileRect);
|
|
Rect destRect(realTileRect);
|
|
|
ui8 rotation = (tinfo.extTileFlags >> 2) % 4;
|
|
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
|
|
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)
|
|
if(isVisible || info->showAllTerrain)
|
|
|
{
|
|
{
|
|
|
drawTileTerrain(targetSurf, tinfo, tile);
|
|
drawTileTerrain(targetSurf, tinfo, tile);
|
|
|
- if(tinfo.riverType != RIVER_NAMES[0])
|
|
|
|
|
|
|
+ if(tinfo.riverType->id != River::NO_RIVER)
|
|
|
drawRiver(targetSurf, tinfo);
|
|
drawRiver(targetSurf, tinfo);
|
|
|
drawRoad(targetSurf, tinfo, tinfoUpper);
|
|
drawRoad(targetSurf, tinfo, tinfoUpper);
|
|
|
}
|
|
}
|