瀏覽代碼

Eternal Garrison

Fixed an issue that caused heroes to stay garrisoned for ever when hero-cap was reached.
Xilmi 1 年之前
父節點
當前提交
769268cfe3

+ 2 - 3
AI/Nullkiller/Analyzers/HeroManager.cpp

@@ -189,10 +189,9 @@ float HeroManager::evaluateHero(const CGHeroInstance * hero) const
 	return evaluateFightingStrength(hero);
 }
 
-bool HeroManager::heroCapReached() const
+bool HeroManager::heroCapReached(bool includeGarrisoned) const
 {
-	const bool includeGarnisoned = true;
-	int heroCount = cb->getHeroCount(ai->playerID, includeGarnisoned);
+	int heroCount = cb->getHeroCount(ai->playerID, includeGarrisoned);
 
 	return heroCount >= ALLOWED_ROAMING_HEROES
 		|| heroCount >= ai->settings->getMaxRoamingHeroes()

+ 1 - 1
AI/Nullkiller/Analyzers/HeroManager.h

@@ -56,7 +56,7 @@ public:
 	float evaluateSecSkill(SecondarySkill skill, const CGHeroInstance * hero) const;
 	float evaluateHero(const CGHeroInstance * hero) const;
 	bool canRecruitHero(const CGTownInstance * t = nullptr) const;
-	bool heroCapReached() const;
+	bool heroCapReached(bool includeGarrisoned = true) const;
 	const CGHeroInstance * findHeroWithGrail() const;
 	const CGHeroInstance * findWeakHeroToDismiss(uint64_t armyLimit) const;
 	float getMagicStrength(const CGHeroInstance * hero) const;

+ 1 - 1
AI/Nullkiller/Pathfinding/AINodeStorage.cpp

@@ -962,7 +962,7 @@ void AINodeStorage::setHeroes(std::map<const CGHeroInstance *, HeroRole> heroes)
 		// do not allow our own heroes in garrison to act on map
 		if(hero.first->getOwner() == ai->playerID
 			&& hero.first->inTownGarrison
-			&& (ai->isHeroLocked(hero.first) || ai->heroManager->heroCapReached()))
+			&& (ai->isHeroLocked(hero.first) || ai->heroManager->heroCapReached(false)))
 		{
 			continue;
 		}