Browse Source

Fixed crash at double attack, including #1202.

DjWarmonger 12 years ago
parent
commit
a63b30e516
1 changed files with 6 additions and 3 deletions
  1. 6 3
      server/CGameHandler.cpp

+ 6 - 3
server/CGameHandler.cpp

@@ -3462,17 +3462,20 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
 
 			for (int i = 0; i < totalAttacks; ++i)
 			{
-				if( stack &&stack->alive()) //move can cause death, eg. by walking into the moat
+				if (stack &&
+					stack->alive() && //move can cause death, eg. by walking into the moat
+					stackAtEnd->alive())
 				{
 					BattleAttack bat;
-					prepareAttack(bat, stack, stackAtEnd, distance, ba.additionalInfo);
+					prepareAttack(bat, stack, stackAtEnd, (i ? 0 : distance),  ba.additionalInfo); //no distance travelled on second attack
+					//prepareAttack(bat, stack, stackAtEnd, 0, ba.additionalInfo); 
 					handleAttackBeforeCasting(bat); //only before first attack
 					sendAndApply(&bat);
 					handleAfterAttackCasting(bat);
 				}
 
 				//counterattack
-				if(!stack->hasBonusOfType(Bonus::BLOCKS_RETALIATION)
+				if (!stack->hasBonusOfType(Bonus::BLOCKS_RETALIATION)
 					&& stackAtEnd->ableToRetaliate()
 					&& stack->alive()) //attacker may have died (fire shield)
 				{