From 4c01a8eec4836e41b2245545be49f7b02a758cb8 Mon Sep 17 00:00:00 2001 From: Andrii Danylchenko Date: Sun, 16 May 2021 15:00:37 +0300 Subject: [PATCH] Nullkiller: fix a few crashes --- AI/Nullkiller/Pathfinding/Actions/BuyArmyAction.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/AI/Nullkiller/Pathfinding/Actions/BuyArmyAction.cpp b/AI/Nullkiller/Pathfinding/Actions/BuyArmyAction.cpp index 2e9ae12e4..48ddf0277 100644 --- a/AI/Nullkiller/Pathfinding/Actions/BuyArmyAction.cpp +++ b/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); }