Browse Source

Nullkiller: fix a few crashes

Andrii Danylchenko 4 years ago
parent
commit
4c01a8eec4
1 changed files with 6 additions and 0 deletions
  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
 	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);
 		ai->recruitCreatures(hero->visitedTown, hero);
 	}
 	}