1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Added workaround for no longer accessible hero in MoveHero

This commit is contained in:
Ivan Savenko 2022-12-25 16:12:26 +02:00
parent 94597e7af6
commit 370e92a90a
2 changed files with 15 additions and 12 deletions

View File

@ -92,8 +92,9 @@ void AIGateway::heroMoved(const TryMoveHero & details, bool verbose)
validateObject(details.id); //enemy hero may have left visible area
auto hero = cb->getHero(details.id);
const int3 from = hero->convertToVisitablePos(details.start);
const int3 to = hero->convertToVisitablePos(details.end);
const int3 from = hero ? hero->convertToVisitablePos(details.start) : (details.start - int3(0,1,0));;
const int3 to = hero ? hero->convertToVisitablePos(details.end) : (details.end - int3(0,1,0));
const CGObjectInstance * o1 = vstd::frontOrNull(cb->getVisitableObjs(from, verbose));
const CGObjectInstance * o2 = vstd::frontOrNull(cb->getVisitableObjs(to, verbose));

View File

@ -98,11 +98,13 @@ void VCAI::heroMoved(const TryMoveHero & details, bool verbose)
LOG_TRACE(logAi);
NET_EVENT_HANDLER;
validateObject(details.id); //enemy hero may have left visible area
//enemy hero may have left visible area
validateObject(details.id);
auto hero = cb->getHero(details.id);
const int3 from = hero->convertToVisitablePos(details.start);
const int3 to = hero->convertToVisitablePos(details.end);
const int3 from = hero ? hero->convertToVisitablePos(details.start) : (details.start - int3(0,1,0));;
const int3 to = hero ? hero->convertToVisitablePos(details.end) : (details.end - int3(0,1,0));
const CGObjectInstance * o1 = vstd::frontOrNull(cb->getVisitableObjs(from, verbose));
const CGObjectInstance * o2 = vstd::frontOrNull(cb->getVisitableObjs(to, verbose));