Index: binaries/data/mods/public/simulation/components/GuiInterface.js
===================================================================
--- binaries/data/mods/public/simulation/components/GuiInterface.js	(revision 18527)
+++ binaries/data/mods/public/simulation/components/GuiInterface.js	(working copy)
@@ -727,7 +727,7 @@
 	notification.id = ++this.timeNotificationID;
 
 	// Let all players and observers receive the notification by default
-	if (notification.players == undefined)
+	if (notification.players === undefined)
 	{
 		let cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
 		let numPlayers = cmpPlayerManager.GetNumPlayers();
@@ -802,9 +802,9 @@
 
 GuiInterface.prototype.IsFormationSelected = function(player, data)
 {
-	for each (let ent in data.ents)
+	for (let ent in data.ents)
 	{
-		let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
+		let cmpUnitAI = Engine.QueryInterface(data.ents[ent], IID_UnitAI);
 		// GetLastFormationName is named in a strange way as it (also) is
 		// the value of the current formation (see Formation.js LoadFormation)
 		if (cmpUnitAI && cmpUnitAI.GetLastFormationTemplate() == data.formationTemplate)
@@ -815,9 +815,9 @@
 
 GuiInterface.prototype.IsStanceSelected = function(player, data)
 {
-	for each (let ent in data.ents)
+	for (let ent in data.ents)
 	{
-		let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
+		let cmpUnitAI = Engine.QueryInterface(data.ents[ent], IID_UnitAI);
 		if (cmpUnitAI && cmpUnitAI.GetStanceName() == data.stance)
 			return true;
 	}
@@ -827,7 +827,7 @@
 GuiInterface.prototype.GetAllBuildableEntities = function(player, cmd)
 {
 	let buildableEnts = [];
-	for each (let ent in cmd.entities)
+	for (let ent of cmd.entities)
 	{
 		let cmpBuilder = Engine.QueryInterface(ent, IID_Builder);
 		if (!cmpBuilder)
@@ -844,7 +844,7 @@
 {
 	let playerColors = {}; // cache of owner -> color map
 
-	for each (let ent in cmd.entities)
+	for (let ent of cmd.entities)
 	{
 		let cmpSelectable = Engine.QueryInterface(ent, IID_Selectable);
 		if (!cmpSelectable)
@@ -934,9 +934,10 @@
 	let cmpPlayer = QueryPlayerIDInterface(player);
 
 	// If there are some rally points already displayed, first hide them
-	for each (let ent in this.entsRallyPointsDisplayed)
+	
+	for (let ent in this.entsRallyPointsDisplayed)
 	{
-		let cmpRallyPointRenderer = Engine.QueryInterface(ent, IID_RallyPointRenderer);
+		let cmpRallyPointRenderer = Engine.QueryInterface(this.entsRallyPointsDisplayed[ent], IID_RallyPointRenderer);
 		if (cmpRallyPointRenderer)
 			cmpRallyPointRenderer.SetDisplayed(false);
 	}
@@ -944,7 +945,7 @@
 	this.entsRallyPointsDisplayed = [];
 
 	// Show the rally points for the passed entities
-	for each (let ent in cmd.entities)
+	for (let ent of cmd.entities)
 	{
 		let cmpRallyPointRenderer = Engine.QueryInterface(ent, IID_RallyPointRenderer);
 		if (!cmpRallyPointRenderer)
@@ -974,7 +975,7 @@
 		{
 			// Only update the position if we changed it (cmd.queued is set)
 			if ("queued" in cmd)
-				if (cmd.queued == true)
+				if (cmd.queued === true)
 					cmpRallyPointRenderer.AddPosition({ 'x': pos.x, 'y': pos.z }); // AddPosition takes a CFixedVector2D which has X/Y components, not X/Z
 				else
 					cmpRallyPointRenderer.SetPosition({ 'x': pos.x, 'y': pos.z }); // SetPosition takes a CFixedVector2D which has X/Y components, not X/Z
@@ -981,8 +982,8 @@
 
 			// rebuild the renderer when not set (when reading saved game or in case of building update)
 			else if (!cmpRallyPointRenderer.IsSet())
-				for each (let posi in cmpRallyPoint.GetPositions())
-					cmpRallyPointRenderer.AddPosition({ 'x': posi.x, 'y': posi.z });
+				for (let pos of cmpRallyPoint.GetPositions())
+					cmpRallyPointRenderer.AddPosition({ 'x': pos.x, 'y': pos.z });
 
 			cmpRallyPointRenderer.SetDisplayed(true);
 
@@ -1026,7 +1027,7 @@
 			Engine.DestroyEntity(this.placementEntity[1]);
 
 		// Load the new template
-		if (cmd.template == "")
+		if (cmd.template === "")
 			this.placementEntity = undefined;
 		else
 			this.placementEntity = [cmd.template, Engine.AddLocalEntity("preview|" + cmd.template)];
@@ -1161,8 +1162,8 @@
 		// we're clearing the preview, clear the entity cache and bail
 		for (let tpl in this.placementWallEntities)
 		{
-			for each (let ent in this.placementWallEntities[tpl].entities)
-				Engine.DestroyEntity(ent);
+			for (let ent in this.placementWallEntities[tpl].entities)
+				Engine.DestroyEntity(this.placementWallEntities[tpl].entities[ent]);
 
 			this.placementWallEntities[tpl].numUsed = 0;
 			this.placementWallEntities[tpl].entities = [];
@@ -1176,9 +1177,9 @@
 		// Move all existing cached entities outside of the world and reset their use count
 		for (let tpl in this.placementWallEntities)
 		{
-			for each (let ent in this.placementWallEntities[tpl].entities)
+			for (let ent in this.placementWallEntities[tpl].entities)
 			{
-				let pos = Engine.QueryInterface(ent, IID_Position);
+				let pos = Engine.QueryInterface(this.placementWallEntities[tpl].entities[ent], IID_Position);
 				if (pos)
 					pos.MoveOutOfWorld();
 			}
@@ -1187,7 +1188,7 @@
 		}
 
 		// Create cache entries for templates we haven't seen before
-		for each (let tpl in wallSet.templates)
+		for (let tpl of wallSet.templates)
 		{
 			if (!(tpl in this.placementWallEntities))
 			{
@@ -1444,7 +1445,7 @@
 				if (i < previewEntities.length - 1)
 					terrainGroundNext = cmpTerrain.GetGroundLevel(previewEntities[i+1].pos.x, previewEntities[i+1].pos.z);
 
-				if (terrainGroundPrev != null || terrainGroundNext != null)
+				if (terrainGroundPrev !== null || terrainGroundNext !== null)
 				{
 					let targetY = Math.max(terrainGroundPrev, terrainGroundNext);
 					cmpPosition.SetHeightFixed(targetY);
@@ -1571,7 +1572,7 @@
 
 	// If any were entities required to build the wall, but none of them could be validly positioned, return failure
 	// (see method-level documentation).
-	if (numRequiredPieces > 0 && result.pieces.length == 0)
+	if (numRequiredPieces > 0 && result.pieces.length)
 		return false;
 
 	if (start.snappedEnt && start.snappedEnt != INVALID_ENTITY)
@@ -1618,9 +1619,9 @@
 		let minDistEntitySnapData = null;
 		let radius2 = data.snapRadius * data.snapRadius;
 
-		for each (let ent in data.snapEntities)
+		for (let ent in data.snapEntities)
 		{
-			let cmpPosition = Engine.QueryInterface(ent, IID_Position);
+			let cmpPosition = Engine.QueryInterface(data.snapEntities[ent], IID_Position);
 			if (!cmpPosition || !cmpPosition.IsInWorld())
 				continue;
 
@@ -1636,12 +1637,12 @@
 						"x": pos.x,
 						"z": pos.z,
 						"angle": cmpPosition.GetRotation().y,
-						"ent": ent
+						"ent": data.snapEntities[ent]
 				};
 			}
 		}
 
-		if (minDistEntitySnapData != null)
+		if (minDistEntitySnapData !== null)
 			return minDistEntitySnapData;
 	}
 
@@ -1693,7 +1694,7 @@
 		// If the entity is in the 'current' (first, 0) bucket on a resumed search, it must be after the "previous" unit, if any.
 		// By adding to the 'end', there is no pause if the series of units loops.
 		var bucket = filtered.bucket;
-		if(bucket == 0 && data.prevUnit && entity <= data.prevUnit)
+		if(bucket === 0 && data.prevUnit && entity <= data.prevUnit)
 			bucket = data.idleClasses.length;
 
 		if (!idleUnits[bucket])
@@ -1701,7 +1702,7 @@
 		idleUnits[bucket].push(entity);
 
 		// If enough units have been collected in the first bucket, go ahead and return them.
-		if (data.limit && bucket == 0 && idleUnits[0].length == data.limit)
+		if (data.limit && bucket === 0 && idleUnits[0].length == data.limit)
 			return idleUnits[0];
 	}
 
@@ -1873,9 +1874,9 @@
 
 GuiInterface.prototype.SetMotionDebugOverlay = function(player, data)
 {
-	for each (let ent in data.entities)
+	for (let ent in data.entities)
 	{
-		let cmpUnitMotion = Engine.QueryInterface(ent, IID_UnitMotion);
+		let cmpUnitMotion = Engine.QueryInterface(data.entities[ent], IID_UnitMotion);
 		if (cmpUnitMotion)
 			cmpUnitMotion.SetDebugOverlay(data.enabled);
 	}
@@ -1894,10 +1895,10 @@
 	let landTrader = { "total": 0, "trading": 0, "garrisoned": 0 };
 	let shipTrader = { "total": 0, "trading": 0 };
 
-	for each (let ent in traders)
+	for (let ent in traders)
 	{
-		let cmpIdentity = Engine.QueryInterface(ent, IID_Identity);
-		let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
+		let cmpIdentity = Engine.QueryInterface(traders[ent], IID_Identity);
+		let cmpUnitAI = Engine.QueryInterface(traders[ent], IID_UnitAI);
 		if (!cmpIdentity || !cmpUnitAI)
 			continue;
 
