From 596b98e1c13b32d1fb35731a31e981dd1a31e310 Mon Sep 17 00:00:00 2001 From: nordsoft Date: Thu, 24 Aug 2023 16:42:47 +0400 Subject: [PATCH] Fix AI freeze regression --- server/CGameHandler.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 152ef5480..c1f6093c7 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -1268,16 +1268,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(topQuery); - if(moveQuery) - queries->popIfTop(moveQuery); - else - break; - } + moveQuery = std::dynamic_pointer_cast(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;