From ea46be03f3fcbe653433506db13bb73ccc30db31 Mon Sep 17 00:00:00 2001 From: ArseniyShestakov Date: Sun, 22 Feb 2015 20:56:50 +0300 Subject: [PATCH] AI: check if hero killed while visiting object he stayed on This is need to avoid crashes like one happen in 2084, but then game bahaviour incorrect. I'm not exactly sure if this possible currently, but I can imaging this would happen if hero decide to attack bank while staying on it. --- AI/VCAI/VCAI.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index 5e1264cf8..4148bb96a 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -1652,6 +1652,11 @@ bool VCAI::moveHeroToTile(int3 dst, HeroPtr h) assert(cb->getVisitableObjs(dst).size() > 1); //there's no point in revisiting tile where there is no visitable object cb->moveHero(*h, CGHeroInstance::convertPosition(dst, true)); waitTillFree(); //movement may cause battle or blocking dialog + if(!h) // TODO is it feasible to hero get killed there if game work properly? + { // not sure if AI can currently reconsider to attack bank while staying on it. Check issue 2084 on mantis for more information. + lostHero(h); + throw std::runtime_error("Hero was lost!"); + } ret = true; } else