1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +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
commit db542d2710
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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;