1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Fixed AI detection of battle end (solves some freezes).

This commit is contained in:
Michał W. Urbańczyk
2013-09-29 20:54:29 +00:00
parent 9ee3133077
commit 5c6d12400f
4 changed files with 30 additions and 15 deletions

View File

@@ -1555,21 +1555,9 @@ void CGameHandler::setupBattle( int3 tile, const CArmedInstance *armies[2], cons
void CGameHandler::checkForBattleEnd()
{
auto &stacks = gs->curB->stacks;
//checking winning condition
bool hasStack[2]; //hasStack[0] - true if attacker has a living stack; defender similarly
hasStack[0] = hasStack[1] = false;
for(auto & stack : stacks)
if(auto result = battleIsFinished())
{
if(stack->alive() && !stack->hasBonusOfType(Bonus::SIEGE_WEAPON))
{
hasStack[1-stack->attackerOwned] = true;
}
}
if(!hasStack[0] || !hasStack[1]) //somebody has won
{
setBattleResult(BattleResult::NORMAL, hasStack[1]);
setBattleResult(BattleResult::NORMAL, *result);
}
}