浏览代码

Nullkiller: fix a few crashes

Andrii Danylchenko 4 年之前
父节点
当前提交
4c01a8eec4
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      AI/Nullkiller/Pathfinding/Actions/BuyArmyAction.cpp

+ 6 - 0
AI/Nullkiller/Pathfinding/Actions/BuyArmyAction.cpp

@@ -21,6 +21,12 @@ namespace AIPathfinding
 {
 	void BuyArmyAction::execute(const CGHeroInstance * hero) const
 	{
+		if(!hero->visitedTown)
+		{
+			throw cannotFulfillGoalException(
+				hero->name + " being at " + hero->visitablePos().toString() + " has no town to recruit creatures.");
+		}
+
 		ai->recruitCreatures(hero->visitedTown, hero);
 	}