2
0
Эх сурвалжийг харах

Some checks and log for CollectRes goal.

DJWarmonger 7 жил өмнө
parent
commit
a5ca32ad38
3 өөрчлөгдсөн 14 нэмэгдсэн , 2 устгасан
  1. 12 1
      AI/VCAI/Goals.cpp
  2. 1 0
      AI/VCAI/Goals.h
  3. 1 1
      AI/VCAI/VCAI.cpp

+ 12 - 1
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<const CGDwelling *> dwellings;

+ 1 - 0
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<GatherTroops>

+ 1 - 1
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)
 			{