From 8c763253d2aa21f41b6367e021e8c4dc6a38a805 Mon Sep 17 00:00:00 2001 From: Dydzio Date: Tue, 9 Oct 2018 23:52:51 +0200 Subject: [PATCH] Build fort unconditionally with high priority, no fort=no dwellings --- AI/VCAI/BuildingManager.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/AI/VCAI/BuildingManager.cpp b/AI/VCAI/BuildingManager.cpp index 28584f0d2..9b95ab2e1 100644 --- a/AI/VCAI/BuildingManager.cpp +++ b/AI/VCAI/BuildingManager.cpp @@ -169,11 +169,15 @@ bool BuildingManager::getBuildingOptions(const CGTownInstance * t) if (tryBuildAnyStructure(t, std::vector(essential, essential + ARRAY_COUNT(essential)))) return true; - //the more gold the better and less problems later + //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; - //workaround for mantis #2696 - build fort and citadel - building castle will be handled without bug + if(!t->hasBuilt(BuildingID::FORT)) //in vast majority of situations fort is top priority building if we already have city hall, TODO: unite with unitGrowth building chain + 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) { @@ -195,8 +199,8 @@ bool BuildingManager::getBuildingOptions(const CGTownInstance * t) return true; } - // first in-game week or second half of any week: try build dwellings - if (cb->getDate(Date::DAY) < 7 || cb->getDate(Date::DAY_OF_WEEK) > 3) + // first in-game week or second half of any week: try build dwellings //TODO: this condition looks not optimal, rethink + if (t->hasBuilt(BuildingID::FORT) && (cb->getDate(Date::DAY) < 7 || cb->getDate(Date::DAY_OF_WEEK) > 3)) { if (tryBuildAnyStructure(t, std::vector(unitsSource, unitsSource + ARRAY_COUNT(unitsSource)), 8 - cb->getDate(Date::DAY_OF_WEEK)))