Sfoglia il codice sorgente

Nullkiller: fix a few crashes

Andrii Danylchenko 4 anni fa
parent
commit
4c01a8eec4
1 ha cambiato i file con 6 aggiunte e 0 eliminazioni
  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);
 	}