mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Some checks and log for CollectRes goal.
This commit is contained in:
@@ -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;
|
||||
|
@@ -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>
|
||||
|
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user