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

Fix one more battle ai related crash.

This commit is contained in:
Andrii Danylchenko 2022-05-15 12:59:56 +03:00 committed by Andrii Danylchenko
parent c6b198ce14
commit c293b655f5

View File

@ -852,6 +852,12 @@ BattleAction CPlayerInterface::activeStack(const CStack * stack) //called when i
if (isAutoFightOn) if (isAutoFightOn)
{ {
auto ret = autofightingAI->activeStack(stack); auto ret = autofightingAI->activeStack(stack);
if(cb->battleIsFinished())
{
return BattleAction::makeDefend(stack); // battle finished with spellcast
}
if (isAutoFightOn) if (isAutoFightOn)
{ {
return ret; return ret;
@ -864,6 +870,11 @@ BattleAction CPlayerInterface::activeStack(const CStack * stack) //called when i
CBattleInterface *b = battleInt; CBattleInterface *b = battleInt;
if(!b)
{
return BattleAction::makeDefend(stack); // probably battle is finished already
}
if(CBattleInterface::givenCommand.get()) if(CBattleInterface::givenCommand.get())
{ {
logGlobal->error("Command buffer must be clean! (we don't want to use old command)"); logGlobal->error("Command buffer must be clean! (we don't want to use old command)");