diff --git a/AI/VCAI/BuildingManager.cpp b/AI/VCAI/BuildingManager.cpp index 9b95ab2e1..a83715ad0 100644 --- a/AI/VCAI/BuildingManager.cpp +++ b/AI/VCAI/BuildingManager.cpp @@ -157,6 +157,8 @@ bool BuildingManager::getBuildingOptions(const CGTownInstance * t) //TODO: faction-specific development: use special buildings, build dwellings in better order, etc //TODO: build resource silo, defences when needed //Possible - allow "locking" on specific building (build prerequisites and then building itself) + + //TODO: There is some disabled building code in GatherTroops and GatherArmy - take it into account when enhancing building. For now AI works best with building only via Build goal. immediateBuildings.clear(); expensiveBuildings.clear(); @@ -169,6 +171,18 @@ bool BuildingManager::getBuildingOptions(const CGTownInstance * t) if (tryBuildAnyStructure(t, std::vector(essential, essential + ARRAY_COUNT(essential)))) return true; + //workaround for mantis #2696 - build fort and citadel - building castle prerequisite when trying to build capitol will be then handled without bug + if(vstd::contains(t->builtBuildings, BuildingID::CITY_HALL) && + cb->canBuildStructure(t, BuildingID::CAPITOL) != EBuildingState::HAVE_CAPITAL) + { + if(cb->canBuildStructure(t, BuildingID::CAPITOL) != EBuildingState::FORBIDDEN) + { + if(tryBuildNextStructure(t, std::vector(capitolRequirements, + capitolRequirements + ARRAY_COUNT(capitolRequirements)))) + return true; + } + } + //the more gold the better and less problems later //TODO: what about building mage guild / marketplace etc. with city hall disabled in editor? if (tryBuildNextStructure(t, std::vector(goldSource, goldSource + ARRAY_COUNT(goldSource)))) return true; @@ -177,18 +191,6 @@ bool BuildingManager::getBuildingOptions(const CGTownInstance * t) if(tryBuildThisStructure(t, BuildingID::FORT)) return true; - //workaround for mantis #2696 - build fort and citadel - building castle will be handled without bug //RECHECK THIS CODE BLOCK - its logic predates building manager - if (vstd::contains(t->builtBuildings, BuildingID::CITY_HALL) && - cb->canBuildStructure(t, BuildingID::CAPITOL) != EBuildingState::HAVE_CAPITAL) - { - if (cb->canBuildStructure(t, BuildingID::CAPITOL) != EBuildingState::FORBIDDEN) - { - if (tryBuildNextStructure(t, std::vector(capitolRequirements, - capitolRequirements + ARRAY_COUNT(capitolRequirements)))) - return true; - } - } - //TODO: save money for capitol or city hall if capitol unavailable //do not build other things (unless gold source buildings are disabled in map editor) diff --git a/AI/VCAI/Goals.cpp b/AI/VCAI/Goals.cpp index 69936e15e..166092c3d 100644 --- a/AI/VCAI/Goals.cpp +++ b/AI/VCAI/Goals.cpp @@ -1227,10 +1227,10 @@ TSubgoal GatherTroops::whatToDoToAchieve() { dwellings.push_back(t); } - else - { + /*else //disable random building requests for now - this code needs to know a lot of town/resource context to do more good than harm + { return sptr(Goals::BuildThis(bid, t).setpriority(priority)); - } + }*/ } } for(auto obj : ai->visitableObjs) @@ -1459,7 +1459,9 @@ TGoalVec GatherArmy::getAllPossibleSubgoals() //build dwelling //TODO: plan building over multiple turns? //auto bid = ah->canBuildAnyStructure(t, std::vector(unitsSource, unitsSource + ARRAY_COUNT(unitsSource)), 8 - cb->getDate(Date::DAY_OF_WEEK)); - auto bid = ai->ah->canBuildAnyStructure(t, std::vector(unitsSource, unitsSource + ARRAY_COUNT(unitsSource)), 1); + + //Do not use below code for now, rely on generic Build. Code below needs to know a lot of town/resource context to do more good than harm + /*auto bid = ai->ah->canBuildAnyStructure(t, std::vector(unitsSource, unitsSource + ARRAY_COUNT(unitsSource)), 1); if (bid.is_initialized()) { auto goal = sptr(BuildThis(bid.get(), t).setpriority(priority)); @@ -1467,7 +1469,7 @@ TGoalVec GatherArmy::getAllPossibleSubgoals() ret.push_back(goal); else logAi->debug("Can not build a structure, because of ai->ah->containsObjective"); - } + }*/ } }