From 77e43cb36f1fe1549b1f17df920827db82a769b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zieli=C5=84ski?= Date: Wed, 14 Sep 2022 15:16:12 +0200 Subject: [PATCH 1/3] Cache Pathfinding skill --- lib/CPathfinder.cpp | 4 ++++ lib/CPathfinder.h | 1 + lib/mapObjects/CGHeroInstance.cpp | 4 +--- 3 files changed, 6 insertions(+), 3 deletions(-) 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; } From 931f4af2df0c5fda4f8fa64da215f2f5a203c15d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zieli=C5=84ski?= Date: Wed, 14 Sep 2022 15:16:26 +0200 Subject: [PATCH 2/3] typo --- AI/Nullkiller/Goals/ExecuteHeroChain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AI/Nullkiller/Goals/ExecuteHeroChain.cpp b/AI/Nullkiller/Goals/ExecuteHeroChain.cpp index dcfde92f1..cd08d356e 100644 --- a/AI/Nullkiller/Goals/ExecuteHeroChain.cpp +++ b/AI/Nullkiller/Goals/ExecuteHeroChain.cpp @@ -107,7 +107,7 @@ void ExecuteHeroChain::accept(AIGateway * ai) || targetNode->turns != 0) { logAi->error( - "Enable to complete chain. Expected hero %s to arive to %s in 0 turns but he can not do this", + "Unable to complete chain. Expected hero %s to arive to %s in 0 turns but he can not do this", hero->name, node.coord.toString()); From 5e2d87abd76bb4cadafe527b553f19012aa9fa88 Mon Sep 17 00:00:00 2001 From: DjWarmonger Date: Wed, 14 Sep 2022 16:23:13 +0200 Subject: [PATCH 3/3] Update AI/Nullkiller/Goals/ExecuteHeroChain.cpp Co-authored-by: Andrey Filipenkov --- AI/Nullkiller/Goals/ExecuteHeroChain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AI/Nullkiller/Goals/ExecuteHeroChain.cpp b/AI/Nullkiller/Goals/ExecuteHeroChain.cpp index cd08d356e..3d19bdc49 100644 --- a/AI/Nullkiller/Goals/ExecuteHeroChain.cpp +++ b/AI/Nullkiller/Goals/ExecuteHeroChain.cpp @@ -107,7 +107,7 @@ void ExecuteHeroChain::accept(AIGateway * ai) || targetNode->turns != 0) { logAi->error( - "Unable to complete chain. Expected hero %s to arive to %s in 0 turns but he can not do this", + "Unable to complete chain. Expected hero %s to arrive to %s in 0 turns but he cannot do this", hero->name, node.coord.toString());