Browse Source

Nullkiller: fix a few crashes

Andrii Danylchenko 4 năm trước cách đây
mục cha
commit
4c01a8eec4
1 tập tin đã thay đổi với 6 bổ sung0 xóa
  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);
 	}