1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

* fixed 592

This commit is contained in:
mateuszb
2010-08-02 10:59:47 +00:00
parent ac54784e55
commit 4fb50260c3

View File

@@ -521,8 +521,10 @@ void CGameHandler::startBattle(const CArmedInstance *army1, const CArmedInstance
continue;
}
askInterfaceForMove:
//ask interface and wait for answer
int numberOfAsks = 1;
bool breakOuter = false;
do
{//ask interface and wait for answer
if(!battleResult.get())
{
BattleSetActiveStack sas;
@@ -533,8 +535,10 @@ askInterfaceForMove:
battleMadeAction.cond.wait(lock);
battleMadeAction.data = false;
}
else
if(battleResult.get()) //don't touch it, battle could be finished while waiting got action
{
breakOuter = true;
break;
}
@@ -550,8 +554,19 @@ askInterfaceForMove:
&& nextStackMorale > 0
&& !(NBonus::hasOfType(hero1, Bonus::BLOCK_MORALE) || NBonus::hasOfType(hero2, Bonus::BLOCK_MORALE)) //checking if heroes have (or don't have) morale blocking bonuses
)
{
if(rand()%24 < nextStackMorale) //this stack hasn't got morale this turn
goto askInterfaceForMove; //move this stack once more
++numberOfAsks; //move this stack once more
}
--numberOfAsks;
} while (numberOfAsks > 0);
if (breakOuter)
{
break;
}
}
}
@@ -4245,7 +4260,9 @@ bool CGameHandler::makeCustomAction( BattleAction &ba )
checkForBattleEnd(gs->curB->stacks);
if(battleResult.get())
{
endBattle(gs->curB->tile, gs->curB->heroes[0], gs->curB->heroes[1]);
battleMadeAction.setn(true);
//battle will be ended by startBattle function
//endBattle(gs->curB->tile, gs->curB->heroes[0], gs->curB->heroes[1]);
}
return true;