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