diff --git a/lib/CPathfinder.cpp b/lib/CPathfinder.cpp index 44064ba9c..4365b1554 100644 --- a/lib/CPathfinder.cpp +++ b/lib/CPathfinder.cpp @@ -1019,6 +1019,7 @@ TurnInfo::BonusCache::BonusCache(TConstBonusListPtr bl) flyingMovementVal = bl->valOfBonuses(Selector::type()(Bonus::FLYING_MOVEMENT)); waterWalking = static_cast(bl->getFirst(Selector::type()(Bonus::WATER_WALKING))); waterWalkingVal = bl->valOfBonuses(Selector::type()(Bonus::WATER_WALKING)); + pathfindingVal = bl->valOfBonuses(Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::PATHFINDING)); } TurnInfo::TurnInfo(const CGHeroInstance * Hero, const int turn) @@ -1075,6 +1076,9 @@ int TurnInfo::valOfBonuses(Bonus::BonusType type, int subtype) const return bonusCache->flyingMovementVal; case Bonus::WATER_WALKING: return bonusCache->waterWalkingVal; + case Bonus::SECONDARY_SKILL_PREMY: + if (subtype == SecondarySkill::PATHFINDING) + return bonusCache->pathfindingVal; } return bonuses->valOfBonuses(Selector::type()(type).And(Selector::subtype()(subtype))); diff --git a/lib/CPathfinder.h b/lib/CPathfinder.h index 7c5388514..0d9aac277 100644 --- a/lib/CPathfinder.h +++ b/lib/CPathfinder.h @@ -513,6 +513,7 @@ struct DLL_LINKAGE TurnInfo int flyingMovementVal; bool waterWalking; int waterWalkingVal; + int pathfindingVal; BonusCache(TConstBonusListPtr bonusList); }; diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index 307f9df6c..5546b5b59 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -103,11 +103,9 @@ ui32 CGHeroInstance::getTileCost(const TerrainTile & dest, const TerrainTile & f && !ti->hasBonusOfType(Bonus::NO_TERRAIN_PENALTY, from.terType.id()) //no special movement bonus ) { - static const CSelector selectorPATHFINDING = Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::PATHFINDING); - static const std::string keyPATHFINDING = "type_"+std::to_string((si32)Bonus::SECONDARY_SKILL_PREMY)+"s_"+std::to_string((si32)SecondarySkill::PATHFINDING); ret = VLC->heroh->terrCosts[from.terType]; - ret -= valOfBonuses(selectorPATHFINDING, keyPATHFINDING); + ret -= ti->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::PATHFINDING); if(ret < GameConstants::BASE_MOVEMENT_COST) ret = GameConstants::BASE_MOVEMENT_COST; }