Michał W. Urbańczyk 14 年之前
父节点
当前提交
102593aabe
共有 1 个文件被更改,包括 6 次插入5 次删除
  1. 6 5
      server/CGameHandler.cpp

+ 6 - 5
server/CGameHandler.cpp

@@ -506,9 +506,10 @@ void CGameHandler::afterBattleCallback() //object interaction after leveling up
 {
 	if(battleEndCallback && *battleEndCallback)
 	{
-		(*battleEndCallback)(battleResult.data);
-		delete battleEndCallback;
-		battleEndCallback = 0;
+		boost::function<void(BattleResult*)> *backup = battleEndCallback;
+		battleEndCallback = NULL; //we need to set it to NULL or else we have infinite recursion when after battle callback gives exp (eg Pandora Box with exp)
+		(*backup)(battleResult.data);
+		delete backup;
 	}
 }
 void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CStack *def, int distance, int targetHex)
@@ -4994,8 +4995,8 @@ void CGameHandler::runBattle()
 
 			const CGHeroInstance * curOwner = gs->curB->battleGetOwner(next);
 
-			if( (next->position < 0 && (!curOwner || curOwner->getSecSkillLevel(CGHeroInstance::BALLISTICS) == 0)) //arrow turret, hero has no ballistics
-				|| (next->getCreature()->idNumber == 146 && (!curOwner || curOwner->getSecSkillLevel(CGHeroInstance::ARTILLERY) == 0))) //ballista, hero has no artillery
+			if( (next->position < 0 || next->getCreature()->idNumber == 146)	//arrow turret or ballista
+				&& (!curOwner || curOwner->getSecSkillLevel(CGHeroInstance::ARTILLERY) == 0)) //hero has no artillery
 			{
 				BattleAction attack;
 				attack.actionType = BattleAction::SHOOT;