diff --git a/client/CMusicHandler.cpp b/client/CMusicHandler.cpp index 376994bbf..473b2cc1a 100644 --- a/client/CMusicHandler.cpp +++ b/client/CMusicHandler.cpp @@ -119,7 +119,7 @@ CSoundHandler::CSoundHandler(): void CSoundHandler::loadHorseSounds() { - auto terrains = CGI->terrainTypeHandler->terrains(); + const auto & terrains = CGI->terrainTypeHandler->terrains(); for(const auto * terrain : terrains) { //since all sounds are hardcoded, let's keep it @@ -376,7 +376,7 @@ CMusicHandler::CMusicHandler(): void CMusicHandler::loadTerrainSounds() { - for (const auto* terrain : CGI->terrainTypeHandler->terrains()) + for (const auto * terrain : CGI->terrainTypeHandler->terrains()) { addEntryToSet("terrain", terrain->name, "Music/" + terrain->musicFilename); } diff --git a/client/CMusicHandler.h b/client/CMusicHandler.h index d71005790..401185b5f 100644 --- a/client/CMusicHandler.h +++ b/client/CMusicHandler.h @@ -84,7 +84,7 @@ public: // Sets std::vector pickupSounds; std::vector battleIntroSounds; - std::map horseSounds; + std::map horseSounds; }; // Helper //now it looks somewhat useless diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 1b935c6ed..7cf8463d3 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -2746,8 +2746,8 @@ void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path) { path.convert(0); - TTerrain currentTerrain = Terrain::BORDER; // not init yet - TTerrain newTerrain; + TTerrainId currentTerrain = Terrain::BORDER; // not init yet + TTerrainId newTerrain; int sh = -1; auto canStop = [&](CGPathNode * node) -> bool diff --git a/client/widgets/AdventureMapClasses.cpp b/client/widgets/AdventureMapClasses.cpp index 6553bc1d4..5aa52c64f 100644 --- a/client/widgets/AdventureMapClasses.cpp +++ b/client/widgets/AdventureMapClasses.cpp @@ -495,9 +495,9 @@ void CMinimapInstance::showAll(SDL_Surface * to) } } -std::map > CMinimap::loadColors() +std::map > CMinimap::loadColors() { - std::map > ret; + std::map > ret; for(const auto * terrain : CGI->terrainTypeHandler->terrains()) { diff --git a/client/widgets/AdventureMapClasses.h b/client/widgets/AdventureMapClasses.h index 75540c81a..50bb0137c 100644 --- a/client/widgets/AdventureMapClasses.h +++ b/client/widgets/AdventureMapClasses.h @@ -217,7 +217,7 @@ protected: int level; //to initialize colors - std::map > loadColors(); + std::map > loadColors(); void clickLeft(tribool down, bool previousState) override; void clickRight(tribool down, bool previousState) override; @@ -228,7 +228,7 @@ protected: public: // terrainID -> (normal color, blocked color) - const std::map > colors; + const std::map > colors; CMinimap(const Rect & position); diff --git a/lib/CCreatureHandler.cpp b/lib/CCreatureHandler.cpp index 3aeb8706d..af2a3d45f 100644 --- a/lib/CCreatureHandler.cpp +++ b/lib/CCreatureHandler.cpp @@ -283,13 +283,13 @@ std::string CCreature::nodeName() const return "\"" + namePl + "\""; } -bool CCreature::isItNativeTerrain(TTerrain terrain) const +bool CCreature::isItNativeTerrain(TTerrainId terrain) const { auto native = getNativeTerrain(); return native == terrain || native == Terrain::ANY_TERRAIN; } -TTerrain CCreature::getNativeTerrain() const +TTerrainId CCreature::getNativeTerrain() const { const std::string cachingStringNoTerrainPenalty = "type_NO_TERRAIN_PENALTY"; static const auto selectorNoTerrainPenalty = Selector::type()(Bonus::NO_TERRAIN_PENALTY); diff --git a/lib/CCreatureHandler.h b/lib/CCreatureHandler.h index d64803fb9..10122a618 100644 --- a/lib/CCreatureHandler.h +++ b/lib/CCreatureHandler.h @@ -119,14 +119,14 @@ public: ArtifactID warMachine; - bool isItNativeTerrain(TTerrain terrain) const; + bool isItNativeTerrain(TTerrainId terrain) const; /** Returns creature native terrain considering some terrain bonuses. @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 = 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 getIconIndex() const override; const std::string & getName() const override; diff --git a/lib/CGeneralTextHandler.h b/lib/CGeneralTextHandler.h index 97a7010e1..20dc8abaa 100644 --- a/lib/CGeneralTextHandler.h +++ b/lib/CGeneralTextHandler.h @@ -122,7 +122,7 @@ public: std::vector advobtxt; std::vector xtrainfo; std::vector restypes; //names of resources - std::map terrainNames; + std::map terrainNames; std::vector randsign; std::vector> mines; //first - name; second - event description std::vector seerEmpty; diff --git a/lib/CHeroHandler.h b/lib/CHeroHandler.h index 418439eab..37e2dc9fc 100644 --- a/lib/CHeroHandler.h +++ b/lib/CHeroHandler.h @@ -265,7 +265,7 @@ public: CHeroClassHandler classes; //default costs of going through terrains. -1 means terrain is impassable - std::map terrCosts; + std::map terrCosts; struct SBallisticsLevelInfo { diff --git a/lib/CPathfinder.h b/lib/CPathfinder.h index 3e02f1457..a00c251d7 100644 --- a/lib/CPathfinder.h +++ b/lib/CPathfinder.h @@ -527,7 +527,7 @@ struct DLL_LINKAGE TurnInfo TConstBonusListPtr bonuses; mutable int maxMovePointsLand; mutable int maxMovePointsWater; - TTerrain nativeTerrain; + TTerrainId nativeTerrain; TurnInfo(const CGHeroInstance * Hero, const int Turn = 0); bool isLayerAvailable(const EPathfindingLayer layer) const; diff --git a/lib/CStack.cpp b/lib/CStack.cpp index 7abb32067..29657c7dc 100644 --- a/lib/CStack.cpp +++ b/lib/CStack.cpp @@ -332,7 +332,7 @@ bool CStack::isOnNativeTerrain() const return res; } -bool CStack::isOnTerrain(TTerrain terrain) const +bool CStack::isOnTerrain(TTerrainId terrain) const { return battle->getTerrainType() == terrain; } diff --git a/lib/CStack.h b/lib/CStack.h index 09109e1ec..5d4cc9fd5 100644 --- a/lib/CStack.h +++ b/lib/CStack.h @@ -29,7 +29,7 @@ public: ui32 ID; //unique ID of stack 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; 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 isOnNativeTerrain() const; - bool isOnTerrain(TTerrain terrain) const; + bool isOnTerrain(TTerrainId terrain) const; ui32 level() const; si32 magicResistance() const override; //include aura of resistance diff --git a/lib/CTownHandler.cpp b/lib/CTownHandler.cpp index 88be8b956..1b9b4697b 100644 --- a/lib/CTownHandler.cpp +++ b/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 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 CBuilding::MODES = { @@ -942,9 +942,9 @@ void CTownHandler::loadPuzzle(CFaction &faction, const JsonNode &source) 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) { diff --git a/lib/CTownHandler.h b/lib/CTownHandler.h index 52f56e323..47b52cbb0 100644 --- a/lib/CTownHandler.h +++ b/lib/CTownHandler.h @@ -185,7 +185,7 @@ public: TFaction index; - TTerrain nativeTerrain; + TTerrainId nativeTerrain; EAlignment::EAlignment alignment; bool preferUndergroundPlacement; @@ -358,9 +358,9 @@ class DLL_LINKAGE CTownHandler : public CHandlerBase requirementsToLoad; std::vector 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(); @@ -391,7 +391,7 @@ class DLL_LINKAGE CTownHandler : public CHandlerBase TDmgRange; typedef si32 TBonusSubtype; typedef si32 TQuantity; -typedef si8 TTerrain; -typedef si8 TRoad; -typedef si8 TRiver; +typedef si8 TTerrainId; +typedef si8 TRoadId; +typedef si8 TRiverId; typedef int TRmgTemplateZoneId; diff --git a/lib/HeroBonus.cpp b/lib/HeroBonus.cpp index 042c0f526..6eb9e9813 100644 --- a/lib/HeroBonus.cpp +++ b/lib/HeroBonus.cpp @@ -2111,7 +2111,7 @@ CreatureTerrainLimiter::CreatureTerrainLimiter() { } -CreatureTerrainLimiter::CreatureTerrainLimiter(TTerrain terrain): +CreatureTerrainLimiter::CreatureTerrainLimiter(TTerrainId terrain): terrainType(terrain) { } diff --git a/lib/HeroBonus.h b/lib/HeroBonus.h index f1ff8a950..23a7d3052 100644 --- a/lib/HeroBonus.h +++ b/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 { public: - TTerrain terrainType; + TTerrainId terrainType; CreatureTerrainLimiter(); - CreatureTerrainLimiter(TTerrain terrain); + CreatureTerrainLimiter(TTerrainId terrain); int limit(const BonusLimitationContext &context) const override; virtual std::string toString() const override; diff --git a/lib/NetPacksLib.cpp b/lib/NetPacksLib.cpp index 5024a0d09..78df665db 100644 --- a/lib/NetPacksLib.cpp +++ b/lib/NetPacksLib.cpp @@ -701,7 +701,7 @@ DLL_LINKAGE void GiveHero::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 { diff --git a/lib/ObstacleHandler.cpp b/lib/ObstacleHandler.cpp index 69918e64e..a4ac99360 100644 --- a/lib/ObstacleHandler.cpp +++ b/lib/ObstacleHandler.cpp @@ -66,7 +66,7 @@ std::vector ObstacleInfo::getBlocked(BattleHex hex) const 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(); diff --git a/lib/ObstacleHandler.h b/lib/ObstacleHandler.h index e870265c9..4e9e03dcd 100644 --- a/lib/ObstacleHandler.h +++ b/lib/ObstacleHandler.h @@ -31,7 +31,7 @@ public: si32 iconIndex; std::string identifier; std::string appearAnimation, animation, dissapearAnimation; - std::vector allowedTerrains; + std::vector allowedTerrains; std::vector allowedSpecialBfields; //TODO: here is extra field to implement it's logic in the future but save backward compatibility @@ -50,7 +50,7 @@ public: std::vector 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 void serialize(Handler &h, const int version) { diff --git a/lib/Terrain.cpp b/lib/Terrain.cpp index e3902f000..6dfa102bc 100644 --- a/lib/Terrain.cpp +++ b/lib/Terrain.cpp @@ -169,11 +169,11 @@ void TerrainTypeHandler::initTerrains(const std::vector & allConfig info->terrainViewPatterns = terr.second["terrainViewPatterns"].String(); } - TTerrain id = Terrain::WRONG; + TTerrainId id = Terrain::WRONG; if(!terr.second["originalTerrainId"].isNull()) { //place in reserved slot - id = (TTerrain)(terr.second["originalTerrainId"].Float()); + id = (TTerrainId)(terr.second["originalTerrainId"].Float()); objects[id] = info; } else @@ -222,7 +222,7 @@ void TerrainTypeHandler::initRivers(const std::vector & allConfigs) if (!river.second["originalRiverId"].isNull()) { - info->id = static_cast(river.second["originalRiverId"].Float()); + info->id = static_cast(river.second["originalRiverId"].Float()); riverTypes[info->id] = info; } else @@ -257,7 +257,7 @@ void TerrainTypeHandler::initRoads(const std::vector & allConfigs) if (!road.second["originalRoadId"].isNull()) { - info->id = static_cast(road.second["originalRoadId"].Float()); + info->id = static_cast(road.second["originalRoadId"].Float()); roadTypes[info->id] = info; } else @@ -332,7 +332,7 @@ const TerrainType* TerrainTypeHandler::getInfoByCode(const std::string& terrainC return terrainInfoByCode.at(terrainCode); } -const TerrainType* TerrainTypeHandler::getInfoById(TTerrain id) const +const TerrainType* TerrainTypeHandler::getInfoById(TTerrainId id) const { return terrainInfoById.at(id); } @@ -347,7 +347,7 @@ const RiverType* TerrainTypeHandler::getRiverByCode(const std::string& riverCode return riverInfoByCode.at(riverCode); } -const RiverType* TerrainTypeHandler::getRiverById(TRiver id) const +const RiverType* TerrainTypeHandler::getRiverById(TRiverId id) const { return riverInfoById.at(id); } @@ -362,7 +362,7 @@ const RoadType* TerrainTypeHandler::getRoadByCode(const std::string& roadCode) c return roadInfoByCode.at(roadCode); } -const RoadType* TerrainTypeHandler::getRoadById(TRoad id) const +const RoadType* TerrainTypeHandler::getRoadById(TRoadId id) const { return roadInfoById.at(id); } @@ -440,17 +440,16 @@ bool TerrainType::isTransitionRequired() const 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), code(code), 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), code(code), - id(id), - movementCost(GameConstants::BASE_MOVEMENT_COST) + id(id) { } \ No newline at end of file diff --git a/lib/Terrain.h b/lib/Terrain.h index e222365b5..3ca466b1a 100644 --- a/lib/Terrain.h +++ b/lib/Terrain.h @@ -29,7 +29,7 @@ public: }; std::vector battleFields; - std::vector prohibitTransitions; + std::vector prohibitTransitions; std::array minimapBlocked; std::array minimapUnblocked; std::string name; @@ -38,10 +38,10 @@ public: std::string terrainText; std::string typeCode; std::string terrainViewPatterns; - TRiver river; + TRiverId river; - TTerrain id; - TTerrain rockTerrain; + TTerrainId id; + TTerrainId rockTerrain; int moveCost; int horseSoundId; ui8 passabilityType; @@ -94,9 +94,9 @@ public: std::string fileName; std::string code; 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 void serialize(Handler& h, const int version) { @@ -112,10 +112,10 @@ class DLL_LINKAGE RoadType public: std::string fileName; std::string code; - TRoad id; + TRoadId id; 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 void serialize(Handler& h, const int version) { @@ -133,24 +133,21 @@ class DLL_LINKAGE TerrainTypeHandler //TODO: public IHandlerBase ? public: TerrainTypeHandler(); - void initTerrains(const std::vector & allConfigs); - void initRivers(const std::vector & allConfigs); - void initRoads(const std::vector & allConfigs); const std::vector & terrains() const; const TerrainType * getInfoByName(const std::string & terrainName) const; const TerrainType * getInfoByCode(const std::string & terrainCode) const; - const TerrainType * getInfoById(TTerrain id) const; + const TerrainType * getInfoById(TTerrainId id) const; const std::vector & rivers() const; const RiverType * getRiverByName(const std::string & riverName) const; const RiverType * getRiverByCode(const std::string & riverCode) const; - const RiverType * getRiverById(TRiver id) const; + const RiverType * getRiverById(TRiverId id) const; const std::vector & roads() const; const RoadType * getRoadByName(const std::string & roadName) const; const RoadType * getRoadByCode(const std::string & roadCode) const; - const RoadType * getRoadById(TRoad id) const; + const RoadType * getRoadById(TRoadId id) const; template void serialize(Handler &h, const int version) { @@ -174,16 +171,19 @@ private: std::unordered_map terrainInfoByName; std::unordered_map terrainInfoByCode; - std::unordered_map terrainInfoById; + std::unordered_map terrainInfoById; std::unordered_map riverInfoByName; std::unordered_map riverInfoByCode; - std::unordered_map riverInfoById; + std::unordered_map riverInfoById; std::unordered_map roadInfoByName; std::unordered_map roadInfoByCode; - std::unordered_map roadInfoById; + std::unordered_map roadInfoById; + void initTerrains(const std::vector & allConfigs); + void initRivers(const std::vector & allConfigs); + void initRoads(const std::vector & allConfigs); void recreateTerrainMaps(); void recreateRiverMaps(); void recreateRoadMaps(); diff --git a/lib/battle/BattleInfo.cpp b/lib/battle/BattleInfo.cpp index 47c797f24..919e3bdd1 100644 --- a/lib/battle/BattleInfo.cpp +++ b/lib/battle/BattleInfo.cpp @@ -189,7 +189,7 @@ struct RangeGenerator std::function 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; auto curB = new BattleInfo(); @@ -563,7 +563,7 @@ BattleField BattleInfo::getBattlefieldType() const return battlefieldType; } -TTerrain BattleInfo::getTerrainType() const +TTerrainId BattleInfo::getTerrainType() const { return terrainType; } diff --git a/lib/battle/BattleInfo.h b/lib/battle/BattleInfo.h index 84748bc46..60e146de2 100644 --- a/lib/battle/BattleInfo.h +++ b/lib/battle/BattleInfo.h @@ -37,7 +37,7 @@ public: SiegeInfo si; 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 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; BattleField getBattlefieldType() const override; - TTerrain getTerrainType() const override; + TTerrainId getTerrainType() 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 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; diff --git a/lib/battle/BattleProxy.cpp b/lib/battle/BattleProxy.cpp index 18bbc328c..d32972f3b 100644 --- a/lib/battle/BattleProxy.cpp +++ b/lib/battle/BattleProxy.cpp @@ -47,7 +47,7 @@ BattleField BattleProxy::getBattlefieldType() const return subject->battleGetBattlefieldType(); } -TTerrain BattleProxy::getTerrainType() const +TTerrainId BattleProxy::getTerrainType() const { return subject->battleTerrainType(); } diff --git a/lib/battle/BattleProxy.h b/lib/battle/BattleProxy.h index 9972fe071..3b8998353 100644 --- a/lib/battle/BattleProxy.h +++ b/lib/battle/BattleProxy.h @@ -30,7 +30,7 @@ public: battle::Units getUnitsIf(battle::UnitFilter predicate) const override; BattleField getBattlefieldType() const override; - TTerrain getTerrainType() const override; + TTerrainId getTerrainType() const override; ObstacleCList getAllObstacles() const override; diff --git a/lib/battle/CBattleInfoEssentials.cpp b/lib/battle/CBattleInfoEssentials.cpp index 512ed414c..43af98110 100644 --- a/lib/battle/CBattleInfoEssentials.cpp +++ b/lib/battle/CBattleInfoEssentials.cpp @@ -14,9 +14,9 @@ #include "../NetPacks.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(); } diff --git a/lib/battle/CBattleInfoEssentials.h b/lib/battle/CBattleInfoEssentials.h index 89b1fb90c..ef3812f1a 100644 --- a/lib/battle/CBattleInfoEssentials.h +++ b/lib/battle/CBattleInfoEssentials.h @@ -46,7 +46,7 @@ public: BattlePerspective::BattlePerspective battleGetMySide() const; const IBonusBearer * getBattleNode() const; - TTerrain battleTerrainType() const override; + TTerrainId battleTerrainType() const override; BattleField battleGetBattlefieldType() const override; int32_t battleGetEnchanterCounter(ui8 side) const; diff --git a/lib/battle/IBattleInfoCallback.h b/lib/battle/IBattleInfoCallback.h index 5a8c1c06c..41a684ad9 100644 --- a/lib/battle/IBattleInfoCallback.h +++ b/lib/battle/IBattleInfoCallback.h @@ -38,7 +38,7 @@ public: virtual scripting::Pool * getContextPool() const = 0; #endif - virtual TTerrain battleTerrainType() const = 0; + virtual TTerrainId battleTerrainType() 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 diff --git a/lib/battle/IBattleState.h b/lib/battle/IBattleState.h index 89c0f3cc3..fd52672f7 100644 --- a/lib/battle/IBattleState.h +++ b/lib/battle/IBattleState.h @@ -42,7 +42,7 @@ public: virtual battle::Units getUnitsIf(battle::UnitFilter predicate) const = 0; virtual BattleField getBattlefieldType() const = 0; - virtual TTerrain getTerrainType() const = 0; + virtual TTerrainId getTerrainType() const = 0; virtual ObstacleCList getAllObstacles() const = 0; diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index 861adc262..679a4a8e9 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -96,7 +96,7 @@ ui32 CGHeroInstance::getTileCost(const TerrainTile & dest, const TerrainTile & f 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. // 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 // TODO: What should we do if all hero stacks are neutral creatures? - TTerrain nativeTerrain = Terrain::BORDER; + TTerrainId nativeTerrain = Terrain::BORDER; 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? continue; diff --git a/lib/mapObjects/CGHeroInstance.h b/lib/mapObjects/CGHeroInstance.h index a0443bb4c..326624c0a 100644 --- a/lib/mapObjects/CGHeroInstance.h +++ b/lib/mapObjects/CGHeroInstance.h @@ -155,7 +155,7 @@ public: 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 - TTerrain getNativeTerrain() const; + TTerrainId getNativeTerrain() const; ui32 getLowestCreatureSpeed() const; 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 diff --git a/lib/mapObjects/CObjectClassesHandler.cpp b/lib/mapObjects/CObjectClassesHandler.cpp index 95caf0c14..717a6d5a7 100644 --- a/lib/mapObjects/CObjectClassesHandler.cpp +++ b/lib/mapObjects/CObjectClassesHandler.cpp @@ -588,7 +588,7 @@ BattleField AObjectTypeHandler::getBattlefield() const return battlefield ? BattleField::fromString(battlefield.get()) : BattleField::NONE; } -std::vector>AObjectTypeHandler::getTemplates(TTerrain terrainType) const +std::vector>AObjectTypeHandler::getTemplates(TTerrainId terrainType) const { std::vector> templates = getTemplates(); std::vector> filtered; @@ -605,7 +605,7 @@ std::vector>AObjectTypeHandler::getTemplat return filtered; } -std::shared_ptr AObjectTypeHandler::getOverride(TTerrain terrainType, const CGObjectInstance * object) const +std::shared_ptr AObjectTypeHandler::getOverride(TTerrainId terrainType, const CGObjectInstance * object) const { std::vector> ret = getTemplates(terrainType); for (const auto & tmpl: ret) diff --git a/lib/mapObjects/CObjectClassesHandler.h b/lib/mapObjects/CObjectClassesHandler.h index 83ff1b5f3..ef5fea929 100644 --- a/lib/mapObjects/CObjectClassesHandler.h +++ b/lib/mapObjects/CObjectClassesHandler.h @@ -182,11 +182,11 @@ public: /// returns all templates matching parameters std::vector> getTemplates() const; - std::vector> getTemplates(const TTerrain terrainType) const; + std::vector> 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) /// note that appearance will not be changed - this must be done separately (either by assignment or via pack from server) - std::shared_ptr getOverride(TTerrain terrainType, const CGObjectInstance * object) const; + std::shared_ptr getOverride(TTerrainId terrainType, const CGObjectInstance * object) const; BattleField getBattlefield() const; diff --git a/lib/mapObjects/ObjectTemplate.cpp b/lib/mapObjects/ObjectTemplate.cpp index 05ff04cf9..26f1ccd41 100644 --- a/lib/mapObjects/ObjectTemplate.cpp +++ b/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 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') allowedTerrains.insert(i); @@ -282,22 +282,22 @@ void ObjectTemplate::readJson(const JsonNode &node, const bool withTerrain) else 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); } 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; allowedTerrains.insert(terrain->id); } } - if (withTerrain && allowedTerrains.empty()) + if(withTerrain && allowedTerrains.empty()) logGlobal->warn("Loaded template without allowed terrains!"); auto charToTile = [&](const char & ch) -> ui8 @@ -555,7 +555,7 @@ void ObjectTemplate::calculateVisitableOffset() visitableOffset = int3(0, 0, 0); } -bool ObjectTemplate::canBePlacedAt(TTerrain terrain) const +bool ObjectTemplate::canBePlacedAt(TTerrainId terrain) const { return vstd::contains(allowedTerrains, terrain); } diff --git a/lib/mapObjects/ObjectTemplate.h b/lib/mapObjects/ObjectTemplate.h index e1b9c2c1b..999250ecd 100644 --- a/lib/mapObjects/ObjectTemplate.h +++ b/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) ui8 visitDir; /// list of terrains on which this object can be placed - std::set allowedTerrains; + std::set allowedTerrains; void afterLoadFixup(); @@ -98,7 +98,7 @@ public: }; // Checks if object can be placed on specific terrain - bool canBePlacedAt(TTerrain terrain) const; + bool canBePlacedAt(TTerrainId terrain) const; ObjectTemplate(); //custom copy constructor is required diff --git a/lib/mapping/CDrawRoadsOperation.cpp b/lib/mapping/CDrawRoadsOperation.cpp index 4f8bd0b24..3b624fa4f 100644 --- a/lib/mapping/CDrawRoadsOperation.cpp +++ b/lib/mapping/CDrawRoadsOperation.cpp @@ -156,14 +156,14 @@ CDrawLinesOperation::CDrawLinesOperation(CMap * map, const CTerrainSelection & t } ///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), roadType(roadType) { } ///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), riverType(riverType) { diff --git a/lib/mapping/CDrawRoadsOperation.h b/lib/mapping/CDrawRoadsOperation.h index b614811f5..de9abd4ec 100644 --- a/lib/mapping/CDrawRoadsOperation.h +++ b/lib/mapping/CDrawRoadsOperation.h @@ -61,7 +61,7 @@ protected: class CDrawRoadsOperation : public CDrawLinesOperation { 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; protected: @@ -72,13 +72,13 @@ protected: void updateTile(TerrainTile & tile, const CDrawLinesOperation::LinePattern & pattern, const int flip) override; private: - TRoad roadType; + TRoadId roadType; }; class CDrawRiversOperation : public CDrawLinesOperation { 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; protected: @@ -89,5 +89,5 @@ protected: void updateTile(TerrainTile & tile, const CDrawLinesOperation::LinePattern & pattern, const int flip) override; private: - TRiver riverType; + TRiverId riverType; }; diff --git a/lib/mapping/CMapEditManager.cpp b/lib/mapping/CMapEditManager.cpp index 3db91fda7..bb8c1a569 100644 --- a/lib/mapping/CMapEditManager.cpp +++ b/lib/mapping/CMapEditManager.cpp @@ -124,19 +124,19 @@ void CMapEditManager::clearTerrain(CRandomGenerator * gen) execute(make_unique(map, gen ? gen : &(this->gen))); } -void CMapEditManager::drawTerrain(TTerrain terType, CRandomGenerator * gen) +void CMapEditManager::drawTerrain(TTerrainId terType, CRandomGenerator * gen) { execute(make_unique(map, terrainSel, terType, gen ? gen : &(this->gen))); terrainSel.clearSelection(); } -void CMapEditManager::drawRoad(TRoad roadType, CRandomGenerator* gen) +void CMapEditManager::drawRoad(TRoadId roadType, CRandomGenerator* gen) { execute(make_unique(map, terrainSel, roadType, gen ? gen : &(this->gen))); terrainSel.clearSelection(); } -void CMapEditManager::drawRiver(TRiver riverType, CRandomGenerator* gen) +void CMapEditManager::drawRiver(TRiverId riverType, CRandomGenerator* gen) { execute(make_unique(map, terrainSel, riverType, gen ? gen : &(this->gen))); terrainSel.clearSelection(); diff --git a/lib/mapping/CMapEditManager.h b/lib/mapping/CMapEditManager.h index 970aab701..052257beb 100644 --- a/lib/mapping/CMapEditManager.h +++ b/lib/mapping/CMapEditManager.h @@ -70,13 +70,13 @@ public: void clearTerrain(CRandomGenerator * gen = nullptr); /// 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. - 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. - void drawRiver(TRiver riverType, CRandomGenerator * gen = nullptr); + void drawRiver(TRiverId riverType, CRandomGenerator * gen = nullptr); void insertObject(CGObjectInstance * obj); void insertObjects(std::set & objects); diff --git a/lib/mapping/CMapOperation.cpp b/lib/mapping/CMapOperation.cpp index 4882e0101..4392beb24 100644 --- a/lib/mapping/CMapOperation.cpp +++ b/lib/mapping/CMapOperation.cpp @@ -81,7 +81,7 @@ void CComposedOperation::addOperation(std::unique_ptr&& 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), terrainSel(terrainSel), terType(terType), diff --git a/lib/mapping/CMapOperation.h b/lib/mapping/CMapOperation.h index 0c3f851ff..3728f16c0 100644 --- a/lib/mapping/CMapOperation.h +++ b/lib/mapping/CMapOperation.h @@ -61,7 +61,7 @@ private: class CDrawTerrainOperation : public CMapOperation { 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 undo() override; @@ -98,7 +98,7 @@ private: ValidationResult validateTerrainViewInner(const int3 & pos, const TerrainViewPattern & pattern, int recDepth = 0) const; CTerrainSelection terrainSel; - TTerrain terType; + TTerrainId terType; CRandomGenerator* gen; std::set invalidatedTerViews; }; diff --git a/lib/mapping/MapEditUtils.cpp b/lib/mapping/MapEditUtils.cpp index 513e05f1a..603d009d7 100644 --- a/lib/mapping/MapEditUtils.cpp +++ b/lib/mapping/MapEditUtils.cpp @@ -268,7 +268,7 @@ CTerrainViewPatternConfig::~CTerrainViewPatternConfig() } -const std::vector & CTerrainViewPatternConfig::getTerrainViewPatterns(TTerrain terrain) const +const std::vector & CTerrainViewPatternConfig::getTerrainViewPatterns(TTerrainId terrain) const { auto iter = terrainViewPatterns.find(VLC->terrainTypeHandler->terrains()[terrain]->terrainViewPatterns); if (iter == terrainViewPatterns.end()) @@ -293,7 +293,7 @@ boost::optional CTerrainViewPatternConfig::getTerrai return boost::optional(); } -boost::optional CTerrainViewPatternConfig::getTerrainViewPatternsById(TTerrain terrain, const std::string & id) const +boost::optional CTerrainViewPatternConfig::getTerrainViewPatternsById(TTerrainId terrain, const std::string & id) const { const std::vector & groupPatterns = getTerrainViewPatterns(terrain); for (const TVPVector & patternFlips : groupPatterns) diff --git a/lib/mapping/MapEditUtils.h b/lib/mapping/MapEditUtils.h index 6a6e44962..3517f49dc 100644 --- a/lib/mapping/MapEditUtils.h +++ b/lib/mapping/MapEditUtils.h @@ -215,9 +215,9 @@ public: CTerrainViewPatternConfig(); ~CTerrainViewPatternConfig(); - const std::vector & getTerrainViewPatterns(TTerrain terrain) const; + const std::vector & getTerrainViewPatterns(TTerrainId terrain) const; boost::optional getTerrainViewPatternById(std::string patternId, const std::string & id) const; - boost::optional getTerrainViewPatternsById(TTerrain terrain, const std::string & id) const; + boost::optional getTerrainViewPatternsById(TTerrainId terrain, const std::string & id) const; const TVPVector * getTerrainTypePatternById(const std::string & id) const; void flipPattern(TerrainViewPattern & pattern, int flip) const; diff --git a/lib/rmg/CRmgTemplate.cpp b/lib/rmg/CRmgTemplate.cpp index 74a376508..7b4439227 100644 --- a/lib/rmg/CRmgTemplate.cpp +++ b/lib/rmg/CRmgTemplate.cpp @@ -215,12 +215,12 @@ boost::optional ZoneOptions::getOwner() const return owner; } -const std::set & ZoneOptions::getTerrainTypes() const +const std::set & ZoneOptions::getTerrainTypes() const { return terrainTypes; } -void ZoneOptions::setTerrainTypes(const std::set & value) +void ZoneOptions::setTerrainTypes(const std::set & value) { //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()); diff --git a/lib/rmg/CRmgTemplate.h b/lib/rmg/CRmgTemplate.h index 3007a9988..f7e5b28c8 100644 --- a/lib/rmg/CRmgTemplate.h +++ b/lib/rmg/CRmgTemplate.h @@ -103,8 +103,8 @@ public: void setSize(int value); boost::optional getOwner() const; - const std::set & getTerrainTypes() const; - void setTerrainTypes(const std::set & value); + const std::set & getTerrainTypes() const; + void setTerrainTypes(const std::set & value); const CTownInfo & getPlayerTowns() const; const CTownInfo & getNeutralTowns() const; @@ -144,7 +144,7 @@ protected: CTownInfo playerTowns; CTownInfo neutralTowns; bool matchTerrainToTown; - std::set terrainTypes; + std::set terrainTypes; bool townsAreSameType; std::set townTypes; diff --git a/lib/rmg/Functions.cpp b/lib/rmg/Functions.cpp index 7d48e836d..7195cde00 100644 --- a/lib/rmg/Functions.cpp +++ b/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(); map.getEditManager()->getTerrainSelection().setSelection(v); 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); vstd::erase_if(factories, [ObjID, &terrain](si32 f) @@ -116,7 +116,7 @@ void initTerrainType(Zone & zone, CMapGenerator & gen) if(zone.getType()==ETemplateZoneType::WATER) { //collect all water terrain types - std::vector waterTerrains; + std::vector waterTerrains; for(auto & terrain : VLC->terrainTypeHandler->terrains()) if(terrain->isWater()) waterTerrains.push_back(terrain->id); diff --git a/lib/rmg/Functions.h b/lib/rmg/Functions.h index db340c3f7..68a26229e 100644 --- a/lib/rmg/Functions.h +++ b/lib/rmg/Functions.h @@ -40,9 +40,9 @@ rmg::Tileset collectDistantTiles(const Zone & zone, int distance); 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); -int chooseRandomAppearance(CRandomGenerator & generator, si32 ObjID, TTerrain terrain); +int chooseRandomAppearance(CRandomGenerator & generator, si32 ObjID, TTerrainId terrain); diff --git a/lib/rmg/ObstaclePlacer.cpp b/lib/rmg/ObstaclePlacer.cpp index bb4c7e042..3700b4f16 100644 --- a/lib/rmg/ObstaclePlacer.cpp +++ b/lib/rmg/ObstaclePlacer.cpp @@ -24,7 +24,7 @@ #include "Functions.h" #include "../mapping/CMapEditManager.h" -void ObstacleProxy::collectPossibleObstacles(TTerrain terrain) +void ObstacleProxy::collectPossibleObstacles(TTerrainId terrain) { //get all possible obstacles for this terrain for(auto primaryID : VLC->objtypeh->knownObjects()) diff --git a/lib/rmg/ObstaclePlacer.h b/lib/rmg/ObstaclePlacer.h index e61df728f..4e1001ad3 100644 --- a/lib/rmg/ObstaclePlacer.h +++ b/lib/rmg/ObstaclePlacer.h @@ -23,7 +23,7 @@ public: rmg::Area blockedArea; - void collectPossibleObstacles(TTerrain terrain); + void collectPossibleObstacles(TTerrainId terrain); void placeObstacles(CMap * map, CRandomGenerator & rand); diff --git a/lib/rmg/RmgMap.cpp b/lib/rmg/RmgMap.cpp index 132b613ec..2d6e03b91 100644 --- a/lib/rmg/RmgMap.cpp +++ b/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); } -void RmgMap::setRoad(const int3& tile, TRoad roadType) +void RmgMap::setRoad(const int3& tile, TRoadId roadType) { assertOnMap(tile); diff --git a/lib/rmg/RmgMap.h b/lib/rmg/RmgMap.h index 22612276d..9deccac20 100644 --- a/lib/rmg/RmgMap.h +++ b/lib/rmg/RmgMap.h @@ -44,7 +44,7 @@ public: bool isOnMap(const int3 & tile) const; 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; diff --git a/lib/rmg/RmgObject.cpp b/lib/rmg/RmgObject.cpp index a1f117559..68d5a7754 100644 --- a/lib/rmg/RmgObject.cpp +++ b/lib/rmg/RmgObject.cpp @@ -103,7 +103,7 @@ void Object::Instance::setPositionRaw(const int3 & position) 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) { @@ -257,7 +257,7 @@ void Object::setPosition(const int3 & position) i.setPositionRaw(i.getPosition()); } -void Object::setTemplate(const TTerrain & terrain) +void Object::setTemplate(const TTerrainId & terrain) { for(auto& i : dInstances) i.setTemplate(terrain); diff --git a/lib/rmg/RmgObject.h b/lib/rmg/RmgObject.h index 7a72126c4..a085c6bd6 100644 --- a/lib/rmg/RmgObject.h +++ b/lib/rmg/RmgObject.h @@ -33,7 +33,7 @@ public: int3 getVisitablePosition() const; bool isVisitableFrom(const int3 & tile) 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; void setPosition(const int3 & position); //cache invalidation @@ -69,7 +69,7 @@ public: const int3 & getPosition() const; void setPosition(const int3 & position); - void setTemplate(const TTerrain & terrain); + void setTemplate(const TTerrainId & terrain); const Area & getArea() const; //lazy cache invalidation diff --git a/lib/rmg/RoadPlacer.cpp b/lib/rmg/RoadPlacer.cpp index 25016c2e8..a235388ad 100644 --- a/lib/rmg/RoadPlacer.cpp +++ b/lib/rmg/RoadPlacer.cpp @@ -70,7 +70,7 @@ void RoadPlacer::drawRoads(bool secondary) zone.freePaths().unite(roads); map.getEditManager()->getTerrainSelection().setSelection(roads.getTilesVector()); 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); } diff --git a/lib/rmg/RockPlacer.h b/lib/rmg/RockPlacer.h index 1163a7cdd..b1df1f7fe 100644 --- a/lib/rmg/RockPlacer.h +++ b/lib/rmg/RockPlacer.h @@ -26,5 +26,5 @@ public: protected: rmg::Area rockArea, accessibleArea; - TTerrain rockTerrain; + TTerrainId rockTerrain; }; diff --git a/lib/rmg/TileInfo.cpp b/lib/rmg/TileInfo.cpp index ba8a4eb35..c28841b09 100644 --- a/lib/rmg/TileInfo.cpp +++ b/lib/rmg/TileInfo.cpp @@ -61,17 +61,17 @@ ETileType::ETileType TileInfo::getTileType() const return occupied; } -TTerrain TileInfo::getTerrainType() const +TTerrainId TileInfo::getTerrainType() const { return terrain; } -void TileInfo::setTerrainType(TTerrain type) +void TileInfo::setTerrainType(TTerrainId type) { terrain = type; } -void TileInfo::setRoadType(TRoad type) +void TileInfo::setRoadType(TRoadId type) { roadType = type; // setOccupied(ETileType::FREE); diff --git a/lib/rmg/TileInfo.h b/lib/rmg/TileInfo.h index 46d0430e3..198481dc4 100644 --- a/lib/rmg/TileInfo.h +++ b/lib/rmg/TileInfo.h @@ -28,14 +28,14 @@ public: bool isUsed() const; bool isRoad() const; void setOccupied(ETileType::ETileType value); - TTerrain getTerrainType() const; + TTerrainId getTerrainType() const; ETileType::ETileType getTileType() const; - void setTerrainType(TTerrain value); + void setTerrainType(TTerrainId value); - void setRoadType(TRoad type); + void setRoadType(TRoadId type); private: float nearestObjectDistance; ETileType::ETileType occupied; - TTerrain terrain; - TRoad roadType; + TTerrainId terrain; + TRoadId roadType; }; diff --git a/lib/rmg/TreasurePlacer.cpp b/lib/rmg/TreasurePlacer.cpp index 801c6b994..83885ccb3 100644 --- a/lib/rmg/TreasurePlacer.cpp +++ b/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); if(!templHandler) diff --git a/lib/rmg/TreasurePlacer.h b/lib/rmg/TreasurePlacer.h index 9d005b224..adea2cd6f 100644 --- a/lib/rmg/TreasurePlacer.h +++ b/lib/rmg/TreasurePlacer.h @@ -26,7 +26,7 @@ struct ObjectInfo //ui32 maxPerMap; //unused std::function generateObject; - void setTemplate(si32 type, si32 subtype, TTerrain terrain); + void setTemplate(si32 type, si32 subtype, TTerrainId terrain); ObjectInfo(); diff --git a/lib/rmg/Zone.cpp b/lib/rmg/Zone.cpp index 83fbd5638..e432b102d 100644 --- a/lib/rmg/Zone.cpp +++ b/lib/rmg/Zone.cpp @@ -132,12 +132,12 @@ void Zone::setTownType(si32 town) townType = town; } -TTerrain Zone::getTerrainType() const +TTerrainId Zone::getTerrainType() const { return terrainType; } -void Zone::setTerrainType(TTerrain terrain) +void Zone::setTerrainType(TTerrainId terrain) { terrainType = terrain; } diff --git a/lib/rmg/Zone.h b/lib/rmg/Zone.h index 78ab28182..830fad6ea 100644 --- a/lib/rmg/Zone.h +++ b/lib/rmg/Zone.h @@ -98,8 +98,8 @@ public: si32 getTownType() const; void setTownType(si32 town); - TTerrain getTerrainType() const; - void setTerrainType(TTerrain terrain); + TTerrainId getTerrainType() const; + void setTerrainType(TTerrainId terrain); void connectPath(const rmg::Path & path); rmg::Path searchPath(const rmg::Area & src, bool onlyStraight, std::function areafilter = AREA_NO_FILTER) const; @@ -138,6 +138,6 @@ protected: //template info si32 townType; - TTerrain terrainType; + TTerrainId terrainType; }; diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 799c65369..d039bf749 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -2238,8 +2238,8 @@ void CGameHandler::setupBattle(int3 tile, const CArmedInstance *armies[2], const { 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 terrain = Terrain::SAND; diff --git a/test/game/CGameStateTest.cpp b/test/game/CGameStateTest.cpp index 6720bc766..cbda7d01e 100644 --- a/test/game/CGameStateTest.cpp +++ b/test/game/CGameStateTest.cpp @@ -191,9 +191,9 @@ public: 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"); //send info about battles diff --git a/test/mock/mock_IBattleInfoCallback.h b/test/mock/mock_IBattleInfoCallback.h index 0f3a42efd..aa9183de7 100644 --- a/test/mock/mock_IBattleInfoCallback.h +++ b/test/mock/mock_IBattleInfoCallback.h @@ -17,7 +17,7 @@ class IBattleInfoCallbackMock : public IBattleInfoCallback { public: MOCK_CONST_METHOD0(getContextPool, scripting::Pool *()); - MOCK_CONST_METHOD0(battleTerrainType, TTerrain()); + MOCK_CONST_METHOD0(battleTerrainType, TTerrainId()); MOCK_CONST_METHOD0(battleGetBattlefieldType, BattleField()); MOCK_CONST_METHOD0(battleIsFinished, boost::optional()); diff --git a/test/mock/mock_battle_IBattleState.h b/test/mock/mock_battle_IBattleState.h index d71eb81eb..c63d2716f 100644 --- a/test/mock/mock_battle_IBattleState.h +++ b/test/mock/mock_battle_IBattleState.h @@ -19,7 +19,7 @@ public: MOCK_CONST_METHOD1(getStacksIf, TStacks(TStackFilter)); MOCK_CONST_METHOD1(getUnitsIf, battle::Units(battle::UnitFilter)); MOCK_CONST_METHOD0(getBattlefieldType, BattleField()); - MOCK_CONST_METHOD0(getTerrainType, TTerrain()); + MOCK_CONST_METHOD0(getTerrainType, TTerrainId()); MOCK_CONST_METHOD0(getAllObstacles, IBattleInfo::ObstacleCList()); MOCK_CONST_METHOD0(getDefendedTown, const CGTownInstance *()); MOCK_CONST_METHOD1(getWallState, si8(int));