From c455986a55d61e62b01ca38f2256f879733343a4 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Tue, 10 Jan 2023 01:05:28 +0200 Subject: [PATCH] Fix regressions in RMG & map editor --- lib/TerrainHandler.cpp | 10 ++++++---- lib/mapping/CMap.cpp | 4 ++-- lib/mapping/CMapDefines.h | 6 +++--- lib/mapping/CMapOperation.cpp | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/TerrainHandler.cpp b/lib/TerrainHandler.cpp index c3f5ed196..765def37d 100644 --- a/lib/TerrainHandler.cpp +++ b/lib/TerrainHandler.cpp @@ -204,7 +204,7 @@ RoadType * RoadTypeHandler::loadFromJson( const std::vector & RoadTypeHandler::getTypeNames() const { - static const std::vector typeNames = { "river" }; + static const std::vector typeNames = { "road" }; return typeNames; } @@ -274,7 +274,7 @@ TerrainType::TerrainType() std::string RoadType::getNameTextID() const { - return TextIdentifier( "terrain", identifier, "name" ).get(); + return TextIdentifier( "road", identifier, "name" ).get(); } std::string RoadType::getNameTranslated() const @@ -284,7 +284,7 @@ std::string RoadType::getNameTranslated() const std::string RiverType::getNameTextID() const { - return TextIdentifier( "terrain", identifier, "name" ).get(); + return TextIdentifier( "river", identifier, "name" ).get(); } std::string RiverType::getNameTranslated() const @@ -293,11 +293,13 @@ std::string RiverType::getNameTranslated() const } RiverType::RiverType(): - id(River::NO_RIVER) + id(River::NO_RIVER), + identifier("empty") {} RoadType::RoadType(): id(Road::NO_ROAD), + identifier("empty"), movementCost(GameConstants::BASE_MOVEMENT_COST) {} VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/CMap.cpp b/lib/mapping/CMap.cpp index 6ace46fff..e77588ac5 100644 --- a/lib/mapping/CMap.cpp +++ b/lib/mapping/CMap.cpp @@ -129,9 +129,9 @@ CCastleEvent::CCastleEvent() : town(nullptr) TerrainTile::TerrainTile(): terType(nullptr), terView(0), - riverType(nullptr), + riverType(VLC->riverTypeHandler->getById(River::NO_RIVER)), riverDir(0), - roadType(nullptr), + roadType(VLC->roadTypeHandler->getById(Road::NO_ROAD)), roadDir(0), extTileFlags(0), visitable(false), diff --git a/lib/mapping/CMapDefines.h b/lib/mapping/CMapDefines.h index ac0500820..52d6885d5 100644 --- a/lib/mapping/CMapDefines.h +++ b/lib/mapping/CMapDefines.h @@ -86,11 +86,11 @@ struct DLL_LINKAGE TerrainTile EDiggingStatus getDiggingStatus(const bool excludeTop = true) const; bool hasFavorableWinds() const; - TerrainType * terType; + const TerrainType * terType; ui8 terView; - RiverType * riverType; + const RiverType * riverType; ui8 riverDir; - RoadType * roadType; + const RoadType * roadType; ui8 roadDir; /// first two bits - how to rotate terrain graphic (next two - river graphic, next two - road); /// 7th bit - whether tile is coastal (allows disembarking if land or block movement if water); 8th bit - Favorable Winds effect diff --git a/lib/mapping/CMapOperation.cpp b/lib/mapping/CMapOperation.cpp index 46cf575b8..88d25768a 100644 --- a/lib/mapping/CMapOperation.cpp +++ b/lib/mapping/CMapOperation.cpp @@ -346,7 +346,7 @@ CDrawTerrainOperation::ValidationResult CDrawTerrainOperation::validateTerrainVi int cy = pos.y + (i / 3) - 1; int3 currentPos(cx, cy, pos.z); bool isAlien = false; - TerrainType * terType = nullptr; + const TerrainType * terType = nullptr; if(!map->isInTheMap(currentPos)) { // position is not in the map, so take the ter type from the neighbor tile