Index: binaries/data/mods/public/gui/session/input.js
===================================================================
--- binaries/data/mods/public/gui/session/input.js	(révision 13968)
+++ binaries/data/mods/public/gui/session/input.js	(copie de travail)
@@ -185,31 +185,9 @@
 	if (!entState)
 		return {"possible": false};
 
-	// If the selection isn't friendly units, no action
-	var playerID = Engine.GetPlayerID();
-	var allOwnedByPlayer = selection.every(function(ent) {
-		var entState = GetEntityState(ent);
-		return entState && entState.player == playerID;
-	});
-
-	if (!g_DevSettings.controlAll && !allOwnedByPlayer)
-		return {"possible": false};
-
-	// Work out whether the selection can have rally points
-	var haveRallyPoints = selection.every(function(ent) {
-		var entState = GetEntityState(ent);
-		return entState && entState.rallyPoint;
-	});
-
-	// Work out whether at least part of the selection have UnitAI
-	var haveUnitAI = selection.some(function(ent) {
-		var entState = GetEntityState(ent);
-		return entState && entState.unitAI;
-	});
-
 	if (!target)
 	{
-		if (action == "set-rallypoint" && haveRallyPoints)
+		if (action == "set-rallypoint")
 		{
 			var cursor = "";
 			var data = {command: "walk"};
@@ -220,13 +198,13 @@
 			}
 			return {"possible": true, "data": data, "cursor": cursor};
 		}
-		else if (haveUnitAI && (action == "move" || action == "attack-move"))
+		else if (action == "move" || action == "attack-move")
 			return {"possible": true};
 		else
 			return {"possible": false};
 	}
 
-	if (haveRallyPoints && selection.indexOf(target) != -1 && action == "unset-rallypoint")
+	if (action == "unset-rallypoint" && selection.indexOf(target) != -1)
 		return {"possible": true};
 
 	// Look at the first targeted entity
@@ -235,9 +213,8 @@
 	var targetState = GetEntityState(target);
 
 	// Look to see what type of command units going to the rally point should use
-	if (haveRallyPoints && action == "set-rallypoint")
+	if (action == "set-rallypoint")
 	{
-		// haveRallyPoints ensures all selected entities can have rally points.
 		// We assume that all entities are owned by the same player.
 		var entState = GetEntityState(selection[0]);
 
@@ -248,11 +225,10 @@
 		var enemyOwned = playerState.isEnemy[targetState.player];
 		var gaiaOwned = (targetState.player == 0);
 
-		var cursor = "";
 		var tooltip;
-
-		// default to walking there
+		// default to walking there (or attack-walking if hotkey pressed)
 		var data = {command: "walk"};
+		var cursor = "";
 		if (Engine.HotkeyIsPressed("session.attackmove"))
 		{
 			data = {command: "attack-walk"};
@@ -273,13 +249,9 @@
 		{
 			var resourceType = targetState.resourceSupply.type;
 			if (resourceType.generic == "treasure")
-			{
 				cursor = "action-gather-" + resourceType.generic;
-			}
 			else
-			{
 				cursor = "action-gather-" + resourceType.specific;
-			}
 			data.command = "gather";
 			data.resourceType = resourceType;
 			data.resourceTemplate = targetState.template;
@@ -414,18 +386,14 @@
 				for each (var unitClass in targetState.identity.classes)
 				{
 					if (unhealableClasses.indexOf(unitClass) != -1)
-					{
 						return {"possible": false};
-					}
 				}
 				
 				var healableClasses = entState.Healer.healableClasses;
 				for each (var unitClass in targetState.identity.classes)
 				{
 					if (healableClasses.indexOf(unitClass) != -1)
-					{
 						return {"possible": true};
-					}
 				}
 			}
 			break;
@@ -455,7 +423,7 @@
 			break;
 		}
 	}
-	if (haveUnitAI && (action == "move" || action == "attack-move"))
+	if (action == "move" || action == "attack-move")
 		return {"possible": true};
 	else
 		return {"possible": false};
@@ -490,24 +458,28 @@
 	if (!g_DevSettings.controlAll && !allOwnedByPlayer)
 		return undefined;
 
