From a5ca32ad385d1b833a6613f313f48357df9c4cc1 Mon Sep 17 00:00:00 2001 From: DJWarmonger Date: Sat, 4 Aug 2018 09:24:43 +0200 Subject: [PATCH] Some checks and log for CollectRes goal. --- AI/VCAI/Goals.cpp | 13 ++++++++++++- AI/VCAI/Goals.h | 1 + AI/VCAI/VCAI.cpp | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/AI/VCAI/Goals.cpp b/AI/VCAI/Goals.cpp index 1ba807338..f310edd0c 100644 --- a/AI/VCAI/Goals.cpp +++ b/AI/VCAI/Goals.cpp @@ -1079,7 +1079,7 @@ TSubgoal Goals::CollectRes::whatToDoToTrade() } else //either it's our town, or we have hero there { - return sptr(setobjid(objid).setisElementar(true)); + return sptr(setobjid(objid).setisElementar(true).setpriority(10)); //we can do this immediately - highest priority } } } @@ -1097,6 +1097,17 @@ bool CollectRes::fulfillsMe(TSubgoal goal) return false; } +bool Goals::CollectRes::operator==(CollectRes & g) +{ + if (isElementar != g.isElementar) //elementar means ready to trade on Marketplace / Trading Post + return false; + if (g.resID == resID) + if (g.value == value) //TODO: not sure if that logic is consitent + return true; + + return false; +} + TSubgoal GatherTroops::whatToDoToAchieve() { std::vector dwellings; diff --git a/AI/VCAI/Goals.h b/AI/VCAI/Goals.h index 96dfb1f5b..130afd6ee 100644 --- a/AI/VCAI/Goals.h +++ b/AI/VCAI/Goals.h @@ -415,6 +415,7 @@ public: TSubgoal whatToDoToAchieve() override; TSubgoal whatToDoToTrade(); bool fulfillsMe(TSubgoal goal) override; + bool operator==(CollectRes & g); }; class DLL_EXPORT GatherTroops : public CGoal diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index a09d218de..3f5aa12a5 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -2393,7 +2393,7 @@ Goals::TSubgoal VCAI::striveToGoalInternal(Goals::TSubgoal ultimateGoal, bool on goal = goal->whatToDoToAchieve(); --maxGoals; if(goal == ultimateGoal) //compare objects by value - throw cannotFulfillGoalException("Goal dependency loop detected!"); + throw cannotFulfillGoalException((boost::format("Goal dependency loop detected for %s!") % ultimateGoal->name()).str()); } catch(goalFulfilledException & e) {