Ver código fonte

Merge pull request #1103 from Nordsoft91/autobattle-bugfix

Preventing multiple AI from being created
Andrii Danylchenko 3 anos atrás
pai
commit
c5cf0e4086
2 arquivos alterados com 8 adições e 4 exclusões
  1. 6 4
      client/battle/CBattleInterface.cpp
  2. 2 0
      client/mapHandler.cpp

+ 6 - 4
client/battle/CBattleInterface.cpp

@@ -859,17 +859,17 @@ void CBattleInterface::reallySurrender()
 
 void CBattleInterface::bAutofightf()
 {
-	if (spellDestSelectMode) //we are casting a spell
+	if(spellDestSelectMode) //we are casting a spell
 		return;
 
 	//Stop auto-fight mode
-	if (curInt->isAutoFightOn)
+	if(curInt->isAutoFightOn)
 	{
 		assert(curInt->autofightingAI);
 		curInt->isAutoFightOn = false;
 		logGlobal->trace("Stopping the autofight...");
 	}
-	else
+	else if(!curInt->autofightingAI)
 	{
 		curInt->isAutoFightOn = true;
 		blockUI(true);
@@ -1619,7 +1619,9 @@ void CBattleInterface::activateStack()
 
 	setActiveStack(stackToActivate);
 	stackToActivate = nullptr;
-	const CStack *s = activeStack;
+	const CStack * s = activeStack;
+	if(!s)
+		return;
 
 	queue->update();
 	redrawBackgroundWithHexes(activeStack);

+ 2 - 0
client/mapHandler.cpp

@@ -536,6 +536,8 @@ void CMapHandler::CMapWorldViewBlitter::drawTileOverlay(SDL_Surface * targetSurf
 	for(auto & object : objects)
 	{
 		const CGObjectInstance * obj = object.obj;
+		if(!obj)
+			continue;
 
 		const bool sameLevel = obj->pos.z == pos.z;