From 1450d408a2eec304f7ca92bfcbde173cfc11717e Mon Sep 17 00:00:00 2001 From: DJWarmonger Date: Thu, 26 Jul 2018 14:37:39 +0200 Subject: [PATCH] Wandering heroes may now travel to town even if it has no army in garrison. --- AI/VCAI/VCAI.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index 2b7b27c9b..e23f77597 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -1520,7 +1520,7 @@ void VCAI::wander(HeroPtr h) std::vector townsNotReachable; for(const CGTownInstance * t : cb->getTownsInfo()) { - if(!t->visitingHero && howManyReinforcementsCanGet(h, t) && !vstd::contains(townVisitsThisWeek[h], t)) + if(!t->visitingHero && !vstd::contains(townVisitsThisWeek[h], t)) { if(isAccessibleForHero(t->visitablePos(), h)) townsReachable.push_back(t); @@ -1528,10 +1528,9 @@ void VCAI::wander(HeroPtr h) townsNotReachable.push_back(t); } } - if(townsReachable.size()) + if(townsReachable.size()) //travel to town with largest garrison, or empty - better than nothing { - boost::sort(townsReachable, compareReinforcements); - dests.push_back(townsReachable.back()); + dests.push_back(*boost::max_element(townsReachable, compareReinforcements)); } else if(townsNotReachable.size()) {