2
0
Эх сурвалжийг харах

Fix one more battle ai related crash.

Andrii Danylchenko 3 жил өмнө
parent
commit
c293b655f5

+ 11 - 0
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)");