From 6456c57755e257984e8fc599eb3a39a8e44414a7 Mon Sep 17 00:00:00 2001
From: Joris <joris.dauphin@gmail.com>
Date: Fri, 11 May 2012 14:00:32 +0200
Subject: [PATCH] Fix warning about mixing && and || by rewriting the code.

---
 src/ai/ai_force.cpp | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/ai/ai_force.cpp b/src/ai/ai_force.cpp
index 5331c68ad..765f0e42e 100644
--- a/src/ai/ai_force.cpp
+++ b/src/ai/ai_force.cpp
@@ -267,20 +267,21 @@ void AiForce::RemoveDeadUnit()
 
 void AiForce::Attack(const Vec2i &pos)
 {
-	Vec2i goalPos(pos);
 	RemoveDeadUnit();
 
-	// Remember the original force position so we can return there after attack
-	if (this->Size() > 0 && (this->Role == AiForceRoleDefend && !this->Attacking)
-		|| (this->Role == AiForceRoleAttack && !this->Attacking && !this->State)) {
-		this->HomePos = this->Units[0]->tilePos;
-	}
-
-	Attacking = false;
 	if (Units.size() == 0) {
+		this->Attacking = false;
 		return;
 	}
-	Attacking = true;
+	if (!this->Attacking) {
+		// Remember the original force position so we can return there after attack
+		if (this->Role == AiForceRoleDefend
+			|| (this->Role == AiForceRoleAttack && this->State == AiForceAttackingState_Waiting)) {
+			this->HomePos = this->Units[0]->tilePos;
+		}
+		this->Attacking = true;
+	}
+	Vec2i goalPos(pos);
 
 	if (Map.Info.IsPointOnMap(goalPos) == false) {
 		/* Search in entire map */