1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Merge pull request #4539 from IvanSavenko/crashfix

Crashfixes
This commit is contained in:
Ivan Savenko 2024-08-30 17:19:24 +03:00 committed by GitHub
commit 727cd2e9e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View File

@ -376,11 +376,14 @@ MoveTarget BattleExchangeEvaluator::findMoveTowardsUnreachable(
logAi->trace("New high score");
#endif
for(BattleHex enemyHex : enemy->getAttackableHexes(activeStack))
for(const BattleHex & initialEnemyHex : enemy->getAttackableHexes(activeStack))
{
while(!flying && dists.distances[enemyHex] > speed)
BattleHex enemyHex = initialEnemyHex;
while(!flying && dists.distances[enemyHex] > speed && dists.predecessors.at(enemyHex).isValid())
{
enemyHex = dists.predecessors.at(enemyHex);
if(dists.accessibility[enemyHex] == EAccessibility::ALIVE_STACK)
{
auto defenderToBypass = hb->battleGetUnitByPos(enemyHex);

View File

@ -104,7 +104,7 @@ public:
bool checkVanquished() const
{
return ownedObjects.empty();
return getHeroes().empty() && getTowns().empty();
}
template <typename Handler> void serialize(Handler &h)