1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-31 22:05:10 +02:00

#4139 - attempt to fix crash on portal probbing

This commit is contained in:
Andrii Danylchenko 2024-06-16 11:58:15 +03:00
parent cd12b0e514
commit cd4aaf93ee

View File

@ -1331,7 +1331,11 @@ bool AIGateway::moveHeroToTile(int3 dst, HeroPtr h)
auto doChannelProbing = [&]() -> void auto doChannelProbing = [&]() -> void
{ {
auto currentPos = h->visitablePos(); auto currentPos = h->visitablePos();
auto currentExit = getObj(currentPos, true)->id; auto currentTeleport = getObj(currentPos, true);
if(currentTeleport)
{
auto currentExit = currentTeleport->id;
status.setChannelProbing(true); status.setChannelProbing(true);
for(auto exit : teleportChannelProbingList) for(auto exit : teleportChannelProbingList)
@ -1340,8 +1344,19 @@ bool AIGateway::moveHeroToTile(int3 dst, HeroPtr h)
status.setChannelProbing(false); status.setChannelProbing(false);
doTeleportMovement(currentExit, currentPos); doTeleportMovement(currentExit, currentPos);
}
else
{
logAi->debug("Unexpected channel probbing at " + currentPos.toString());
teleportChannelProbingList.clear();
status.setChannelProbing(false);
}
}; };
teleportChannelProbingList.clear();
status.setChannelProbing(false);
for(; i > 0; i--) for(; i > 0; i--)
{ {
int3 currentCoord = path.nodes[i].coord; int3 currentCoord = path.nodes[i].coord;