Jelajahi Sumber

Fix possible crash on trying to move to invalid battlefield hexes

Ivan Savenko 1 tahun lalu
induk
melakukan
fe115c6917
1 mengubah file dengan 1 tambahan dan 2 penghapusan
  1. 1 2
      AI/BattleAI/BattleEvaluator.cpp

+ 1 - 2
AI/BattleAI/BattleEvaluator.cpp

@@ -291,10 +291,9 @@ BattleAction BattleEvaluator::goTowardsNearest(const CStack * stack, std::vector
 		std::vector<BattleHex> copy = targetHexes;
 
 		for(auto hex : copy)
-		{
 			vstd::concatenate(targetHexes, hex.allNeighbouringTiles());
-		}
 
+		vstd::erase_if(targetHexes, [](const BattleHex & hex) {return !hex.isValid();});
 		vstd::removeDuplicates(targetHexes);
 	}