-	// Work out whether the selection can have rally points
-	var haveRallyPoints = selection.every(function(ent) {
+	// Work out whether at least part of the selection have UnitAI
+	var haveUnitAI = selection.some(function(ent) {
 		var entState = GetEntityState(ent);
+		return entState && entState.unitAI;
+	});
+
+	// Work out whether at least part the selection have rally points
+	// while none have UnitAI
+	var haveRallyPoints = !haveUnitAI && selection.some(function(ent) {
+		var entState = GetEntityState(ent);
 		return entState && entState.rallyPoint;
 	});
 
 	var targets = [];
 	var target = undefined;
-	var type = "none";
 	var cursor = "";
 	var targetState = undefined;
 	if (!fromMinimap)
 		targets = Engine.PickEntitiesAtPoint(x, y);
 
 	if (targets.length)
-	{
 		target = targets[0];
-	}
 
 	var actionInfo = undefined;
 	if (preSelectedAction != ACTION_NONE)
@@ -536,7 +508,7 @@
 	{
 		return {"type": "garrison", "cursor": "action-garrison", "tooltip": actionInfo.tooltip, "target": target};
 	}
-	else if (Engine.HotkeyIsPressed("session.attackmove") && getActionInfo("attack-move", target).possible)
+	else if (haveUnitAI && Engine.HotkeyIsPressed("session.attackmove") && getActionInfo("attack-move", target).possible)
 	{
 			return {"type": "attack-move", "cursor": "action-attack-move"};
 	}
@@ -552,18 +524,18 @@
 			return {"type": "build", "cursor": "action-build", "target": target};
 		else if (getActionInfo("repair", target).possible)
 			return {"type": "build", "cursor": "action-repair", "target": target};
-		else if ((actionInfo = getActionInfo("set-rallypoint", target)).possible)
+		else if (haveRallyPoints && (actionInfo = getActionInfo("set-rallypoint", target)).possible)
 			return {"type": "set-rallypoint", "cursor": actionInfo.cursor, "data": actionInfo.data, "tooltip": actionInfo.tooltip, "position": actionInfo.position};
 		else if (getActionInfo("heal", target).possible)
 			return {"type": "heal", "cursor": "action-heal", "target": target};
 		else if (getActionInfo("attack", target).possible)
 			return {"type": "attack", "cursor": "action-attack", "target": target};
-		else if (getActionInfo("unset-rallypoint", target).possible)
+		else if (haveRallyPoints && getActionInfo("unset-rallypoint", target).possible)
 			return {"type": "unset-rallypoint"};
-		else if (getActionInfo("move", target).possible)
+		else if (haveUnitAI && getActionInfo("move", target).possible)
 			return {"type": "move"};
 	}
-	return {"type": type, "cursor": cursor, "target": target};
+	return {"type": "none", "cursor": cursor, "target": target};
 }
 
 
@@ -577,8 +549,6 @@
 		return false;
 	}
 
-	var selection = g_Selection.toList();
-
 	// Use the preview to check it's a valid build location
 	if (!updateBuildingPlacementPreview())
 	{
@@ -587,6 +557,8 @@
 		return false;
 	}
 
+	var selection = g_Selection.toList();
+
 	// Start the construction
 	Engine.PostNetworkCommand({
 		"type": "construct",
@@ -879,8 +851,8 @@
 		case "mousebuttonup":
 			if (ev.button === SDL_BUTTON_LEFT)
 			{
-    			inputState = INPUT_BUILDING_WALL_PATHING;
-    			return true;
+				inputState = INPUT_BUILDING_WALL_PATHING;
+				return true;
 			}
 			break;
 			
@@ -1323,8 +1295,8 @@
 				else
 				{
 					placementSupport.position = Engine.GetTerrainAtScreenPoint(ev.x, ev.y);
-    				dragStart = [ ev.x, ev.y ];
-    				inputState = INPUT_BUILDING_CLICK;
+					dragStart = [ ev.x, ev.y ];
+					inputState = INPUT_BUILDING_CLICK;
 				}
 				return true;
 			}
Index: binaries/data/mods/public/gui/session/unit_commands.js
===================================================================
--- binaries/data/mods/public/gui/session/unit_commands.js	(révision 13968)
+++ binaries/data/mods/public/gui/session/unit_commands.js	(copie de travail)
@@ -1092,7 +1092,7 @@
 			var gates = [];
 			for (var i in selection)
 			{
-				state = GetEntityState(selection[i]);
+				var state = GetEntityState(selection[i]);
 				if (hasClass(state, "LongWall") && !state.gate && !longWallTypes[state.template])
 				{
 					var gateTemplate = getWallGateTemplate(state.id);
