瀏覽代碼

A variety of suggested style tweaks

Tomasz Zieliński 3 年之前
父節點
當前提交
4ea57ea7fc
共有 66 個文件被更改,包括 155 次插入156 次删除
  1. 2 2
      client/CMusicHandler.cpp
  2. 1 1
      client/CMusicHandler.h
  3. 2 2
      client/CPlayerInterface.cpp
  4. 2 2
      client/widgets/AdventureMapClasses.cpp
  5. 2 2
      client/widgets/AdventureMapClasses.h
  6. 2 2
      lib/CCreatureHandler.cpp
  7. 2 2
      lib/CCreatureHandler.h
  8. 1 1
      lib/CGeneralTextHandler.h
  9. 1 1
      lib/CHeroHandler.h
  10. 1 1
      lib/CPathfinder.h
  11. 1 1
      lib/CStack.cpp
  12. 2 2
      lib/CStack.h
  13. 5 5
      lib/CTownHandler.cpp
  14. 5 5
      lib/CTownHandler.h
  15. 3 3
      lib/GameConstants.h
  16. 1 1
      lib/HeroBonus.cpp
  17. 2 2
      lib/HeroBonus.h
  18. 1 1
      lib/NetPacksLib.cpp
  19. 1 1
      lib/ObstacleHandler.cpp
  20. 2 2
      lib/ObstacleHandler.h
  21. 10 11
      lib/Terrain.cpp
  22. 17 17
      lib/Terrain.h
  23. 2 2
      lib/battle/BattleInfo.cpp
  24. 3 3
      lib/battle/BattleInfo.h
  25. 1 1
      lib/battle/BattleProxy.cpp
  26. 1 1
      lib/battle/BattleProxy.h
  27. 2 2
      lib/battle/CBattleInfoEssentials.cpp
  28. 1 1
      lib/battle/CBattleInfoEssentials.h
  29. 1 1
      lib/battle/IBattleInfoCallback.h
  30. 1 1
      lib/battle/IBattleState.h
  31. 3 3
      lib/mapObjects/CGHeroInstance.cpp
  32. 1 1
      lib/mapObjects/CGHeroInstance.h
  33. 2 2
      lib/mapObjects/CObjectClassesHandler.cpp
  34. 2 2
      lib/mapObjects/CObjectClassesHandler.h
  35. 7 7
      lib/mapObjects/ObjectTemplate.cpp
  36. 2 2
      lib/mapObjects/ObjectTemplate.h
  37. 2 2
      lib/mapping/CDrawRoadsOperation.cpp
  38. 4 4
      lib/mapping/CDrawRoadsOperation.h
  39. 3 3
      lib/mapping/CMapEditManager.cpp
  40. 3 3
      lib/mapping/CMapEditManager.h
  41. 1 1
      lib/mapping/CMapOperation.cpp
  42. 2 2
      lib/mapping/CMapOperation.h
  43. 2 2
      lib/mapping/MapEditUtils.cpp
  44. 2 2
      lib/mapping/MapEditUtils.h
  45. 2 2
      lib/rmg/CRmgTemplate.cpp
  46. 3 3
      lib/rmg/CRmgTemplate.h
  47. 3 3
      lib/rmg/Functions.cpp
  48. 2 2
      lib/rmg/Functions.h
  49. 1 1
      lib/rmg/ObstaclePlacer.cpp
  50. 1 1
      lib/rmg/ObstaclePlacer.h
  51. 1 1
      lib/rmg/RmgMap.cpp
  52. 1 1
      lib/rmg/RmgMap.h
  53. 2 2
      lib/rmg/RmgObject.cpp
  54. 2 2
      lib/rmg/RmgObject.h
  55. 1 1
      lib/rmg/RoadPlacer.cpp
  56. 1 1
      lib/rmg/RockPlacer.h
  57. 3 3
      lib/rmg/TileInfo.cpp
  58. 5 5
      lib/rmg/TileInfo.h
  59. 1 1
      lib/rmg/TreasurePlacer.cpp
  60. 1 1
      lib/rmg/TreasurePlacer.h
  61. 2 2
      lib/rmg/Zone.cpp
  62. 3 3
      lib/rmg/Zone.h
  63. 2 2
      server/CGameHandler.cpp
  64. 2 2
      test/game/CGameStateTest.cpp
  65. 1 1
      test/mock/mock_IBattleInfoCallback.h
  66. 1 1
      test/mock/mock_battle_IBattleState.h

+ 2 - 2
client/CMusicHandler.cpp

