DjWarmonger 9 년 전
부모
커밋
eaf14f6429
1개의 변경된 파일10개의 추가작업 그리고 6개의 파일을 삭제
  1. 10 6
      AI/VCAI/Goals.cpp

+ 10 - 6
AI/VCAI/Goals.cpp

@@ -926,13 +926,17 @@ TSubgoal GatherTroops::whatToDoToAchieve()
 		{
 			nearestDwellings[hero] = *boost::range::min_element(dwellings, CDistanceSorter(hero));
 		}
+		if (nearestDwellings.size())
+		{
+			// find hero who is nearest to a dwelling
+			const CGDwelling * nearest = boost::range::min_element(nearestDwellings, comparator)->second;
+			if (!nearest)
+				throw cannotFulfillGoalException("Cannot find nearest dwelling!");
 
-		// find hero who is nearest to a dwelling
-		const CGDwelling * nearest = boost::range::min_element(nearestDwellings, comparator)->second;
-		if(nearest) // FIXME: Find out what regression / bug cause this. Issue 2624
-			throw cannotFulfillGoalException("Cannot find nearest dwelling!");
-
-		return sptr (Goals::GetObj(nearest->id.getNum()));
+			return sptr(Goals::GetObj(nearest->id.getNum()));
+		}
+		else
+			return sptr(Goals::Explore());
 	}
 	else
 		return sptr (Goals::Explore());