1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Merge pull request #2664 from Nordsoft91/fix-ai-movement-freeze

This commit is contained in:
Nordsoft91
2023-08-25 00:08:40 +04:00
committed by GitHub

View File

@@ -1262,16 +1262,14 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
visitObjectOnTile(t, h);
}
if(!transit)
for(auto topQuery = queries->topQuery(h->tempOwner); true; topQuery = queries->topQuery(h->tempOwner))
{
for(auto topQuery = queries->topQuery(h->tempOwner); true; topQuery = queries->topQuery(h->tempOwner))
{
moveQuery = std::dynamic_pointer_cast<CHeroMovementQuery>(topQuery);
if(moveQuery)
queries->popIfTop(moveQuery);
else
break;
}
moveQuery = std::dynamic_pointer_cast<CHeroMovementQuery>(topQuery);
if(moveQuery
&& (!transit || result == TryMoveHero::FAILED || moveQuery->tmh.stopMovement()))
queries->popIfTop(moveQuery);
else
break;
}
logGlobal->trace("Hero %s ends movement", h->getNameTranslated());
return result != TryMoveHero::FAILED;