Browse Source

Fix regressions in RMG & map editor

Ivan Savenko 2 years ago
parent
commit
c455986a55
4 changed files with 12 additions and 10 deletions
  1. 6 4
      lib/TerrainHandler.cpp
  2. 2 2
      lib/mapping/CMap.cpp
  3. 3 3
      lib/mapping/CMapDefines.h
  4. 1 1
      lib/mapping/CMapOperation.cpp

+ 6 - 4
lib/TerrainHandler.cpp

@@ -204,7 +204,7 @@ RoadType * RoadTypeHandler::loadFromJson(
 
 const std::vector<std::string> & RoadTypeHandler::getTypeNames() const
 {
-	static const std::vector<std::string> typeNames = { "river" };
+	static const std::vector<std::string> 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

+ 2 - 2
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),

+ 3 - 3
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

+ 1 - 1
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