@@ -119,7 +119,7 @@ CSoundHandler::CSoundHandler():
 
 
 void CSoundHandler::loadHorseSounds()
 void CSoundHandler::loadHorseSounds()
 {
 {
-	auto terrains = CGI->terrainTypeHandler->terrains();
+	const auto & terrains = CGI->terrainTypeHandler->terrains();
 	for(const auto * terrain : terrains)
 	for(const auto * terrain : terrains)
 	{
 	{
 		//since all sounds are hardcoded, let's keep it
 		//since all sounds are hardcoded, let's keep it
@@ -376,7 +376,7 @@ CMusicHandler::CMusicHandler():
 
 
 void CMusicHandler::loadTerrainSounds()
 void CMusicHandler::loadTerrainSounds()
 {
 {
-	for (const auto* terrain : CGI->terrainTypeHandler->terrains())
+	for (const auto * terrain : CGI->terrainTypeHandler->terrains())
 	{
 	{
 		addEntryToSet("terrain", terrain->name, "Music/" + terrain->musicFilename);
 		addEntryToSet("terrain", terrain->name, "Music/" + terrain->musicFilename);
 	}
 	}

+ 1 - 1
client/CMusicHandler.h

@@ -84,7 +84,7 @@ public:
 	// Sets
 	// Sets
 	std::vector<soundBase::soundID> pickupSounds;
 	std::vector<soundBase::soundID> pickupSounds;
 	std::vector<soundBase::soundID> battleIntroSounds;
 	std::vector<soundBase::soundID> battleIntroSounds;
-	std::map<TTerrain, soundBase::soundID> horseSounds;
+	std::map<TTerrainId, soundBase::soundID> horseSounds;
 };
 };
 
 
 // Helper //now it looks somewhat useless
 // Helper //now it looks somewhat useless

+ 2 - 2
client/CPlayerInterface.cpp

@@ -2746,8 +2746,8 @@ void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path)
 
 
 	{
 	{
 		path.convert(0);
 		path.convert(0);
-		TTerrain currentTerrain = Terrain::BORDER; // not init yet
-		TTerrain newTerrain;
+		TTerrainId currentTerrain = Terrain::BORDER; // not init yet
+		TTerrainId newTerrain;
 		int sh = -1;
 		int sh = -1;
 
 
 		auto canStop = [&](CGPathNode * node) -> bool
 		auto canStop = [&](CGPathNode * node) -> bool

+ 2 - 2
client/widgets/AdventureMapClasses.cpp

@@ -495,9 +495,9 @@ void CMinimapInstance::showAll(SDL_Surface * to)
 	}
 	}
 }
 }
 
 
-std::map<TTerrain, std::pair<SDL_Color, SDL_Color> > CMinimap::loadColors()
+std::map<TTerrainId, std::pair<SDL_Color, SDL_Color> > CMinimap::loadColors()
 {
 {
-	std::map<TTerrain, std::pair<SDL_Color, SDL_Color> > ret;
+	std::map<TTerrainId, std::pair<SDL_Color, SDL_Color> > ret;
 
 
 	for(const auto * terrain : CGI->terrainTypeHandler->terrains())
 	for(const auto * terrain : CGI->terrainTypeHandler->terrains())
 	{
 	{

+ 2 - 2
client/widgets/AdventureMapClasses.h

@@ -217,7 +217,7 @@ protected:
 	int level;
 	int level;
 
 
 	//to initialize colors
 	//to initialize colors
-	std::map<TTerrain, std::pair<SDL_Color, SDL_Color> > loadColors();
+	std::map<TTerrainId, std::pair<SDL_Color, SDL_Color> > loadColors();
 
 
 	void clickLeft(tribool down, bool previousState) override;
 	void clickLeft(tribool down, bool previousState) override;
 	void clickRight(tribool down, bool previousState) override;
 	void clickRight(tribool down, bool previousState) override;
@@ -228,7 +228,7 @@ protected:
 
 
 public:
 public:
 	// terrainID -> (normal color, blocked color)
 	// terrainID -> (normal color, blocked color)
-	const std::map<TTerrain, std::pair<SDL_Color, SDL_Color> > colors;
+	const std::map<TTerrainId, std::pair<SDL_Color, SDL_Color> > colors;
 
 
 	CMinimap(const Rect & position);
 	CMinimap(const Rect & position);
 
 

+ 2 - 2
lib/CCreatureHandler.cpp

@@ -283,13 +283,13 @@ std::string CCreature::nodeName() const
 	return "\"" + namePl + "\"";
 	return "\"" + namePl + "\"";
 }
 }
 
 
-bool CCreature::isItNativeTerrain(TTerrain terrain) const
+bool CCreature::isItNativeTerrain(TTerrainId terrain) const
 {
 {
 	auto native = getNativeTerrain();
 	auto native = getNativeTerrain();
 	return native == terrain || native == Terrain::ANY_TERRAIN;
 	return native == terrain || native == Terrain::ANY_TERRAIN;
 }
 }
 
 
-TTerrain CCreature::getNativeTerrain() const
+TTerrainId CCreature::getNativeTerrain() const
 {
 {
 	const std::string cachingStringNoTerrainPenalty = "type_NO_TERRAIN_PENALTY";
 	const std::string cachingStringNoTerrainPenalty = "type_NO_TERRAIN_PENALTY";
 	static const auto selectorNoTerrainPenalty = Selector::type()(Bonus::NO_TERRAIN_PENALTY);
 	static const auto selectorNoTerrainPenalty = Selector::type()(Bonus::NO_TERRAIN_PENALTY);

+ 2 - 2
lib/CCreatureHandler.h

@@ -119,14 +119,14 @@ public:
 
 
 	ArtifactID warMachine;
 	ArtifactID warMachine;
 
 
-	bool isItNativeTerrain(TTerrain terrain) const;
+	bool isItNativeTerrain(TTerrainId terrain) const;
 	/**
 	/**
 	Returns creature native terrain considering some terrain bonuses.
 	Returns creature native terrain considering some terrain bonuses.
 	@param considerBonus is used to avoid Dead Lock when this method is called inside getAllBonuses
 	@param considerBonus is used to avoid Dead Lock when this method is called inside getAllBonuses
 	considerBonus = true is called from Pathfinder and fills actual nativeTerrain considering bonus(es).
 	considerBonus = true is called from Pathfinder and fills actual nativeTerrain considering bonus(es).
 	considerBonus = false is called on Battle init and returns already prepared nativeTerrain without Bonus system calling.
 	considerBonus = false is called on Battle init and returns already prepared nativeTerrain without Bonus system calling.
 	*/
 	*/
-	TTerrain getNativeTerrain() const;
+	TTerrainId getNativeTerrain() const;
 	int32_t getIndex() const override;
 	int32_t getIndex() const override;
 	int32_t getIconIndex() const override;
 	int32_t getIconIndex() const override;
 	const std::string & getName() const override;
 	const std::string & getName() const override;

+ 1 - 1
lib/CGeneralTextHandler.h

@@ -122,7 +122,7 @@ public:
 	std::vector<std::string> advobtxt;
 	std::vector<std::string> advobtxt;
 	std::vector<std::string> xtrainfo;
 	std::vector<std::string> xtrainfo;
 	std::vector<std::string> restypes; //names of resources
 	std::vector<std::string> restypes; //names of resources
-	std::map<TTerrain, std::string> terrainNames;
+	std::map<TTerrainId, std::string> terrainNames;
 	std::vector<std::string> randsign;
 	std::vector<std::string> randsign;
 	std::vector<std::pair<std::string,std::string>> mines; //first - name; second - event description
 	std::vector<std::pair<std::string,std::string>> mines; //first - name; second - event description
 	std::vector<std::string> seerEmpty;
 	std::vector<std::string> seerEmpty;

+ 1 - 1
lib/CHeroHandler.h

@@ -265,7 +265,7 @@ public:
 	CHeroClassHandler classes;
 	CHeroClassHandler classes;
 
 
 	//default costs of going through terrains. -1 means terrain is impassable
 	//default costs of going through terrains. -1 means terrain is impassable
-	std::map<TTerrain, int> terrCosts;
+	std::map<TTerrainId, int> terrCosts;
 
 
 	struct SBallisticsLevelInfo
 	struct SBallisticsLevelInfo
 	{
 	{

+ 1 - 1
lib/CPathfinder.h

@@ -527,7 +527,7 @@ struct DLL_LINKAGE TurnInfo
 	TConstBonusListPtr bonuses;
 	TConstBonusListPtr bonuses;
 	mutable int maxMovePointsLand;
 	mutable int maxMovePointsLand;
 	mutable int maxMovePointsWater;
 	mutable int maxMovePointsWater;
-	TTerrain nativeTerrain;
+	TTerrainId nativeTerrain;
 
 
 	TurnInfo(const CGHeroInstance * Hero, const int Turn = 0);
 	TurnInfo(const CGHeroInstance * Hero, const int Turn = 0);
 	bool isLayerAvailable(const EPathfindingLayer layer) const;
 	bool isLayerAvailable(const EPathfindingLayer layer) const;

+ 1 - 1
lib/CStack.cpp

@@ -332,7 +332,7 @@ bool CStack::isOnNativeTerrain() const
 	return res;
 	return res;
 }
 }
 
 
-bool CStack::isOnTerrain(TTerrain terrain) const
+bool CStack::isOnTerrain(TTerrainId terrain) const
 {
 {
 	return battle->getTerrainType() == terrain;
 	return battle->getTerrainType() == terrain;
 }
 }

+ 2 - 2
lib/CStack.h

@@ -29,7 +29,7 @@ public:
 
 
 	ui32 ID; //unique ID of stack
 	ui32 ID; //unique ID of stack
 	const CCreature * type;
 	const CCreature * type;
-	TTerrain nativeTerrain; //tmp variable to save native terrain value on battle init
+	TTerrainId nativeTerrain; //tmp variable to save native terrain value on battle init
 	ui32 baseAmount;
 	ui32 baseAmount;
 
 
 	PlayerColor owner; //owner - player color (255 for neutrals)
 	PlayerColor owner; //owner - player color (255 for neutrals)
@@ -51,7 +51,7 @@ public:
 
 
 	bool canBeHealed() const; //for first aid tent - only harmed stacks that are not war machines
 	bool canBeHealed() const; //for first aid tent - only harmed stacks that are not war machines
 	bool isOnNativeTerrain() const;
 	bool isOnNativeTerrain() const;
-	bool isOnTerrain(TTerrain terrain) const;
+	bool isOnTerrain(TTerrainId terrain) const;
 
 
 	ui32 level() const;
 	ui32 level() const;
 	si32 magicResistance() const override; //include aura of resistance
 	si32 magicResistance() const override; //include aura of resistance

+ 5 - 5
lib/CTownHandler.cpp

@@ -26,9 +26,9 @@
 
 
 const int NAMES_PER_TOWN=16; // number of town names per faction in H3 files. Json can define any number
 const int NAMES_PER_TOWN=16; // number of town names per faction in H3 files. Json can define any number
 
 
-const TTerrain CTownHandler::defaultGoodTerrain(Terrain::GRASS);
-const TTerrain CTownHandler::defaultEvilTerrain(Terrain::LAVA);
-const TTerrain CTownHandler::defaultNeutralTerrain(Terrain::ROUGH);
+const TTerrainId CTownHandler::defaultGoodTerrain(Terrain::GRASS);
+const TTerrainId CTownHandler::defaultEvilTerrain(Terrain::LAVA);
+const TTerrainId CTownHandler::defaultNeutralTerrain(Terrain::ROUGH);
 
 
 const std::map<std::string, CBuilding::EBuildMode> CBuilding::MODES =
 const std::map<std::string, CBuilding::EBuildMode> CBuilding::MODES =
 {
 {
@@ -942,9 +942,9 @@ void CTownHandler::loadPuzzle(CFaction &faction, const JsonNode &source)
 	assert(faction.puzzleMap.size() == GameConstants::PUZZLE_MAP_PIECES);
 	assert(faction.puzzleMap.size() == GameConstants::PUZZLE_MAP_PIECES);
 }
 }
 
 
-TTerrain CTownHandler::getDefaultTerrainForAlignment(EAlignment::EAlignment alignment) const
+TTerrainId CTownHandler::getDefaultTerrainForAlignment(EAlignment::EAlignment alignment) const
 {
 {
-	TTerrain terrain = defaultGoodTerrain;
+	TTerrainId terrain = defaultGoodTerrain;
 
 
 	switch(alignment)
 	switch(alignment)
 	{
 	{

+ 5 - 5
lib/CTownHandler.h

@@ -185,7 +185,7 @@ public:
 
 
 	TFaction index;
 	TFaction index;
 
 
-	TTerrain nativeTerrain;
+	TTerrainId nativeTerrain;
 	EAlignment::EAlignment alignment;
 	EAlignment::EAlignment alignment;
 	bool preferUndergroundPlacement;
 	bool preferUndergroundPlacement;
 
 
@@ -358,9 +358,9 @@ class DLL_LINKAGE CTownHandler : public CHandlerBase<FactionID, Faction, CFactio
 	std::vector<BuildingRequirementsHelper> requirementsToLoad;
 	std::vector<BuildingRequirementsHelper> requirementsToLoad;
 	std::vector<BuildingRequirementsHelper> overriddenBidsToLoad; //list of buildings, which bonuses should be overridden.
 	std::vector<BuildingRequirementsHelper> overriddenBidsToLoad; //list of buildings, which bonuses should be overridden.
 
 
-	const static TTerrain defaultGoodTerrain;
-	const static TTerrain defaultEvilTerrain;
-	const static TTerrain defaultNeutralTerrain;
+	const static TTerrainId defaultGoodTerrain;
+	const static TTerrainId defaultEvilTerrain;
+	const static TTerrainId defaultNeutralTerrain;
 
 
 	static TPropagatorPtr & emptyPropagator();
 	static TPropagatorPtr & emptyPropagator();
 
 
@@ -391,7 +391,7 @@ class DLL_LINKAGE CTownHandler : public CHandlerBase<FactionID, Faction, CFactio
 
 
 	void loadPuzzle(CFaction & faction, const JsonNode & source);
 	void loadPuzzle(CFaction & faction, const JsonNode & source);
 
 
-	TTerrain getDefaultTerrainForAlignment(EAlignment::EAlignment aligment) const;
+	TTerrainId getDefaultTerrainForAlignment(EAlignment::EAlignment aligment) const;
 	void loadRandomFaction();
 	void loadRandomFaction();
 
 
 
 

+ 3 - 3
lib/GameConstants.h

@@ -1230,9 +1230,9 @@ typedef si64 TExpType;
 typedef std::pair<si64, si64> TDmgRange;
 typedef std::pair<si64, si64> TDmgRange;
 typedef si32 TBonusSubtype;
 typedef si32 TBonusSubtype;
 typedef si32 TQuantity;
 typedef si32 TQuantity;
-typedef si8 TTerrain;
-typedef si8 TRoad;
-typedef si8 TRiver;
+typedef si8 TTerrainId;
+typedef si8 TRoadId;
+typedef si8 TRiverId;
 
 
 typedef int TRmgTemplateZoneId;
 typedef int TRmgTemplateZoneId;
 
 

+ 1 - 1
lib/HeroBonus.cpp

@@ -2111,7 +2111,7 @@ CreatureTerrainLimiter::CreatureTerrainLimiter()
 {
 {
 }
 }
 
 
-CreatureTerrainLimiter::CreatureTerrainLimiter(TTerrain terrain):
+CreatureTerrainLimiter::CreatureTerrainLimiter(TTerrainId terrain):
 	terrainType(terrain)
 	terrainType(terrain)
 {
 {
 }
 }

+ 2 - 2
lib/HeroBonus.h

@@ -1060,9 +1060,9 @@ public:
 class DLL_LINKAGE CreatureTerrainLimiter : public ILimiter //applies only to creatures that are on specified terrain, default native terrain
 class DLL_LINKAGE CreatureTerrainLimiter : public ILimiter //applies only to creatures that are on specified terrain, default native terrain
 {
 {
 public:
 public:
-	TTerrain terrainType;
+	TTerrainId terrainType;
 	CreatureTerrainLimiter();
 	CreatureTerrainLimiter();
-	CreatureTerrainLimiter(TTerrain terrain);
+	CreatureTerrainLimiter(TTerrainId terrain);
 
 
 	int limit(const BonusLimitationContext &context) const override;
 	int limit(const BonusLimitationContext &context) const override;
 	virtual std::string toString() const override;
 	virtual std::string toString() const override;

+ 1 - 1
lib/NetPacksLib.cpp

@@ -701,7 +701,7 @@ DLL_LINKAGE void GiveHero::applyGs(CGameState *gs)
 
 
 DLL_LINKAGE void NewObject::applyGs(CGameState *gs)
 DLL_LINKAGE void NewObject::applyGs(CGameState *gs)
 {
 {
-	TTerrain terrainType = Terrain::BORDER;
+	TTerrainId terrainType = Terrain::BORDER;
 
 
 	if(ID == Obj::BOAT && !gs->isInTheMap(pos)) //special handling for bug #3060 - pos outside map but visitablePos is not
 	if(ID == Obj::BOAT && !gs->isInTheMap(pos)) //special handling for bug #3060 - pos outside map but visitablePos is not
 	{
 	{

+ 1 - 1
lib/ObstacleHandler.cpp

@@ -66,7 +66,7 @@ std::vector<BattleHex> ObstacleInfo::getBlocked(BattleHex hex) const
 	return ret;
 	return ret;
 }
 }
 
 
-bool ObstacleInfo::isAppropriate(const TTerrain terrainType, const BattleField & battlefield) const
+bool ObstacleInfo::isAppropriate(const TTerrainId terrainType, const BattleField & battlefield) const
 {
 {
 	auto bgInfo = battlefield.getInfo();
 	auto bgInfo = battlefield.getInfo();
 	
 	

+ 2 - 2
lib/ObstacleHandler.h

@@ -31,7 +31,7 @@ public:
 	si32 iconIndex;
 	si32 iconIndex;
 	std::string identifier;
 	std::string identifier;
 	std::string appearAnimation, animation, dissapearAnimation;
 	std::string appearAnimation, animation, dissapearAnimation;
-	std::vector<TTerrain> allowedTerrains;
+	std::vector<TTerrainId> allowedTerrains;
 	std::vector<std::string> allowedSpecialBfields;
 	std::vector<std::string> allowedSpecialBfields;
 	
 	
 	//TODO: here is extra field to implement it's logic in the future but save backward compatibility
 	//TODO: here is extra field to implement it's logic in the future but save backward compatibility
@@ -50,7 +50,7 @@ public:
 	
 	
 	std::vector<BattleHex> getBlocked(BattleHex hex) const; //returns vector of hexes blocked by obstacle when it's placed on hex 'hex'
 	std::vector<BattleHex> getBlocked(BattleHex hex) const; //returns vector of hexes blocked by obstacle when it's placed on hex 'hex'
 	
 	
-	bool isAppropriate(const TTerrain terrainType, const BattleField & specialBattlefield) const;
+	bool isAppropriate(const TTerrainId terrainType, const BattleField & specialBattlefield) const;
 	
 	
 	template <typename Handler> void serialize(Handler &h, const int version)
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
 	{

+ 10 - 11
lib/Terrain.cpp

@@ -169,11 +169,11 @@ void TerrainTypeHandler::initTerrains(const std::vector<std::string> & allConfig
 				info->terrainViewPatterns = terr.second["terrainViewPatterns"].String();
 				info->terrainViewPatterns = terr.second["terrainViewPatterns"].String();
 			}
 			}
 
 
-			TTerrain id = Terrain::WRONG;
+			TTerrainId id = Terrain::WRONG;
 			if(!terr.second["originalTerrainId"].isNull())
 			if(!terr.second["originalTerrainId"].isNull())
 			{
 			{
 				//place in reserved slot
 				//place in reserved slot
-				id = (TTerrain)(terr.second["originalTerrainId"].Float());
+				id = (TTerrainId)(terr.second["originalTerrainId"].Float());
 				objects[id] = info;
 				objects[id] = info;
 			}
 			}
 			else
 			else
@@ -222,7 +222,7 @@ void TerrainTypeHandler::initRivers(const std::vector<std::string> & allConfigs)
 
 
 			if (!river.second["originalRiverId"].isNull())
 			if (!river.second["originalRiverId"].isNull())
 			{
 			{
-				info->id = static_cast<TRiver>(river.second["originalRiverId"].Float());
+				info->id = static_cast<TRiverId>(river.second["originalRiverId"].Float());
 				riverTypes[info->id] = info;
 				riverTypes[info->id] = info;
 			}
 			}
 			else
 			else
@@ -257,7 +257,7 @@ void TerrainTypeHandler::initRoads(const std::vector<std::string> & allConfigs)
 
 
 			if (!road.second["originalRoadId"].isNull())
 			if (!road.second["originalRoadId"].isNull())
 			{
 			{
-				info->id = static_cast<TRoad>(road.second["originalRoadId"].Float());
+				info->id = static_cast<TRoadId>(road.second["originalRoadId"].Float());
 				roadTypes[info->id] = info;
 				roadTypes[info->id] = info;
 			}
 			}
 			else
 			else
@@ -332,7 +332,7 @@ const TerrainType* TerrainTypeHandler::getInfoByCode(const std::string& terrainC
 	return terrainInfoByCode.at(terrainCode);
 	return terrainInfoByCode.at(terrainCode);
 }
 }
 
 
-const TerrainType* TerrainTypeHandler::getInfoById(TTerrain id) const
+const TerrainType* TerrainTypeHandler::getInfoById(TTerrainId id) const
 {
 {
 	return terrainInfoById.at(id);
 	return terrainInfoById.at(id);
 }
 }
@@ -347,7 +347,7 @@ const RiverType* TerrainTypeHandler::getRiverByCode(const std::string& riverCode
 	return riverInfoByCode.at(riverCode);
 	return riverInfoByCode.at(riverCode);
 }
 }
 
 
-const RiverType* TerrainTypeHandler::getRiverById(TRiver id) const
+const RiverType* TerrainTypeHandler::getRiverById(TRiverId id) const
 {
 {
 	return riverInfoById.at(id);
 	return riverInfoById.at(id);
 }
 }
@@ -362,7 +362,7 @@ const RoadType* TerrainTypeHandler::getRoadByCode(const std::string& roadCode) c
 	return roadInfoByCode.at(roadCode);
 	return roadInfoByCode.at(roadCode);
 }
 }
 
 
-const RoadType* TerrainTypeHandler::getRoadById(TRoad id) const
+const RoadType* TerrainTypeHandler::getRoadById(TRoadId id) const
 {
 {
 	return roadInfoById.at(id);
 	return roadInfoById.at(id);
 }
 }
@@ -440,17 +440,16 @@ bool TerrainType::isTransitionRequired() const
 	return transitionRequired;
 	return transitionRequired;
 }
 }
 
 
-RiverType::RiverType(const std::string & fileName, const std::string & code, TRiver id):
+RiverType::RiverType(const std::string & fileName, const std::string & code, TRiverId id):
 	fileName(fileName),
 	fileName(fileName),
 	code(code),
 	code(code),
 	id(id)
 	id(id)
 {
 {
 }
 }
 
 
-RoadType::RoadType(const std::string& fileName, const std::string& code, TRoad id):
+RoadType::RoadType(const std::string& fileName, const std::string& code, TRoadId id):
 	fileName(fileName),
 	fileName(fileName),
 	code(code),
 	code(code),
-	id(id),
-	movementCost(GameConstants::BASE_MOVEMENT_COST)
+	id(id)
 {
 {
 }
 }

+ 17 - 17
lib/Terrain.h

@@ -29,7 +29,7 @@ public:
 	};
 	};
 	
 	
 	std::vector<std::string> battleFields;
 	std::vector<std::string> battleFields;
-	std::vector<TTerrain> prohibitTransitions;
+	std::vector<TTerrainId> prohibitTransitions;
 	std::array<int, 3> minimapBlocked;
 	std::array<int, 3> minimapBlocked;
 	std::array<int, 3> minimapUnblocked;
 	std::array<int, 3> minimapUnblocked;
 	std::string name;
 	std::string name;
@@ -38,10 +38,10 @@ public:
 	std::string terrainText;
 	std::string terrainText;
 	std::string typeCode;
 	std::string typeCode;
 	std::string terrainViewPatterns;
 	std::string terrainViewPatterns;
-	TRiver river;
+	TRiverId river;
 
 
-	TTerrain id;
-	TTerrain rockTerrain;
+	TTerrainId id;
+	TTerrainId rockTerrain;
 	int moveCost;
 	int moveCost;
 	int horseSoundId;
 	int horseSoundId;
 	ui8 passabilityType;
 	ui8 passabilityType;
@@ -94,9 +94,9 @@ public:
 	std::string fileName;
 	std::string fileName;
 	std::string code;
 	std::string code;
 	std::string deltaName;
 	std::string deltaName;
-	TRiver id;
+	TRiverId id;
 
 
-	RiverType(const std::string & fileName = "", const std::string& code = "", TRiver id = River::NO_RIVER);
+	RiverType(const std::string & fileName = "", const std::string & code = "", TRiverId id = River::NO_RIVER);
 
 
 	template <typename Handler> void serialize(Handler& h, const int version)
 	template <typename Handler> void serialize(Handler& h, const int version)
 	{
 	{
@@ -112,10 +112,10 @@ class DLL_LINKAGE RoadType
 public:
 public:
 	std::string fileName;
 	std::string fileName;
 	std::string code;
 	std::string code;
-	TRoad id;
+	TRoadId id;
 	ui8 movementCost;
 	ui8 movementCost;
 
 
-	RoadType(const std::string & fileName = "", const std::string& code = "", TRoad id = Road::NO_ROAD);
+	RoadType(const std::string & fileName = "", const std::string& code = "", TRoadId id = Road::NO_ROAD);
 
 
 	template <typename Handler> void serialize(Handler& h, const int version)
 	template <typename Handler> void serialize(Handler& h, const int version)
 	{
 	{
@@ -133,24 +133,21 @@ class DLL_LINKAGE TerrainTypeHandler //TODO: public IHandlerBase ?
 public:
 public:
 
 
 	TerrainTypeHandler();
 	TerrainTypeHandler();
-	void initTerrains(const std::vector<std::string> & allConfigs);
-	void initRivers(const std::vector<std::string> & allConfigs);
-	void initRoads(const std::vector<std::string> & allConfigs);
 
 
 	const std::vector<TerrainType *> & terrains() const;
 	const std::vector<TerrainType *> & terrains() const;
 	const TerrainType * getInfoByName(const std::string & terrainName) const;
 	const TerrainType * getInfoByName(const std::string & terrainName) const;
 	const TerrainType * getInfoByCode(const std::string & terrainCode) const;
 	const TerrainType * getInfoByCode(const std::string & terrainCode) const;
-	const TerrainType * getInfoById(TTerrain id) const;
+	const TerrainType * getInfoById(TTerrainId id) const;
 
 
 	const std::vector<RiverType *> & rivers() const;
 	const std::vector<RiverType *> & rivers() const;
 	const RiverType * getRiverByName(const std::string & riverName) const;
 	const RiverType * getRiverByName(const std::string & riverName) const;
 	const RiverType * getRiverByCode(const std::string & riverCode) const;
 	const RiverType * getRiverByCode(const std::string & riverCode) const;
-	const RiverType * getRiverById(TRiver id) const;
+	const RiverType * getRiverById(TRiverId id) const;
 
 
 	const std::vector<RoadType *> & roads() const;
 	const std::vector<RoadType *> & roads() const;
 	const RoadType * getRoadByName(const std::string & roadName) const;
 	const RoadType * getRoadByName(const std::string & roadName) const;
 	const RoadType * getRoadByCode(const std::string & roadCode) const;
 	const RoadType * getRoadByCode(const std::string & roadCode) const;
-	const RoadType * getRoadById(TRoad id) const;
+	const RoadType * getRoadById(TRoadId id) const;
 
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
 	{
@@ -174,16 +171,19 @@ private:
 
 
 	std::unordered_map<std::string, const TerrainType*> terrainInfoByName;
 	std::unordered_map<std::string, const TerrainType*> terrainInfoByName;
 	std::unordered_map<std::string, const TerrainType*> terrainInfoByCode;
 	std::unordered_map<std::string, const TerrainType*> terrainInfoByCode;
-	std::unordered_map<TTerrain, const TerrainType*> terrainInfoById;
+	std::unordered_map<TTerrainId, const TerrainType*> terrainInfoById;
 
 
 	std::unordered_map<std::string, const RiverType*> riverInfoByName;
 	std::unordered_map<std::string, const RiverType*> riverInfoByName;
 	std::unordered_map<std::string, const RiverType*> riverInfoByCode;
 	std::unordered_map<std::string, const RiverType*> riverInfoByCode;
-	std::unordered_map<TRiver, const RiverType*> riverInfoById;
+	std::unordered_map<TRiverId, const RiverType*> riverInfoById;
 
 
 	std::unordered_map<std::string, const RoadType*> roadInfoByName;
 	std::unordered_map<std::string, const RoadType*> roadInfoByName;
 	std::unordered_map<std::string, const RoadType*> roadInfoByCode;
 	std::unordered_map<std::string, const RoadType*> roadInfoByCode;
-	std::unordered_map<TRoad, const RoadType*> roadInfoById;
+	std::unordered_map<TRoadId, const RoadType*> roadInfoById;
 
 
+	void initTerrains(const std::vector<std::string> & allConfigs);
+	void initRivers(const std::vector<std::string> & allConfigs);
+	void initRoads(const std::vector<std::string> & allConfigs);
 	void recreateTerrainMaps();
 	void recreateTerrainMaps();
 	void recreateRiverMaps();
 	void recreateRiverMaps();
 	void recreateRoadMaps();
 	void recreateRoadMaps();

+ 2 - 2
lib/battle/BattleInfo.cpp

@@ -189,7 +189,7 @@ struct RangeGenerator
 	std::function<int()> myRand;
 	std::function<int()> myRand;
 };
 };
 
 
-BattleInfo * BattleInfo::setupBattle(const int3 & tile, TTerrain terrain, const BattleField & battlefieldType, const CArmedInstance * armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance * town)
+BattleInfo * BattleInfo::setupBattle(const int3 & tile, TTerrainId terrain, const BattleField & battlefieldType, const CArmedInstance * armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance * town)
 {
 {
 	CMP_stack cmpst;
 	CMP_stack cmpst;
 	auto curB = new BattleInfo();
 	auto curB = new BattleInfo();
@@ -563,7 +563,7 @@ BattleField BattleInfo::getBattlefieldType() const
 	return battlefieldType;
 	return battlefieldType;
 }
 }
 
 
-TTerrain BattleInfo::getTerrainType() const
+TTerrainId BattleInfo::getTerrainType() const
 {
 {
 	return terrainType;
 	return terrainType;
 }
 }

+ 3 - 3
lib/battle/BattleInfo.h

@@ -37,7 +37,7 @@ public:
 	SiegeInfo si;
 	SiegeInfo si;
 
 
 	BattleField battlefieldType; //like !!BA:B
 	BattleField battlefieldType; //like !!BA:B
-	TTerrain terrainType; //used for some stack nativity checks (not the bonus limiters though that have their own copy)
+	TTerrainId terrainType; //used for some stack nativity checks (not the bonus limiters though that have their own copy)
 
 
 	ui8 tacticsSide; //which side is requested to play tactics phase
 	ui8 tacticsSide; //which side is requested to play tactics phase
 	ui8 tacticDistance; //how many hexes we can go forward (1 = only hexes adjacent to margin line)
 	ui8 tacticDistance; //how many hexes we can go forward (1 = only hexes adjacent to margin line)
@@ -73,7 +73,7 @@ public:
 	battle::Units getUnitsIf(battle::UnitFilter predicate) const override;
 	battle::Units getUnitsIf(battle::UnitFilter predicate) const override;
 
 
 	BattleField getBattlefieldType() const override;
 	BattleField getBattlefieldType() const override;
-	TTerrain getTerrainType() const override;
+	TTerrainId getTerrainType() const override;
 
 
 	ObstacleCList getAllObstacles() const override;
 	ObstacleCList getAllObstacles() const override;
 
 
@@ -138,7 +138,7 @@ public:
 	const CGHeroInstance * getHero(PlayerColor player) const; //returns fighting hero that belongs to given player
 	const CGHeroInstance * getHero(PlayerColor player) const; //returns fighting hero that belongs to given player
 
 
 	void localInit();
 	void localInit();
-	static BattleInfo * setupBattle(const int3 & tile, TTerrain, const BattleField & battlefieldType, const CArmedInstance * armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance * town);
+	static BattleInfo * setupBattle(const int3 & tile, TTerrainId, const BattleField & battlefieldType, const CArmedInstance * armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance * town);
 
 
 	ui8 whatSide(PlayerColor player) const;
 	ui8 whatSide(PlayerColor player) const;
 
 

+ 1 - 1
lib/battle/BattleProxy.cpp

@@ -47,7 +47,7 @@ BattleField BattleProxy::getBattlefieldType() const
 	return subject->battleGetBattlefieldType();
 	return subject->battleGetBattlefieldType();
 }
 }
 
 
-TTerrain BattleProxy::getTerrainType() const
+TTerrainId BattleProxy::getTerrainType() const
 {
 {
 	return subject->battleTerrainType();
 	return subject->battleTerrainType();
 }
 }

+ 1 - 1
lib/battle/BattleProxy.h

@@ -30,7 +30,7 @@ public:
 	battle::Units getUnitsIf(battle::UnitFilter predicate) const override;
 	battle::Units getUnitsIf(battle::UnitFilter predicate) const override;
 
 
 	BattleField getBattlefieldType() const override;
 	BattleField getBattlefieldType() const override;
-	TTerrain getTerrainType() const override;
+	TTerrainId getTerrainType() const override;
 
 
 	ObstacleCList getAllObstacles() const override;
 	ObstacleCList getAllObstacles() const override;
 
 

+ 2 - 2
lib/battle/CBattleInfoEssentials.cpp

@@ -14,9 +14,9 @@
 #include "../NetPacks.h"
 #include "../NetPacks.h"
 #include "../mapObjects/CGTownInstance.h"
 #include "../mapObjects/CGTownInstance.h"
 
 
-TTerrain CBattleInfoEssentials::battleTerrainType() const
+TTerrainId CBattleInfoEssentials::battleTerrainType() const
 {
 {
-	RETURN_IF_NOT_BATTLE(TTerrain());
+	RETURN_IF_NOT_BATTLE(TTerrainId());
 	return getBattle()->getTerrainType();
 	return getBattle()->getTerrainType();
 }
 }
 
 

+ 1 - 1
lib/battle/CBattleInfoEssentials.h

@@ -46,7 +46,7 @@ public:
 	BattlePerspective::BattlePerspective battleGetMySide() const;
 	BattlePerspective::BattlePerspective battleGetMySide() const;
 	const IBonusBearer * getBattleNode() const;
 	const IBonusBearer * getBattleNode() const;
 
 
-	TTerrain battleTerrainType() const override;
+	TTerrainId battleTerrainType() const override;
 	BattleField battleGetBattlefieldType() const override;
 	BattleField battleGetBattlefieldType() const override;
 	int32_t battleGetEnchanterCounter(ui8 side) const;
 	int32_t battleGetEnchanterCounter(ui8 side) const;
 
 

+ 1 - 1
lib/battle/IBattleInfoCallback.h

@@ -38,7 +38,7 @@ public:
 	virtual scripting::Pool * getContextPool() const = 0;
 	virtual scripting::Pool * getContextPool() const = 0;
 #endif
 #endif
 
 
-	virtual TTerrain battleTerrainType() const = 0;
+	virtual TTerrainId battleTerrainType() const = 0;
 	virtual BattleField battleGetBattlefieldType() const = 0;
 	virtual BattleField battleGetBattlefieldType() const = 0;
 
 
 	///return none if battle is ongoing; otherwise the victorious side (0/1) or 2 if it is a draw
 	///return none if battle is ongoing; otherwise the victorious side (0/1) or 2 if it is a draw

+ 1 - 1
lib/battle/IBattleState.h

@@ -42,7 +42,7 @@ public:
 	virtual battle::Units getUnitsIf(battle::UnitFilter predicate) const = 0;
 	virtual battle::Units getUnitsIf(battle::UnitFilter predicate) const = 0;
 
 
 	virtual BattleField getBattlefieldType() const = 0;
 	virtual BattleField getBattlefieldType() const = 0;
-	virtual TTerrain getTerrainType() const = 0;
+	virtual TTerrainId getTerrainType() const = 0;
 
 
 	virtual ObstacleCList getAllObstacles() const = 0;
 	virtual ObstacleCList getAllObstacles() const = 0;
 
 

+ 3 - 3
lib/mapObjects/CGHeroInstance.cpp

@@ -96,7 +96,7 @@ ui32 CGHeroInstance::getTileCost(const TerrainTile & dest, const TerrainTile & f
 	return (ui32)ret;
 	return (ui32)ret;
 }
 }
 
 
-TTerrain CGHeroInstance::getNativeTerrain() const
+TTerrainId CGHeroInstance::getNativeTerrain() const
 {
 {
 	// NOTE: in H3 neutral stacks will ignore terrain penalty only if placed as topmost stack(s) in hero army.
 	// NOTE: in H3 neutral stacks will ignore terrain penalty only if placed as topmost stack(s) in hero army.
 	// This is clearly bug in H3 however intended behaviour is not clear.
 	// This is clearly bug in H3 however intended behaviour is not clear.
@@ -104,11 +104,11 @@ TTerrain CGHeroInstance::getNativeTerrain() const
 	// will always have best penalty without any influence from player-defined stacks order
 	// will always have best penalty without any influence from player-defined stacks order
 
 
 	// TODO: What should we do if all hero stacks are neutral creatures?
 	// TODO: What should we do if all hero stacks are neutral creatures?
-	TTerrain nativeTerrain = Terrain::BORDER;
+	TTerrainId nativeTerrain = Terrain::BORDER;
 
 
 	for(auto stack : stacks)
 	for(auto stack : stacks)
 	{
 	{
-		TTerrain stackNativeTerrain = stack.second->type->getNativeTerrain(); //consider terrain bonuses e.g. Lodestar.
+		TTerrainId stackNativeTerrain = stack.second->type->getNativeTerrain(); //consider terrain bonuses e.g. Lodestar.
 
 
 		if(stackNativeTerrain == Terrain::BORDER) //where does this value come from?
 		if(stackNativeTerrain == Terrain::BORDER) //where does this value come from?
 			continue;
 			continue;

+ 1 - 1
lib/mapObjects/CGHeroInstance.h

@@ -155,7 +155,7 @@ public:
 	bool needsLastStack()const override;
 	bool needsLastStack()const override;
 
 
 	ui32 getTileCost(const TerrainTile &dest, const TerrainTile &from, const TurnInfo * ti) const; //move cost - applying pathfinding skill, road and terrain modifiers. NOT includes diagonal move penalty, last move levelling
 	ui32 getTileCost(const TerrainTile &dest, const TerrainTile &from, const TurnInfo * ti) const; //move cost - applying pathfinding skill, road and terrain modifiers. NOT includes diagonal move penalty, last move levelling
-	TTerrain getNativeTerrain() const;
+	TTerrainId getNativeTerrain() const;
 	ui32 getLowestCreatureSpeed() const;
 	ui32 getLowestCreatureSpeed() const;
 	int3 getPosition(bool h3m = false) const; //h3m=true - returns position of hero object; h3m=false - returns position of hero 'manifestation'
 	int3 getPosition(bool h3m = false) const; //h3m=true - returns position of hero object; h3m=false - returns position of hero 'manifestation'
 	si32 manaRegain() const; //how many points of mana can hero regain "naturally" in one day
 	si32 manaRegain() const; //how many points of mana can hero regain "naturally" in one day

+ 2 - 2
lib/mapObjects/CObjectClassesHandler.cpp

@@ -588,7 +588,7 @@ BattleField AObjectTypeHandler::getBattlefield() const
 	return battlefield ? BattleField::fromString(battlefield.get()) : BattleField::NONE;
 	return battlefield ? BattleField::fromString(battlefield.get()) : BattleField::NONE;
 }
 }
 
 
-std::vector<std::shared_ptr<const ObjectTemplate>>AObjectTypeHandler::getTemplates(TTerrain terrainType) const
+std::vector<std::shared_ptr<const ObjectTemplate>>AObjectTypeHandler::getTemplates(TTerrainId terrainType) const
 {
 {
 	std::vector<std::shared_ptr<const ObjectTemplate>> templates = getTemplates();
 	std::vector<std::shared_ptr<const ObjectTemplate>> templates = getTemplates();
 	std::vector<std::shared_ptr<const ObjectTemplate>> filtered;
 	std::vector<std::shared_ptr<const ObjectTemplate>> filtered;
@@ -605,7 +605,7 @@ std::vector<std::shared_ptr<const ObjectTemplate>>AObjectTypeHandler::getTemplat
 		return filtered;
 		return filtered;
 }
 }
 
 
-std::shared_ptr<const ObjectTemplate> AObjectTypeHandler::getOverride(TTerrain terrainType, const CGObjectInstance * object) const
+std::shared_ptr<const ObjectTemplate> AObjectTypeHandler::getOverride(TTerrainId terrainType, const CGObjectInstance * object) const
 {
 {
 	std::vector<std::shared_ptr<const ObjectTemplate>> ret = getTemplates(terrainType);
 	std::vector<std::shared_ptr<const ObjectTemplate>> ret = getTemplates(terrainType);
 	for (const auto & tmpl: ret)
 	for (const auto & tmpl: ret)

+ 2 - 2
lib/mapObjects/CObjectClassesHandler.h

@@ -182,11 +182,11 @@ public:
 
 
 	/// returns all templates matching parameters
 	/// returns all templates matching parameters
 	std::vector<std::shared_ptr<const ObjectTemplate>> getTemplates() const;
 	std::vector<std::shared_ptr<const ObjectTemplate>> getTemplates() const;
-	std::vector<std::shared_ptr<const ObjectTemplate>> getTemplates(const TTerrain terrainType) const;
+	std::vector<std::shared_ptr<const ObjectTemplate>> getTemplates(const TTerrainId terrainType) const;
 
 
 	/// returns preferred template for this object, if present (e.g. one of 3 possible templates for town - village, fort and castle)
 	/// returns preferred template for this object, if present (e.g. one of 3 possible templates for town - village, fort and castle)
 	/// note that appearance will not be changed - this must be done separately (either by assignment or via pack from server)
 	/// note that appearance will not be changed - this must be done separately (either by assignment or via pack from server)
-	std::shared_ptr<const ObjectTemplate> getOverride(TTerrain terrainType, const CGObjectInstance * object) const;
+	std::shared_ptr<const ObjectTemplate> getOverride(TTerrainId terrainType, const CGObjectInstance * object) const;
 
 
 	BattleField getBattlefield() const;
 	BattleField getBattlefield() const;
 
 

+ 7 - 7
lib/mapObjects/ObjectTemplate.cpp

@@ -156,7 +156,7 @@ void ObjectTemplate::readTxt(CLegacyConfigParser & parser)
 	std::string & terrStr = strings[4]; // allowed terrains, 1 = object can be placed on this terrain
 	std::string & terrStr = strings[4]; // allowed terrains, 1 = object can be placed on this terrain
 
 
 	assert(terrStr.size() == Terrain::ROCK - 1); // all terrains but rock
 	assert(terrStr.size() == Terrain::ROCK - 1); // all terrains but rock
-	for(TTerrain i = Terrain::FIRST_REGULAR_TERRAIN; i < Terrain::ROCK; i++)
+	for(TTerrainId i = Terrain::FIRST_REGULAR_TERRAIN; i < Terrain::ROCK; i++)
 	{
 	{
 		if (terrStr[8-i] == '1')
 		if (terrStr[8-i] == '1')
 			allowedTerrains.insert(i);
 			allowedTerrains.insert(i);
@@ -282,22 +282,22 @@ void ObjectTemplate::readJson(const JsonNode &node, const bool withTerrain)
 	else
 	else
 		visitDir = 0x00;
 		visitDir = 0x00;
 
 
-	if (withTerrain && !node["allowedTerrains"].isNull())
+	if(withTerrain && !node["allowedTerrains"].isNull())
 	{
 	{
-		for (auto& entry : node["allowedTerrains"].Vector())
+		for(auto& entry : node["allowedTerrains"].Vector())
 			allowedTerrains.insert(VLC->terrainTypeHandler->getInfoByName(entry.String())->id);
 			allowedTerrains.insert(VLC->terrainTypeHandler->getInfoByName(entry.String())->id);
 	}
 	}
 	else
 	else
 	{
 	{
-		for (const auto* terrain : VLC->terrainTypeHandler->terrains())
+		for(const auto* terrain : VLC->terrainTypeHandler->terrains())
 		{
 		{
-			if (!terrain->isPassable() || terrain->isWater())
+			if(!terrain->isPassable() || terrain->isWater())
 				continue;
 				continue;
 			allowedTerrains.insert(terrain->id);
 			allowedTerrains.insert(terrain->id);
 		}
 		}
 	}
 	}
 
 
-	if (withTerrain && allowedTerrains.empty())
+	if(withTerrain && allowedTerrains.empty())
 		logGlobal->warn("Loaded template without allowed terrains!");
 		logGlobal->warn("Loaded template without allowed terrains!");
 
 
 	auto charToTile = [&](const char & ch) -> ui8
 	auto charToTile = [&](const char & ch) -> ui8
@@ -555,7 +555,7 @@ void ObjectTemplate::calculateVisitableOffset()
 	visitableOffset = int3(0, 0, 0);
 	visitableOffset = int3(0, 0, 0);
 }
 }
 
 
-bool ObjectTemplate::canBePlacedAt(TTerrain terrain) const
+bool ObjectTemplate::canBePlacedAt(TTerrainId terrain) const
 {
 {
 	return vstd::contains(allowedTerrains, terrain);
 	return vstd::contains(allowedTerrains, terrain);
 }
 }

+ 2 - 2
lib/mapObjects/ObjectTemplate.h

@@ -31,7 +31,7 @@ class DLL_LINKAGE ObjectTemplate
 	/// directions from which object can be entered, format same as for moveDir in CGHeroInstance(but 0 - 7)
 	/// directions from which object can be entered, format same as for moveDir in CGHeroInstance(but 0 - 7)
 	ui8 visitDir;
 	ui8 visitDir;
 	/// list of terrains on which this object can be placed
 	/// list of terrains on which this object can be placed
-	std::set<TTerrain> allowedTerrains;
+	std::set<TTerrainId> allowedTerrains;
 
 
 	void afterLoadFixup();
 	void afterLoadFixup();
 
 
@@ -98,7 +98,7 @@ public:
 	};
 	};
 
 
 	// Checks if object can be placed on specific terrain
 	// Checks if object can be placed on specific terrain
-	bool canBePlacedAt(TTerrain terrain) const;
+	bool canBePlacedAt(TTerrainId terrain) const;
 
 
 	ObjectTemplate();
 	ObjectTemplate();
 	//custom copy constructor is required
 	//custom copy constructor is required

+ 2 - 2
lib/mapping/CDrawRoadsOperation.cpp

@@ -156,14 +156,14 @@ CDrawLinesOperation::CDrawLinesOperation(CMap * map, const CTerrainSelection & t
 }
 }
 
 
 ///CDrawRoadsOperation
 ///CDrawRoadsOperation
-CDrawRoadsOperation::CDrawRoadsOperation(CMap * map, const CTerrainSelection & terrainSel, TRoad roadType, CRandomGenerator * gen):
+CDrawRoadsOperation::CDrawRoadsOperation(CMap * map, const CTerrainSelection & terrainSel, TRoadId roadType, CRandomGenerator * gen):
 	CDrawLinesOperation(map, terrainSel,gen),
 	CDrawLinesOperation(map, terrainSel,gen),
 	roadType(roadType)
 	roadType(roadType)
 {
 {
 }
 }
 
 
 ///CDrawRiversOperation
 ///CDrawRiversOperation
-CDrawRiversOperation::CDrawRiversOperation(CMap * map, const CTerrainSelection & terrainSel, TRiver riverType, CRandomGenerator * gen):
+CDrawRiversOperation::CDrawRiversOperation(CMap * map, const CTerrainSelection & terrainSel, TRiverId riverType, CRandomGenerator * gen):
 	CDrawLinesOperation(map, terrainSel, gen),
 	CDrawLinesOperation(map, terrainSel, gen),
 	riverType(riverType)
 	riverType(riverType)
 {
 {

+ 4 - 4
lib/mapping/CDrawRoadsOperation.h

@@ -61,7 +61,7 @@ protected:
 class CDrawRoadsOperation : public CDrawLinesOperation
 class CDrawRoadsOperation : public CDrawLinesOperation
 {
 {
 public:
 public:
-	CDrawRoadsOperation(CMap * map, const CTerrainSelection & terrainSel, TRoad roadType, CRandomGenerator * gen);
+	CDrawRoadsOperation(CMap * map, const CTerrainSelection & terrainSel, TRoadId roadType, CRandomGenerator * gen);
 	std::string getLabel() const override;
 	std::string getLabel() const override;
 	
 	
 protected:
 protected:
@@ -72,13 +72,13 @@ protected:
 	void updateTile(TerrainTile & tile, const CDrawLinesOperation::LinePattern & pattern, const int flip) override;
 	void updateTile(TerrainTile & tile, const CDrawLinesOperation::LinePattern & pattern, const int flip) override;
 	
 	
 private:
 private:
-	TRoad roadType;
+	TRoadId roadType;
 };
 };
 
 
 class CDrawRiversOperation : public CDrawLinesOperation
 class CDrawRiversOperation : public CDrawLinesOperation
 {
 {
 public:
 public:
-	CDrawRiversOperation(CMap * map, const CTerrainSelection & terrainSel, TRoad roadType, CRandomGenerator * gen);
+	CDrawRiversOperation(CMap * map, const CTerrainSelection & terrainSel, TRoadId roadType, CRandomGenerator * gen);
 	std::string getLabel() const override;
 	std::string getLabel() const override;
 	
 	
 protected:
 protected:
@@ -89,5 +89,5 @@ protected:
 	void updateTile(TerrainTile & tile, const CDrawLinesOperation::LinePattern & pattern, const int flip) override;
 	void updateTile(TerrainTile & tile, const CDrawLinesOperation::LinePattern & pattern, const int flip) override;
 	
 	
 private:
 private:
-	TRiver riverType;
+	TRiverId riverType;
 };
 };

+ 3 - 3
lib/mapping/CMapEditManager.cpp

@@ -124,19 +124,19 @@ void CMapEditManager::clearTerrain(CRandomGenerator * gen)
 	execute(make_unique<CClearTerrainOperation>(map, gen ? gen : &(this->gen)));
 	execute(make_unique<CClearTerrainOperation>(map, gen ? gen : &(this->gen)));
 }
 }
 
 
-void CMapEditManager::drawTerrain(TTerrain terType, CRandomGenerator * gen)
+void CMapEditManager::drawTerrain(TTerrainId terType, CRandomGenerator * gen)
 {
 {
 	execute(make_unique<CDrawTerrainOperation>(map, terrainSel, terType, gen ? gen : &(this->gen)));
 	execute(make_unique<CDrawTerrainOperation>(map, terrainSel, terType, gen ? gen : &(this->gen)));
 	terrainSel.clearSelection();
 	terrainSel.clearSelection();
 }
 }
 
 
-void CMapEditManager::drawRoad(TRoad roadType, CRandomGenerator* gen)
+void CMapEditManager::drawRoad(TRoadId roadType, CRandomGenerator* gen)
 {
 {
 	execute(make_unique<CDrawRoadsOperation>(map, terrainSel, roadType, gen ? gen : &(this->gen)));
 	execute(make_unique<CDrawRoadsOperation>(map, terrainSel, roadType, gen ? gen : &(this->gen)));
 	terrainSel.clearSelection();
 	terrainSel.clearSelection();
 }
 }
 
 
-void CMapEditManager::drawRiver(TRiver riverType, CRandomGenerator* gen)
+void CMapEditManager::drawRiver(TRiverId riverType, CRandomGenerator* gen)
 {
 {
 	execute(make_unique<CDrawRiversOperation>(map, terrainSel, riverType, gen ? gen : &(this->gen)));
 	execute(make_unique<CDrawRiversOperation>(map, terrainSel, riverType, gen ? gen : &(this->gen)));
 	terrainSel.clearSelection();
 	terrainSel.clearSelection();

+ 3 - 3
lib/mapping/CMapEditManager.h

@@ -70,13 +70,13 @@ public:
 	void clearTerrain(CRandomGenerator * gen = nullptr);
 	void clearTerrain(CRandomGenerator * gen = nullptr);
 
 
 	/// Draws terrain at the current terrain selection. The selection will be cleared automatically.
 	/// Draws terrain at the current terrain selection. The selection will be cleared automatically.
-	void drawTerrain(TTerrain terType, CRandomGenerator * gen = nullptr);
+	void drawTerrain(TTerrainId terType, CRandomGenerator * gen = nullptr);
 
 
 	/// Draws roads at the current terrain selection. The selection will be cleared automatically.
 	/// Draws roads at the current terrain selection. The selection will be cleared automatically.
-	void drawRoad(TRoad roadType, CRandomGenerator * gen = nullptr);
+	void drawRoad(TRoadId roadType, CRandomGenerator * gen = nullptr);
 	
 	
 	/// Draws rivers at the current terrain selection. The selection will be cleared automatically.
 	/// Draws rivers at the current terrain selection. The selection will be cleared automatically.
-	void drawRiver(TRiver riverType, CRandomGenerator * gen = nullptr);
+	void drawRiver(TRiverId riverType, CRandomGenerator * gen = nullptr);
 
 
 	void insertObject(CGObjectInstance * obj);
 	void insertObject(CGObjectInstance * obj);
 	void insertObjects(std::set<CGObjectInstance *> & objects);
 	void insertObjects(std::set<CGObjectInstance *> & objects);

+ 1 - 1
lib/mapping/CMapOperation.cpp

@@ -81,7 +81,7 @@ void CComposedOperation::addOperation(std::unique_ptr<CMapOperation>&& operation
 	operations.push_back(std::move(operation));
 	operations.push_back(std::move(operation));
 }
 }
 
 
-CDrawTerrainOperation::CDrawTerrainOperation(CMap* map, const CTerrainSelection& terrainSel, TTerrain terType, CRandomGenerator* gen):
+CDrawTerrainOperation::CDrawTerrainOperation(CMap* map, const CTerrainSelection& terrainSel, TTerrainId terType, CRandomGenerator* gen):
 	CMapOperation(map),
 	CMapOperation(map),
 	terrainSel(terrainSel),
 	terrainSel(terrainSel),
 	terType(terType),
 	terType(terType),

+ 2 - 2
lib/mapping/CMapOperation.h

@@ -61,7 +61,7 @@ private:
 class CDrawTerrainOperation : public CMapOperation
 class CDrawTerrainOperation : public CMapOperation
 {
 {
 public:
 public:
-	CDrawTerrainOperation(CMap * map, const CTerrainSelection & terrainSel, TTerrain terType, CRandomGenerator * gen);
+	CDrawTerrainOperation(CMap * map, const CTerrainSelection & terrainSel, TTerrainId terType, CRandomGenerator * gen);
 
 
 	void execute() override;
 	void execute() override;
 	void undo() override;
 	void undo() override;
@@ -98,7 +98,7 @@ private:
 	ValidationResult validateTerrainViewInner(const int3 & pos, const TerrainViewPattern & pattern, int recDepth = 0) const;
 	ValidationResult validateTerrainViewInner(const int3 & pos, const TerrainViewPattern & pattern, int recDepth = 0) const;
 
 
 	CTerrainSelection terrainSel;
 	CTerrainSelection terrainSel;
-	TTerrain terType;
+	TTerrainId terType;
 	CRandomGenerator* gen;
 	CRandomGenerator* gen;
 	std::set<int3> invalidatedTerViews;
 	std::set<int3> invalidatedTerViews;
 };
 };

+ 2 - 2
lib/mapping/MapEditUtils.cpp

@@ -268,7 +268,7 @@ CTerrainViewPatternConfig::~CTerrainViewPatternConfig()
 
 
 }
 }
 
 
-const std::vector<CTerrainViewPatternConfig::TVPVector> & CTerrainViewPatternConfig::getTerrainViewPatterns(TTerrain terrain) const
+const std::vector<CTerrainViewPatternConfig::TVPVector> & CTerrainViewPatternConfig::getTerrainViewPatterns(TTerrainId terrain) const
 {
 {
 	auto iter = terrainViewPatterns.find(VLC->terrainTypeHandler->terrains()[terrain]->terrainViewPatterns);
 	auto iter = terrainViewPatterns.find(VLC->terrainTypeHandler->terrains()[terrain]->terrainViewPatterns);
 	if (iter == terrainViewPatterns.end())
 	if (iter == terrainViewPatterns.end())
@@ -293,7 +293,7 @@ boost::optional<const TerrainViewPattern &> CTerrainViewPatternConfig::getTerrai
 	return boost::optional<const TerrainViewPattern&>();
 	return boost::optional<const TerrainViewPattern&>();
 }
 }
 
 
-boost::optional<const CTerrainViewPatternConfig::TVPVector &> CTerrainViewPatternConfig::getTerrainViewPatternsById(TTerrain terrain, const std::string & id) const
+boost::optional<const CTerrainViewPatternConfig::TVPVector &> CTerrainViewPatternConfig::getTerrainViewPatternsById(TTerrainId terrain, const std::string & id) const
 {
 {
 	const std::vector<TVPVector> & groupPatterns = getTerrainViewPatterns(terrain);
 	const std::vector<TVPVector> & groupPatterns = getTerrainViewPatterns(terrain);
 	for (const TVPVector & patternFlips : groupPatterns)
 	for (const TVPVector & patternFlips : groupPatterns)

+ 2 - 2
lib/mapping/MapEditUtils.h

@@ -215,9 +215,9 @@ public:
 	CTerrainViewPatternConfig();
 	CTerrainViewPatternConfig();
 	~CTerrainViewPatternConfig();
 	~CTerrainViewPatternConfig();
 
 
-	const std::vector<TVPVector> & getTerrainViewPatterns(TTerrain terrain) const;
+	const std::vector<TVPVector> & getTerrainViewPatterns(TTerrainId terrain) const;
 	boost::optional<const TerrainViewPattern &> getTerrainViewPatternById(std::string patternId, const std::string & id) const;
 	boost::optional<const TerrainViewPattern &> getTerrainViewPatternById(std::string patternId, const std::string & id) const;
-	boost::optional<const TVPVector &> getTerrainViewPatternsById(TTerrain terrain, const std::string & id) const;
+	boost::optional<const TVPVector &> getTerrainViewPatternsById(TTerrainId terrain, const std::string & id) const;
 	const TVPVector * getTerrainTypePatternById(const std::string & id) const;
 	const TVPVector * getTerrainTypePatternById(const std::string & id) const;
 	void flipPattern(TerrainViewPattern & pattern, int flip) const;
 	void flipPattern(TerrainViewPattern & pattern, int flip) const;
 
 

+ 2 - 2
lib/rmg/CRmgTemplate.cpp

@@ -215,12 +215,12 @@ boost::optional<int> ZoneOptions::getOwner() const
 	return owner;
 	return owner;
 }
 }
 
 
-const std::set<TTerrain> & ZoneOptions::getTerrainTypes() const
+const std::set<TTerrainId> & ZoneOptions::getTerrainTypes() const
 {
 {
 	return terrainTypes;
 	return terrainTypes;
 }
 }
 
 
-void ZoneOptions::setTerrainTypes(const std::set<TTerrain> & value)
+void ZoneOptions::setTerrainTypes(const std::set<TTerrainId> & value)
 {
 {
 	//assert(value.find(ETerrainType::WRONG) == value.end() && value.find(ETerrainType::BORDER) == value.end() &&
 	//assert(value.find(ETerrainType::WRONG) == value.end() && value.find(ETerrainType::BORDER) == value.end() &&
 	//	   value.find(ETerrainType::WATER) == value.end() && value.find(ETerrainType::ROCK) == value.end());
 	//	   value.find(ETerrainType::WATER) == value.end() && value.find(ETerrainType::ROCK) == value.end());

+ 3 - 3
lib/rmg/CRmgTemplate.h

@@ -103,8 +103,8 @@ public:
 	void setSize(int value);
 	void setSize(int value);
 	boost::optional<int> getOwner() const;
 	boost::optional<int> getOwner() const;
 
 
-	const std::set<TTerrain> & getTerrainTypes() const;
-	void setTerrainTypes(const std::set<TTerrain> & value);
+	const std::set<TTerrainId> & getTerrainTypes() const;
+	void setTerrainTypes(const std::set<TTerrainId> & value);
 
 
 	const CTownInfo & getPlayerTowns() const;
 	const CTownInfo & getPlayerTowns() const;
 	const CTownInfo & getNeutralTowns() const;
 	const CTownInfo & getNeutralTowns() const;
@@ -144,7 +144,7 @@ protected:
 	CTownInfo playerTowns;
 	CTownInfo playerTowns;
 	CTownInfo neutralTowns;
 	CTownInfo neutralTowns;
 	bool matchTerrainToTown;
 	bool matchTerrainToTown;
-	std::set<TTerrain> terrainTypes;
+	std::set<TTerrainId> terrainTypes;
 	bool townsAreSameType;
 	bool townsAreSameType;
 
 
 	std::set<TFaction> townTypes;
 	std::set<TFaction> townTypes;

+ 3 - 3
lib/rmg/Functions.cpp

@@ -93,14 +93,14 @@ void createBorder(RmgMap & gen, Zone & zone)
 	}
 	}
 }
 }
 
 
-void paintZoneTerrain(const Zone & zone, CRandomGenerator & generator, RmgMap & map, TTerrain terrain)
+void paintZoneTerrain(const Zone & zone, CRandomGenerator & generator, RmgMap & map, TTerrainId terrain)
 {
 {
 	auto v = zone.getArea().getTilesVector();
 	auto v = zone.getArea().getTilesVector();
 	map.getEditManager()->getTerrainSelection().setSelection(v);
 	map.getEditManager()->getTerrainSelection().setSelection(v);
 	map.getEditManager()->drawTerrain(terrain, &generator);
 	map.getEditManager()->drawTerrain(terrain, &generator);
 }
 }
 
 
-int chooseRandomAppearance(CRandomGenerator & generator, si32 ObjID, TTerrain terrain)
+int chooseRandomAppearance(CRandomGenerator & generator, si32 ObjID, TTerrainId terrain)
 {
 {
 	auto factories = VLC->objtypeh->knownSubObjects(ObjID);
 	auto factories = VLC->objtypeh->knownSubObjects(ObjID);
 	vstd::erase_if(factories, [ObjID, &terrain](si32 f)
 	vstd::erase_if(factories, [ObjID, &terrain](si32 f)
@@ -116,7 +116,7 @@ void initTerrainType(Zone & zone, CMapGenerator & gen)
 	if(zone.getType()==ETemplateZoneType::WATER)
 	if(zone.getType()==ETemplateZoneType::WATER)
 	{
 	{
 		//collect all water terrain types
 		//collect all water terrain types
-		std::vector<TTerrain> waterTerrains;
+		std::vector<TTerrainId> waterTerrains;
 		for(auto & terrain : VLC->terrainTypeHandler->terrains())
 		for(auto & terrain : VLC->terrainTypeHandler->terrains())
 			if(terrain->isWater())
 			if(terrain->isWater())
 				waterTerrains.push_back(terrain->id);
 				waterTerrains.push_back(terrain->id);

+ 2 - 2
lib/rmg/Functions.h

@@ -40,9 +40,9 @@ rmg::Tileset collectDistantTiles(const Zone & zone, int distance);
 
 
 void createBorder(RmgMap & gen, Zone & zone);
 void createBorder(RmgMap & gen, Zone & zone);
 
 
-void paintZoneTerrain(const Zone & zone, CRandomGenerator & generator, RmgMap & map, TTerrain terrainType);
+void paintZoneTerrain(const Zone & zone, CRandomGenerator & generator, RmgMap & map, TTerrainId terrainType);
 
 
 void initTerrainType(Zone & zone, CMapGenerator & gen);
 void initTerrainType(Zone & zone, CMapGenerator & gen);
 
 
-int chooseRandomAppearance(CRandomGenerator & generator, si32 ObjID, TTerrain terrain);
+int chooseRandomAppearance(CRandomGenerator & generator, si32 ObjID, TTerrainId terrain);
 
 

+ 1 - 1
lib/rmg/ObstaclePlacer.cpp

@@ -24,7 +24,7 @@
 #include "Functions.h"
 #include "Functions.h"
 #include "../mapping/CMapEditManager.h"
 #include "../mapping/CMapEditManager.h"
 
 
-void ObstacleProxy::collectPossibleObstacles(TTerrain terrain)
+void ObstacleProxy::collectPossibleObstacles(TTerrainId terrain)
 {
 {
 	//get all possible obstacles for this terrain
 	//get all possible obstacles for this terrain
 	for(auto primaryID : VLC->objtypeh->knownObjects())
 	for(auto primaryID : VLC->objtypeh->knownObjects())

+ 1 - 1
lib/rmg/ObstaclePlacer.h

@@ -23,7 +23,7 @@ public:
 
 
 	rmg::Area blockedArea;
 	rmg::Area blockedArea;
 
 
-	void collectPossibleObstacles(TTerrain terrain);
+	void collectPossibleObstacles(TTerrainId terrain);
 
 
 	void placeObstacles(CMap * map, CRandomGenerator & rand);
 	void placeObstacles(CMap * map, CRandomGenerator & rand);
 
 

+ 1 - 1
lib/rmg/RmgMap.cpp

@@ -229,7 +229,7 @@ void RmgMap::setOccupied(const int3 &tile, ETileType::ETileType state)
 	tiles[tile.x][tile.y][tile.z].setOccupied(state);
 	tiles[tile.x][tile.y][tile.z].setOccupied(state);
 }
 }
 
 
-void RmgMap::setRoad(const int3& tile, TRoad roadType)
+void RmgMap::setRoad(const int3& tile, TRoadId roadType)
 {
 {
 	assertOnMap(tile);
 	assertOnMap(tile);
 	
 	

+ 1 - 1
lib/rmg/RmgMap.h

@@ -44,7 +44,7 @@ public:
 	bool isOnMap(const int3 & tile) const;
 	bool isOnMap(const int3 & tile) const;
 	
 	
 	void setOccupied(const int3 &tile, ETileType::ETileType state);
 	void setOccupied(const int3 &tile, ETileType::ETileType state);
-	void setRoad(const int3 &tile, TRoad roadType);
+	void setRoad(const int3 &tile, TRoadId roadType);
 	
 	
 	TileInfo getTile(const int3 & tile) const;
 	TileInfo getTile(const int3 & tile) const;
 		
 		

+ 2 - 2
lib/rmg/RmgObject.cpp

@@ -103,7 +103,7 @@ void Object::Instance::setPositionRaw(const int3 & position)
 	dObject.pos = dPosition + dParent.getPosition();
 	dObject.pos = dPosition + dParent.getPosition();
 }
 }
 
 
-void Object::Instance::setTemplate(const TTerrain & terrain)
+void Object::Instance::setTemplate(const TTerrainId & terrain)
 {
 {
 	if(dObject.appearance->id == Obj::NO_OBJ)
 	if(dObject.appearance->id == Obj::NO_OBJ)
 	{
 	{
@@ -257,7 +257,7 @@ void Object::setPosition(const int3 & position)
 		i.setPositionRaw(i.getPosition());
 		i.setPositionRaw(i.getPosition());
 }
 }
 
 
-void Object::setTemplate(const TTerrain & terrain)
+void Object::setTemplate(const TTerrainId & terrain)
 {
 {
 	for(auto& i : dInstances)
 	for(auto& i : dInstances)
 		i.setTemplate(terrain);
 		i.setTemplate(terrain);

+ 2 - 2
lib/rmg/RmgObject.h

@@ -33,7 +33,7 @@ public:
 		int3 getVisitablePosition() const;
 		int3 getVisitablePosition() const;
 		bool isVisitableFrom(const int3 & tile) const;
 		bool isVisitableFrom(const int3 & tile) const;
 		const Area & getAccessibleArea() const;
 		const Area & getAccessibleArea() const;
-		void setTemplate(const TTerrain & terrain); //cache invalidation
+		void setTemplate(const TTerrainId & terrain); //cache invalidation
 		
 		
 		int3 getPosition(bool isAbsolute = false) const;
 		int3 getPosition(bool isAbsolute = false) const;
 		void setPosition(const int3 & position); //cache invalidation
 		void setPosition(const int3 & position); //cache invalidation
@@ -69,7 +69,7 @@ public:
 	
 	
 	const int3 & getPosition() const;
 	const int3 & getPosition() const;
 	void setPosition(const int3 & position);
 	void setPosition(const int3 & position);
-	void setTemplate(const TTerrain & terrain);
+	void setTemplate(const TTerrainId & terrain);
 	
 	
 	const Area & getArea() const;  //lazy cache invalidation
 	const Area & getArea() const;  //lazy cache invalidation
 	
 	

+ 1 - 1
lib/rmg/RoadPlacer.cpp

@@ -70,7 +70,7 @@ void RoadPlacer::drawRoads(bool secondary)
 	zone.freePaths().unite(roads);
 	zone.freePaths().unite(roads);
 	map.getEditManager()->getTerrainSelection().setSelection(roads.getTilesVector());
 	map.getEditManager()->getTerrainSelection().setSelection(roads.getTilesVector());
 	std::string roadCode = (secondary ? generator.getConfig().secondaryRoadType : generator.getConfig().defaultRoadType);
 	std::string roadCode = (secondary ? generator.getConfig().secondaryRoadType : generator.getConfig().defaultRoadType);
-	TRoad roadType = VLC->terrainTypeHandler->getRoadByCode(roadCode)->id;
+	TRoadId roadType = VLC->terrainTypeHandler->getRoadByCode(roadCode)->id;
 	map.getEditManager()->drawRoad(roadType, &generator.rand);
 	map.getEditManager()->drawRoad(roadType, &generator.rand);
 }
 }
 
 

+ 1 - 1
lib/rmg/RockPlacer.h

@@ -26,5 +26,5 @@ public:
 protected:
 protected:
 	
 	
 	rmg::Area rockArea, accessibleArea;
 	rmg::Area rockArea, accessibleArea;
-	TTerrain rockTerrain;
+	TTerrainId rockTerrain;
 };
 };

+ 3 - 3
lib/rmg/TileInfo.cpp

@@ -61,17 +61,17 @@ ETileType::ETileType TileInfo::getTileType() const
 	return occupied;
 	return occupied;
 }
 }
 
 
-TTerrain TileInfo::getTerrainType() const
+TTerrainId TileInfo::getTerrainType() const
 {
 {
 	return terrain;
 	return terrain;
 }
 }
 
 
-void TileInfo::setTerrainType(TTerrain type)
+void TileInfo::setTerrainType(TTerrainId type)
 {
 {
 	terrain = type;
 	terrain = type;
 }
 }
 
 
-void TileInfo::setRoadType(TRoad type)
+void TileInfo::setRoadType(TRoadId type)
 {
 {
 	roadType = type;
 	roadType = type;
 	//	setOccupied(ETileType::FREE);
 	//	setOccupied(ETileType::FREE);

+ 5 - 5
lib/rmg/TileInfo.h

@@ -28,14 +28,14 @@ public:
 	bool isUsed() const;
 	bool isUsed() const;
 	bool isRoad() const;
 	bool isRoad() const;
 	void setOccupied(ETileType::ETileType value);
 	void setOccupied(ETileType::ETileType value);
-	TTerrain getTerrainType() const;
+	TTerrainId getTerrainType() const;
 	ETileType::ETileType getTileType() const;
 	ETileType::ETileType getTileType() const;
-	void setTerrainType(TTerrain value);
+	void setTerrainType(TTerrainId value);
 	
 	
-	void setRoadType(TRoad type);
+	void setRoadType(TRoadId type);
 private:
 private:
 	float nearestObjectDistance;
 	float nearestObjectDistance;
 	ETileType::ETileType occupied;
 	ETileType::ETileType occupied;
-	TTerrain terrain;
-	TRoad roadType;
+	TTerrainId terrain;
+	TRoadId roadType;
 };
 };

+ 1 - 1
lib/rmg/TreasurePlacer.cpp

@@ -811,7 +811,7 @@ ObjectInfo::ObjectInfo()
 	
 	
 }
 }
 
 
-void ObjectInfo::setTemplate(si32 type, si32 subtype, TTerrain terrainType)
+void ObjectInfo::setTemplate(si32 type, si32 subtype, TTerrainId terrainType)
 {
 {
 	auto templHandler = VLC->objtypeh->getHandlerFor(type, subtype);
 	auto templHandler = VLC->objtypeh->getHandlerFor(type, subtype);
 	if(!templHandler)
 	if(!templHandler)

+ 1 - 1
lib/rmg/TreasurePlacer.h

@@ -26,7 +26,7 @@ struct ObjectInfo
 	//ui32 maxPerMap; //unused
 	//ui32 maxPerMap; //unused
 	std::function<CGObjectInstance *()> generateObject;
 	std::function<CGObjectInstance *()> generateObject;
 	
 	
-	void setTemplate(si32 type, si32 subtype, TTerrain terrain);
+	void setTemplate(si32 type, si32 subtype, TTerrainId terrain);
 	
 	
 	ObjectInfo();
 	ObjectInfo();
 	
 	

+ 2 - 2
lib/rmg/Zone.cpp

@@ -132,12 +132,12 @@ void Zone::setTownType(si32 town)
 	townType = town;
 	townType = town;
 }
 }
 
 
-TTerrain Zone::getTerrainType() const
+TTerrainId Zone::getTerrainType() const
 {
 {
 	return terrainType;
 	return terrainType;
 }
 }
 
 
-void Zone::setTerrainType(TTerrain terrain)
+void Zone::setTerrainType(TTerrainId terrain)
 {
 {
 	terrainType = terrain;
 	terrainType = terrain;
 }
 }

+ 3 - 3
lib/rmg/Zone.h

@@ -98,8 +98,8 @@ public:
 	
 	
 	si32 getTownType() const;
 	si32 getTownType() const;
 	void setTownType(si32 town);
 	void setTownType(si32 town);
-	TTerrain getTerrainType() const;
-	void setTerrainType(TTerrain terrain);
+	TTerrainId getTerrainType() const;
+	void setTerrainType(TTerrainId terrain);
 		
 		
 	void connectPath(const rmg::Path & path);
 	void connectPath(const rmg::Path & path);
 	rmg::Path searchPath(const rmg::Area & src, bool onlyStraight, std::function<bool(const int3 &)> areafilter = AREA_NO_FILTER) const;
 	rmg::Path searchPath(const rmg::Area & src, bool onlyStraight, std::function<bool(const int3 &)> areafilter = AREA_NO_FILTER) const;
@@ -138,6 +138,6 @@ protected:
 	
 	
 	//template info
 	//template info
 	si32 townType;
 	si32 townType;
-	TTerrain terrainType;
+	TTerrainId terrainType;
 	
 	
 };
 };

+ 2 - 2
server/CGameHandler.cpp

@@ -2238,8 +2238,8 @@ void CGameHandler::setupBattle(int3 tile, const CArmedInstance *armies[2], const
 {
 {
 	battleResult.set(nullptr);
 	battleResult.set(nullptr);
 
 
-	const auto t = getTile(tile);
-	TTerrain terrain = t->terType->id;
+	const auto & t = *getTile(tile);
+	TTerrainId terrain = t.terType->id;
 	if (gs->map->isCoastalTile(tile)) //coastal tile is always ground
 	if (gs->map->isCoastalTile(tile)) //coastal tile is always ground
 		terrain = Terrain::SAND;
 		terrain = Terrain::SAND;
 
 

+ 2 - 2
test/game/CGameStateTest.cpp

@@ -191,9 +191,9 @@ public:
 
 
 		int3 tile(4,4,0);
 		int3 tile(4,4,0);
 
 
-		const auto t = gameCallback->getTile(tile);
+		const auto & t = *gameCallback->getTile(tile);
 
 
-		TTerrain terrain = t->terType->id;
+		TTerrainId terrain = t.terType->id;
 		BattleField terType = BattleField::fromString("grass_hills");
 		BattleField terType = BattleField::fromString("grass_hills");
 
 
 		//send info about battles
 		//send info about battles

+ 1 - 1
test/mock/mock_IBattleInfoCallback.h

@@ -17,7 +17,7 @@ class IBattleInfoCallbackMock : public IBattleInfoCallback
 {
 {
 public:
 public:
 	MOCK_CONST_METHOD0(getContextPool, scripting::Pool *());
 	MOCK_CONST_METHOD0(getContextPool, scripting::Pool *());
-	MOCK_CONST_METHOD0(battleTerrainType, TTerrain());
+	MOCK_CONST_METHOD0(battleTerrainType, TTerrainId());
 	MOCK_CONST_METHOD0(battleGetBattlefieldType, BattleField());
 	MOCK_CONST_METHOD0(battleGetBattlefieldType, BattleField());
 
 
 	MOCK_CONST_METHOD0(battleIsFinished, boost::optional<int>());
 	MOCK_CONST_METHOD0(battleIsFinished, boost::optional<int>());

+ 1 - 1
test/mock/mock_battle_IBattleState.h

@@ -19,7 +19,7 @@ public:
 	MOCK_CONST_METHOD1(getStacksIf, TStacks(TStackFilter));
 	MOCK_CONST_METHOD1(getStacksIf, TStacks(TStackFilter));
 	MOCK_CONST_METHOD1(getUnitsIf, battle::Units(battle::UnitFilter));
 	MOCK_CONST_METHOD1(getUnitsIf, battle::Units(battle::UnitFilter));
 	MOCK_CONST_METHOD0(getBattlefieldType, BattleField());
 	MOCK_CONST_METHOD0(getBattlefieldType, BattleField());
-	MOCK_CONST_METHOD0(getTerrainType, TTerrain());
+	MOCK_CONST_METHOD0(getTerrainType, TTerrainId());
 	MOCK_CONST_METHOD0(getAllObstacles, IBattleInfo::ObstacleCList());
 	MOCK_CONST_METHOD0(getAllObstacles, IBattleInfo::ObstacleCList());
 	MOCK_CONST_METHOD0(getDefendedTown, const CGTownInstance *());
 	MOCK_CONST_METHOD0(getDefendedTown, const CGTownInstance *());
 	MOCK_CONST_METHOD1(getWallState, si8(int));
 	MOCK_CONST_METHOD1(getWallState, si8(int));