浏览代码

Fix one more battle ai related crash.

Andrii Danylchenko 3 年之前
父节点
当前提交
c293b655f5
共有 1 个文件被更改,包括 11 次插入0 次删除
  1. 11 0
      client/CPlayerInterface.cpp

+ 11 - 0
client/CPlayerInterface.cpp

@@ -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)");