瀏覽代碼

Fix AI hero infinite move on the same tile

Vadim Markovtsev 9 年之前
父節點
當前提交
2bfc8ec8cb
共有 1 個文件被更改,包括 5 次插入4 次删除
  1. 5 4
      AI/VCAI/VCAI.cpp

+ 5 - 4
AI/VCAI/VCAI.cpp

@@ -1987,7 +1987,6 @@ bool VCAI::moveHeroToTile(int3 dst, HeroPtr h)
 			if(teleportChannelProbingList.size())
 			if(teleportChannelProbingList.size())
 				doChannelProbing();
 				doChannelProbing();
 		}
 		}
-		ret = !i;
 	}
 	}
 	if (h)
 	if (h)
 	{
 	{
@@ -2002,6 +2001,8 @@ bool VCAI::moveHeroToTile(int3 dst, HeroPtr h)
 		completeGoal (sptr(Goals::VisitTile(dst).sethero(h))); //we stepped on some tile, anyway
 		completeGoal (sptr(Goals::VisitTile(dst).sethero(h))); //we stepped on some tile, anyway
 		completeGoal (sptr(Goals::ClearWayTo(dst).sethero(h)));
 		completeGoal (sptr(Goals::ClearWayTo(dst).sethero(h)));
 
 
+		ret = (dst == h->visitablePos());
+
 		if(!ret) //reserve object we are heading towards
 		if(!ret) //reserve object we are heading towards
 		{
 		{
 			auto obj = vstd::frontOrNull(cb->getVisitableObjs(dst));
 			auto obj = vstd::frontOrNull(cb->getVisitableObjs(dst));
@@ -2020,7 +2021,7 @@ bool VCAI::moveHeroToTile(int3 dst, HeroPtr h)
 }
 }
 void VCAI::tryRealize(Goals::Explore & g)
 void VCAI::tryRealize(Goals::Explore & g)
 {
 {
-	throw cannotFulfillGoalException("EXPLORE is not a elementar goal!");
+	throw cannotFulfillGoalException("EXPLORE is not an elementar goal!");
 }
 }
 
 
 void VCAI::tryRealize(Goals::RecruitHero & g)
 void VCAI::tryRealize(Goals::RecruitHero & g)
@@ -2853,7 +2854,7 @@ BattleState AIStatus::getBattle()
 }
 }
 
 
 void AIStatus::addQuery(QueryID ID, std::string description)
 void AIStatus::addQuery(QueryID ID, std::string description)
-{	
+{
 	if(ID == QueryID(-1))
 	if(ID == QueryID(-1))
 	{
 	{
         logAi->debugStream() << boost::format("The \"query\" has an id %d, it'll be ignored as non-query. Description: %s") % ID % description;
         logAi->debugStream() << boost::format("The \"query\" has an id %d, it'll be ignored as non-query. Description: %s") % ID % description;
@@ -2878,7 +2879,7 @@ void AIStatus::removeQuery(QueryID ID)
 
 
 	std::string description = remainingQueries[ID];
 	std::string description = remainingQueries[ID];
 	remainingQueries.erase(ID);
 	remainingQueries.erase(ID);
-	
+
 	cv.notify_all();
 	cv.notify_all();
     logAi->debugStream() << boost::format("Removing query %d - %s. Total queries count: %d") % ID % description % remainingQueries.size();
     logAi->debugStream() << boost::format("Removing query %d - %s. Total queries count: %d") % ID % description % remainingQueries.size();
 }
 }