From e93273afae4026271cda6c282dff2e1d9a8e63b3 Mon Sep 17 00:00:00 2001
From: johns <>
Date: Sun, 31 Mar 2002 14:07:58 +0000
Subject: [PATCH] Fixed bug #537142: Crashes with flame shield attacking
 buildings.

---
 src/unit/unit.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/unit/unit.cpp b/src/unit/unit.cpp
index b6a58744d..20188ecc5 100644
--- a/src/unit/unit.cpp
+++ b/src/unit/unit.cpp
@@ -3078,9 +3078,10 @@ global void HitUnit(Unit* attacker,Unit* target,int damage)
     // david: capture enemy buildings
     // Only worker types can capture.
     // Still possible to destroy building if not careful (too many attackers)
-    if( EnableBuildingCapture && type->Building && target->HP<=damage*3 &&
+    if( EnableBuildingCapture && attack
+	    && type->Building && target->HP<=damage*3 &&
 	    (attacker->Type==UnitTypeOrcWorker
-	    || attacker->Type==UnitTypeHumanWorker) ) {
+		|| attacker->Type==UnitTypeHumanWorker) ) {
 	ChangeUnitOwner(target, target->Player, attacker->Player);
 	CommandStopUnit(attacker);	// Attacker shouldn't continue attack!
     }