From 769268cfe34a50f38e789b600afb24e316583ad2 Mon Sep 17 00:00:00 2001 From: Xilmi Date: Sun, 29 Sep 2024 01:15:09 +0200 Subject: [PATCH] Eternal Garrison Fixed an issue that caused heroes to stay garrisoned for ever when hero-cap was reached. --- AI/Nullkiller/Analyzers/HeroManager.cpp | 5 ++--- AI/Nullkiller/Analyzers/HeroManager.h | 2 +- AI/Nullkiller/Pathfinding/AINodeStorage.cpp | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/AI/Nullkiller/Analyzers/HeroManager.cpp b/AI/Nullkiller/Analyzers/HeroManager.cpp index 594b2e394..7e88bcdce 100644 --- a/AI/Nullkiller/Analyzers/HeroManager.cpp +++ b/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() diff --git a/AI/Nullkiller/Analyzers/HeroManager.h b/AI/Nullkiller/Analyzers/HeroManager.h index 675357626..9d7f6c4e0 100644 --- a/AI/Nullkiller/Analyzers/HeroManager.h +++ b/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; diff --git a/AI/Nullkiller/Pathfinding/AINodeStorage.cpp b/AI/Nullkiller/Pathfinding/AINodeStorage.cpp index 247836768..fe8912c7a 100644 --- a/AI/Nullkiller/Pathfinding/AINodeStorage.cpp +++ b/AI/Nullkiller/Pathfinding/AINodeStorage.cpp @@ -962,7 +962,7 @@ void AINodeStorage::setHeroes(std::map 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; }