From f36a86412e2dfc76af8dd16dc71bb9c29bb10885 Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Sun, 24 Feb 2019 18:45:53 +0300 Subject: [PATCH] Quick fix for https://bugs.vcmi.eu/view.php?id=3041 --- AI/VCAI/Goals/AdventureSpellCast.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AI/VCAI/Goals/AdventureSpellCast.cpp b/AI/VCAI/Goals/AdventureSpellCast.cpp index befec250d..0db0cca4c 100644 --- a/AI/VCAI/Goals/AdventureSpellCast.cpp +++ b/AI/VCAI/Goals/AdventureSpellCast.cpp @@ -44,6 +44,9 @@ TSubgoal AdventureSpellCast::whatToDoToAchieve() if(hero->mana < hero->getSpellCost(spell)) throw cannotFulfillGoalException("Hero has not enough mana to cast " + spell->name); + if(spellID == SpellID::TOWN_PORTAL && town && town->visitingHero) + throw cannotFulfillGoalException("The town is already occupied by " + town->visitingHero->name); + return iAmElementar(); }