diff --git a/AI/Nullkiller/Engine/Nullkiller.cpp b/AI/Nullkiller/Engine/Nullkiller.cpp index aaa3a3e66..c803cc7d3 100644 --- a/AI/Nullkiller/Engine/Nullkiller.cpp +++ b/AI/Nullkiller/Engine/Nullkiller.cpp @@ -645,7 +645,7 @@ bool Nullkiller::handleTrading() ObjectInstanceID marketId; for (auto town : cb->getTownsInfo()) { - if (town->hasBuiltSomeTradeBuilding()) + if (town->hasBuiltResourceMarketplace()) { marketId = town->id; } diff --git a/AI/Nullkiller/Engine/PriorityEvaluator.cpp b/AI/Nullkiller/Engine/PriorityEvaluator.cpp index 7c52cc31d..68e7e59b8 100644 --- a/AI/Nullkiller/Engine/PriorityEvaluator.cpp +++ b/AI/Nullkiller/Engine/PriorityEvaluator.cpp @@ -1578,7 +1578,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier) logAi->trace("Should make sure to build market-place instead of %s", task->toString()); for (auto town : ai->cb->getTownsInfo()) { - if (!town->hasBuiltSomeTradeBuilding()) + if (!town->hasBuiltResourceMarketplace()) return 0; } } diff --git a/AI/Nullkiller2/Engine/Nullkiller.cpp b/AI/Nullkiller2/Engine/Nullkiller.cpp index fd2211e2c..eb0b1a1e8 100644 --- a/AI/Nullkiller2/Engine/Nullkiller.cpp +++ b/AI/Nullkiller2/Engine/Nullkiller.cpp @@ -250,9 +250,7 @@ void Nullkiller::invalidatePathfinderData() void Nullkiller::updateState() { -#if NK2AI_TRACE_LEVEL >= 1 logAi->info("PERFORMANCE: AI updateState started"); -#endif makingTurnInterruption.interruptionPoint(); std::unique_lock lockGuard(aiStateMutex); @@ -309,8 +307,7 @@ void Nullkiller::updateState() armyManager->update(); -#if NK2AI_TRACE_LEVEL >= 1 - if(const auto timeElapsedMs = timeElapsed(start); timeElapsedMs > 499) + if(const auto timeElapsedMs = timeElapsed(start); timeElapsedMs > 999) { logAi->warn("PERFORMANCE: AI updateState took %ld ms", timeElapsedMs); } @@ -318,7 +315,6 @@ void Nullkiller::updateState() { logAi->info("PERFORMANCE: AI updateState took %ld ms", timeElapsedMs); } -#endif } bool Nullkiller::isHeroLocked(const CGHeroInstance * hero) const @@ -382,14 +378,10 @@ void Nullkiller::makeTurn() decompose(tasks, sptr(ExplorationBehavior()), MAX_DEPTH); TTaskVec selectedTasks; -#if NK2AI_TRACE_LEVEL >= 1 int prioOfTask = 0; -#endif for (int prio = PriorityEvaluator::PriorityTier::INSTAKILL; prio <= PriorityEvaluator::PriorityTier::MAX_PRIORITY_TIER; ++prio) { -#if NK2AI_TRACE_LEVEL >= 1 prioOfTask = prio; -#endif selectedTasks = buildPlan(tasks, prio); if (!selectedTasks.empty() || settings->isUseFuzzy()) break; diff --git a/AI/Nullkiller2/Engine/PriorityEvaluator.cpp b/AI/Nullkiller2/Engine/PriorityEvaluator.cpp index ede609d77..6c36ed2c8 100644 --- a/AI/Nullkiller2/Engine/PriorityEvaluator.cpp +++ b/AI/Nullkiller2/Engine/PriorityEvaluator.cpp @@ -1628,7 +1628,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier) logAi->trace("Should make sure to build market-place instead of %s", task->toString()); for (auto town : aiNk->cc->getTownsInfo()) { - if (!town->hasBuiltSomeTradeBuilding()) + if (!town->hasBuiltResourceMarketplace()) return 0; } } diff --git a/AI/Nullkiller2/Engine/ResourceTrader.cpp b/AI/Nullkiller2/Engine/ResourceTrader.cpp index e51ab39d6..f186fcd60 100644 --- a/AI/Nullkiller2/Engine/ResourceTrader.cpp +++ b/AI/Nullkiller2/Engine/ResourceTrader.cpp @@ -20,7 +20,7 @@ bool ResourceTrader::trade(BuildAnalyzer & buildAnalyzer, CCallback & cc, const // Are those used anywhere? To inspect. for(const auto * const town : cc.getTownsInfo()) { - if(town->hasBuiltSomeTradeBuilding()) + if(town->hasBuiltResourceMarketplace()) { marketId = town->id; break; diff --git a/lib/mapObjects/CGTownInstance.cpp b/lib/mapObjects/CGTownInstance.cpp index c40242755..0543586a8 100644 --- a/lib/mapObjects/CGTownInstance.cpp +++ b/lib/mapObjects/CGTownInstance.cpp @@ -651,7 +651,7 @@ BoatId CGTownInstance::getBoatType() const int CGTownInstance::getMarketEfficiency() const { - if(!hasBuiltSomeTradeBuilding()) + if(!hasBuiltResourceMarketplace()) return 0; const PlayerState *p = cb->getPlayerState(tempOwner); @@ -659,7 +659,7 @@ int CGTownInstance::getMarketEfficiency() const int marketCount = 0; for(const CGTownInstance *t : p->getTowns()) - if(t->hasBuiltSomeTradeBuilding()) + if(t->hasBuiltResourceMarketplace()) marketCount++; return marketCount; @@ -885,9 +885,10 @@ const CArmedInstance * CGTownInstance::getUpperArmy() const return this; } -bool CGTownInstance::hasBuiltSomeTradeBuilding() const +bool CGTownInstance::hasBuiltResourceMarketplace() const { - return availableModes().empty() ? false : true; + const auto modes = availableModes(); + return std::find(modes.begin(), modes.end(), EMarketMode::RESOURCE_RESOURCE) != modes.end(); } bool CGTownInstance::hasBuilt(BuildingSubID::EBuildingSubID buildingID) const diff --git a/lib/mapObjects/CGTownInstance.h b/lib/mapObjects/CGTownInstance.h index b286a762b..98a9b1252 100644 --- a/lib/mapObjects/CGTownInstance.h +++ b/lib/mapObjects/CGTownInstance.h @@ -160,7 +160,7 @@ public: GrowthInfo getGrowthInfo(int level) const; bool hasFort() const; bool hasCapitol() const; - bool hasBuiltSomeTradeBuilding() const; + bool hasBuiltResourceMarketplace() const; //checks if special building with type buildingID is constructed bool hasBuilt(BuildingSubID::EBuildingSubID buildingID) const; //checks if building is constructed and town has same subID