From 0e4be8c7768fb3fe1a7baaa0fe0a30895b65d9b3 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Wed, 19 Jun 2024 18:25:07 +0000 Subject: [PATCH] Fix crash on sieging Citadel or Castle --- AI/BattleAI/BattleExchangeVariant.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AI/BattleAI/BattleExchangeVariant.cpp b/AI/BattleAI/BattleExchangeVariant.cpp index 29ed104ea..1f83b58e8 100644 --- a/AI/BattleAI/BattleExchangeVariant.cpp +++ b/AI/BattleAI/BattleExchangeVariant.cpp @@ -621,6 +621,9 @@ BattleScore BattleExchangeEvaluator::calculateExchange( if(!exchangeBattle->getForUpdate(u->unitId())->alive()) return false; + if (!u->getPosition().isValid()) + return false; // e.g. tower shooters + return vstd::contains_if(reachabilityMap.at(u->getPosition()), [&attacker](const battle::Unit * other) -> bool { return attacker->unitId() == other->unitId();