From 280ca0c7b507f5aa4492f0731cbf9ce156a8b4cf Mon Sep 17 00:00:00 2001
From: cybermind <iddqd_mail@mail.ru>
Date: Mon, 20 Feb 2012 19:07:04 +0600
Subject: [PATCH] [-]Fixed some bugs -typo in CommandAttackGround
 -Preferences.ShowMessages now true by default -towers now clear their action
 when unit is out of range

---
 src/action/action_attack.cpp | 5 ++++-
 src/action/command.cpp       | 2 +-
 src/include/unit.h           | 2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/action/action_attack.cpp b/src/action/action_attack.cpp
index 8dfbd3d65..15178795c 100644
--- a/src/action/action_attack.cpp
+++ b/src/action/action_attack.cpp
@@ -445,7 +445,10 @@ void HandleActionAttack(COrder& order, CUnit &unit)
 		case MOVE_TO_TARGET:
 		case MOVE_TO_TARGET + WEAK_TARGET:
 			if (!unit.CanMove()) {
-				unit.RestoreOrder();
+				if (!unit.RestoreOrder()) {
+					unit.ClearAction();
+					unit.State = 0;
+				}
 				return;
 			}
 			MoveToTarget(unit);
diff --git a/src/action/command.cpp b/src/action/command.cpp
index 378f7599c..2e8681b4e 100644
--- a/src/action/command.cpp
+++ b/src/action/command.cpp
@@ -337,7 +337,7 @@ void CommandAttackGround(CUnit &unit, const Vec2i &pos, int flush)
 	}
 	COrderPtr *order;
 
-	if (unit.Type->CanAttack) {
+	if (!unit.Type->CanAttack) {
 		ClearNewAction(unit);
 		order = &unit.NewOrder;
 	} else {
diff --git a/src/include/unit.h b/src/include/unit.h
index f8e6360b6..fe9179b8c 100644
--- a/src/include/unit.h
+++ b/src/include/unit.h
@@ -953,7 +953,7 @@ struct CResourceDepositFinder {
 class CPreference {
 public:
 	CPreference() : ShowSightRange(false), ShowReactionRange(false),
-		ShowAttackRange(false), ShowMessages(false),
+		ShowAttackRange(false), ShowMessages(true),
 		BigScreen(false),ShowOrders(0) {};
 
 	bool ShowSightRange;     /// Show sight range.