From 1c522c49b671ec02a25650c62dfca8831cc2f7fb Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sat, 20 Jul 2024 18:28:13 +0000 Subject: [PATCH] Fix possible crash on trying to move to invalid battlefield hexes --- AI/BattleAI/BattleEvaluator.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/AI/BattleAI/BattleEvaluator.cpp b/AI/BattleAI/BattleEvaluator.cpp index 98d1bf3e6..3fccb5e8c 100644 --- a/AI/BattleAI/BattleEvaluator.cpp +++ b/AI/BattleAI/BattleEvaluator.cpp @@ -291,10 +291,9 @@ BattleAction BattleEvaluator::goTowardsNearest(const CStack * stack, std::vector std::vector copy = targetHexes; for(auto hex : copy) - { vstd::concatenate(targetHexes, hex.allNeighbouringTiles()); - } + vstd::erase_if(targetHexes, [](const BattleHex & hex) {return !hex.isValid();}); vstd::removeDuplicates(targetHexes); }