Remove all occurrences of for each in JS scripts.

This will allow us to use some linters that would otherwise crash on
this non-standard SpiderMonkey feature. Refs #4419.

Special thanks to elexis for thoroughly checking and testing all the
changes!
Reviewed By: leper, elexis
Differential Revision: https://code.wildfiregames.com/D40
This was SVN commit r19191.
This commit is contained in:
Itms
2017-01-30 12:47:08 +00:00
parent c0ca70efd2
commit 83a2e810da
21 changed files with 96 additions and 99 deletions
+2 -2
View File
@@ -360,7 +360,7 @@ function moveCurrItem(objectName, up)
function areDependenciesMet(mod)
{
var guiObject = Engine.GetGUIObjectByName("message");
for each (var dependency in g_mods[mod].dependencies)
for (var dependency of g_mods[mod].dependencies)
{
if (isDependencyMet(dependency))
continue;
@@ -397,7 +397,7 @@ function isDependencyMet(dependency_idAndVersion, modsEnabled = null)
var dependency_id = dependency_idAndVersion;
// modsEnabled_key currently is the mod folder name.
for each (var modsEnabled_key in modsEnabled)
for (var modsEnabled_key of modsEnabled)
{
var modJson = g_mods[modsEnabled_key];
if (modJson.name != dependency_id)
+2 -2
View File
@@ -22,14 +22,14 @@ hwdetectTestData.sort(function(a, b) {
return 0;
});
for each (var settings in hwdetectTestData)
for (var settings of hwdetectTestData)
{
var output = RunDetection(settings);
var os = (settings.os_linux ? "linux" : settings.os_macosx ? "macosx" : settings.os_win ? "win" : "???");
var disabled = [];
for each (var d in ["disable_audio", "disable_s3tc", "disable_shadows", "disable_shadowpcf", "disable_allwater", "disable_fancywater", "override_renderpath"])
for (var d of ["disable_audio", "disable_s3tc", "disable_shadows", "disable_shadowpcf", "disable_allwater", "disable_fancywater", "override_renderpath"])
if (output[d] !== undefined)
disabled.push(d+"="+output[d])
@@ -38,12 +38,9 @@ function getXMLFileList(pathname)
function getJSONFileList(pathname)
{
var files = Engine.BuildDirEntList(pathname, "*.json", false);
// Remove the path and extension from each name, since we just want the filename
files = [ n.substring(pathname.length, n.length-5) for each (n in files) ];
return files;
return Engine.BuildDirEntList(pathname, "*.json", false).map(
filename => filename.substring(pathname.length, filename.length-5));
}
// A sorting function for arrays of objects with 'name' properties, ignoring case
@@ -108,7 +108,7 @@ Music.prototype.updateState = function()
Music.prototype.storeTracks = function(civMusic)
{
this.resetTracks();
for each (var music in civMusic)
for (var music of civMusic)
{
var type = undefined;
for (var i in this.MUSIC)
@@ -52,7 +52,7 @@ function updateTimers()
if (g_Timers[id][0] <= g_Time)
run.push(id);
}
for each (var id in run)
for (var id of run)
{
var t = g_Timers[id];
if (!t)
@@ -8,7 +8,7 @@ function init(data)
g_Controls = {};
var options = Engine.ReadJSONFile("gui/options/options.json");
for (let category of Object.keys(options))
for (let category in options)
{
let lastSize;
for (let i = 0; i < options[category].length; ++i)
@@ -84,7 +84,7 @@ function setupControl(option, i, category)
let checked;
let keyRenderer;
for (let param of Object.keys(option.parameters))
for (let param in option.parameters)
{
switch (param)
{
@@ -140,7 +140,7 @@ function setupControl(option, i, category)
let minval;
let maxval;
for (let param of Object.keys(option.parameters))
for (let param in option.parameters)
{
switch (param)
{
@@ -192,7 +192,7 @@ function setupControl(option, i, category)
control = Engine.GetGUIObjectByName(category + "Dropdown[" + i + "]");
control.onSelectionChange = function(){}; // just the time to setup the value
for (let param of Object.keys(option.parameters))
for (let param in option.parameters)
{
switch (param)
{
@@ -1738,23 +1738,23 @@ function unloadTemplate(template)
function unloadSelection()
{
var parent = 0;
var ents = [];
for each (var ent in g_Selection.selected)
let parent = 0;
let ents = [];
for (let ent in g_Selection.selected)
{
var state = GetExtendedEntityState(ent);
let state = GetExtendedEntityState(+ent);
if (!state || !state.turretParent)
continue;
if (!parent)
{
parent = state.turretParent;
ents.push(ent);
ents.push(+ent);
}
else if (state.turretParent == parent)
ents.push(ent);
ents.push(+ent);
}
if (parent)
Engine.PostNetworkCommand({ "type": "unload", "entities":ents, "garrisonHolder": parent });
Engine.PostNetworkCommand({ "type": "unload", "entities": ents, "garrisonHolder": parent });
}
function unloadAllByOwner()
Binary file not shown.
@@ -37,10 +37,14 @@ AlertRaiser.prototype.SoundAlert = function()
PlaySound(alertString, this.entity);
};
/**
* Used when units are spawned and need to follow alert orders.
* @param {number[]} units - Entity IDs of spawned units.
*/
AlertRaiser.prototype.UpdateUnits = function(units)
{
var level = this.GetLevel();
for each (var unit in units)
for (var unit of units)
{
var cmpUnitAI = Engine.QueryInterface(unit, IID_UnitAI);
if (!cmpUnitAI || !cmpUnitAI.ReactsToAlert(level))
@@ -71,7 +75,7 @@ AlertRaiser.prototype.IncreaseAlertLevel = function()
if (Engine.QueryInterface(this.entity, IID_ProductionQueue))
buildings.push(this.entity);
for each (var building in buildings)
for (var building of buildings)
{
var cmpProductionQueue = Engine.QueryInterface(building, IID_ProductionQueue);
cmpProductionQueue.PutUnderAlert(this.entity);
@@ -85,7 +89,7 @@ AlertRaiser.prototype.IncreaseAlertLevel = function()
return !cmpUnitAI.IsUnderAlert() && cmpUnitAI.ReactsToAlert(level);
});
for each (var unit in units)
for (var unit of units)
{
var cmpUnitAI = Engine.QueryInterface(unit, IID_UnitAI);
cmpUnitAI.ReplaceOrder("Alert", {"raiser": this.entity, "force": true});
@@ -110,7 +114,7 @@ AlertRaiser.prototype.EndOfAlert = function()
this.SoundAlert();
// First, handle units not yet garrisoned
for each (var unit in this.walkingUnits)
for (var unit of this.walkingUnits)
{
var cmpUnitAI = Engine.QueryInterface(unit, IID_UnitAI);
if (!cmpUnitAI)
@@ -126,7 +130,7 @@ AlertRaiser.prototype.EndOfAlert = function()
this.walkingUnits = [];
// Then, eject garrisoned units
for each (var slot in this.garrisonedUnits)
for (var slot of this.garrisonedUnits)
{
var cmpGarrisonHolder = Engine.QueryInterface(slot.holder, IID_GarrisonHolder);
var cmpUnitAI = Engine.QueryInterface(slot.unit, IID_UnitAI);
@@ -144,7 +148,7 @@ AlertRaiser.prototype.EndOfAlert = function()
this.garrisonedUnits = [];
// Finally, reset production buildings state
for each (var building in this.prodBuildings)
for (var building of this.prodBuildings)
{
var cmpProductionQueue = Engine.QueryInterface(building, IID_ProductionQueue);
if (cmpProductionQueue)
@@ -97,7 +97,7 @@ Formation.prototype.Init = function()
var differentAnimations = animations[animationName].split(/\s*;\s*/);
this.animations[animationName] = [];
// loop over the different rectangulars that will map to different animations
for each (var rectAnimation in differentAnimations)
for (var rectAnimation of differentAnimations)
{
var rect, replacementAnimationName;
[rect, replacementAnimationName] = rectAnimation.split(/\s*:\s*/);
@@ -171,7 +171,7 @@ Formation.prototype.GetClosestMember = function(ent, filter)
var entPosition = cmpEntPosition.GetPosition2D();
var closestMember = INVALID_ENTITY;
var closestDistance = Infinity;
for each (var member in this.members)
for (var member of this.members)
{
if (filter && !filter(ent))
continue;
@@ -297,7 +297,7 @@ Formation.prototype.SetMembers = function(ents)
var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
var templateName = cmpTemplateManager.GetCurrentTemplateName(this.entity);
for each (var ent in this.members)
for (var ent of this.members)
{
var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
cmpUnitAI.SetFormationController(this.entity);
@@ -329,14 +329,14 @@ Formation.prototype.RemoveMembers = function(ents)
this.members = this.members.filter(function(e) { return ents.indexOf(e) == -1; });
this.inPosition = this.inPosition.filter(function(e) { return ents.indexOf(e) == -1; });
for each (var ent in ents)
for (var ent of ents)
{
var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
cmpUnitAI.UpdateWorkOrders();
cmpUnitAI.SetFormationController(INVALID_ENTITY);
}
for each (var ent in this.formationMembersWithAura)
for (var ent of this.formationMembersWithAura)
{
var cmpAuras = Engine.QueryInterface(ent, IID_Auras);
cmpAuras.RemoveFormationBonus(ents);
@@ -369,7 +369,7 @@ Formation.prototype.AddMembers = function(ents)
this.offsets = undefined;
this.inPosition = [];
for each (var ent in this.formationMembersWithAura)
for (var ent of this.formationMembersWithAura)
{
var cmpAuras = Engine.QueryInterface(ent, IID_Auras);
cmpAuras.RemoveFormationBonus(ents);
@@ -381,7 +381,7 @@ Formation.prototype.AddMembers = function(ents)
this.members = this.members.concat(ents);
for each (var ent in this.members)
for (var ent of this.members)
{
var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
cmpUnitAI.SetFormationController(this.entity);
@@ -421,13 +421,13 @@ Formation.prototype.FindInPosition = function()
*/
Formation.prototype.Disband = function()
{
for each (var ent in this.members)
for (var ent of this.members)
{
var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
cmpUnitAI.SetFormationController(INVALID_ENTITY);
}
for each (var ent in this.formationMembersWithAura)
for (var ent of this.formationMembersWithAura)
{
var cmpAuras = Engine.QueryInterface(ent, IID_Auras);
cmpAuras.RemoveFormationBonus(this.members);
@@ -457,7 +457,7 @@ Formation.prototype.MoveMembersIntoFormation = function(moveCenter, force)
var active = [];
var positions = [];
for each (var ent in this.members)
for (var ent of this.members)
{
var cmpPosition = Engine.QueryInterface(ent, IID_Position);
if (!cmpPosition || !cmpPosition.IsInWorld())
@@ -538,7 +538,7 @@ Formation.prototype.MoveToMembersCenter = function()
{
var positions = [];
for each (var ent in this.members)
for (var ent of this.members)
{
var cmpPosition = Engine.QueryInterface(ent, IID_Position);
if (!cmpPosition || !cmpPosition.IsInWorld())
@@ -564,7 +564,7 @@ Formation.prototype.MoveToMembersCenter = function()
Formation.prototype.GetAvgFootprint = function(active)
{
var footprints = [];
for each (var ent in active)
for (var ent of active)
{
var cmpFootprint = Engine.QueryInterface(ent, IID_Footprint);
if (cmpFootprint)
@@ -574,7 +574,7 @@ Formation.prototype.GetAvgFootprint = function(active)
return {"width":1, "depth": 1};
var r = {"width": 0, "depth": 0};
for each (var shape in footprints)
for (var shape of footprints)
{
if (shape.type == "circle")
{
@@ -769,7 +769,7 @@ Formation.prototype.ComputeFormationOffsets = function(active, positions)
continue;
var usedOffsets = offsets.splice(-t.length);
var usedRealPositions = realPositions.splice(-t.length);
for each (var entPos in t)
for (var entPos of t)
{
var closestOffsetId = this.TakeClosestOffset(entPos, usedRealPositions, usedOffsets);
usedRealPositions.splice(closestOffsetId, 1);
@@ -813,7 +813,7 @@ Formation.prototype.GetRealOffsetPositions = function(offsets, pos)
var offsetPositions = [];
var {sin, cos} = this.GetEstimatedOrientation(pos);
// calculate the world positions
for each (var o in offsets)
for (var o of offsets)
offsetPositions.push(new Vector2D(pos.x + o.y * sin + o.x * cos, pos.y + o.y * cos - o.x * sin));
return offsetPositions;
@@ -861,7 +861,7 @@ Formation.prototype.ComputeMotionParameters = function()
var maxRadius = 0;
var minSpeed = Infinity;
for each (var ent in this.members)
for (var ent of this.members)
{
var cmpUnitMotion = Engine.QueryInterface(ent, IID_UnitMotion);
if (cmpUnitMotion)
@@ -968,7 +968,7 @@ Formation.prototype.RegisterTwinFormation = function(entity)
Formation.prototype.DeleteTwinFormations = function()
{
for each (var ent in this.twinFormations)
for (var ent of this.twinFormations)
{
var cmpFormation = Engine.QueryInterface(ent, IID_Formation);
if (cmpFormation)
@@ -25,7 +25,7 @@ FormationAttack.prototype.GetRange = function(target)
return result;
}
var members = cmpFormation.GetMembers();
for each (var ent in members)
for (var ent of members)
{
var cmpAttack = Engine.QueryInterface(ent, IID_Attack);
if (!cmpAttack)
@@ -183,7 +183,7 @@ Foundation.prototype.Build = function(builderEnt, work)
if (collisions.length)
{
var cmpFoundationOwnership = Engine.QueryInterface(this.entity, IID_Ownership);
for each (var ent in collisions)
for (var ent of collisions)
{
var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
if (cmpUnitAI)
@@ -62,17 +62,18 @@ GarrisonHolder.prototype.Init = function()
// Garrisoned Units
this.entities = [];
this.timer = undefined;
this.allowGarrisoning = {};
this.allowGarrisoning = new Map();
this.visibleGarrisonPoints = [];
if (this.template.VisibleGarrisonPoints)
{
for each (var offset in this.template.VisibleGarrisonPoints)
let points = this.template.VisibleGarrisonPoints;
for (let i in points)
{
var o = {};
o.x = +offset.X;
o.y = +offset.Y;
o.z = +offset.Z;
this.visibleGarrisonPoints.push({"offset":o, "entity": null});
let o = {};
o.x = +points[i].X;
o.y = +points[i].Y;
o.z = +points[i].Z;
this.visibleGarrisonPoints.push({ "offset": o, "entity": null });
}
}
};
@@ -154,7 +155,7 @@ GarrisonHolder.prototype.GetHealRate = function()
*/
GarrisonHolder.prototype.AllowGarrisoning = function(allow, callerID)
{
this.allowGarrisoning[callerID] = allow;
this.allowGarrisoning.set(callerID, allow);
};
/**
@@ -163,11 +164,10 @@ GarrisonHolder.prototype.AllowGarrisoning = function(allow, callerID)
*/
GarrisonHolder.prototype.IsGarrisoningAllowed = function()
{
for each (var allow in this.allowGarrisoning)
{
for (let [callerID, allow] of this.allowGarrisoning)
if (!allow)
return false;
}
return true;
};
@@ -177,7 +177,7 @@ GarrisonHolder.prototype.IsGarrisoningAllowed = function()
GarrisonHolder.prototype.GetGarrisonedEntitiesCount = function()
{
var count = 0;
for each (var ent in this.entities)
for (var ent of this.entities)
{
count++;
var cmpGarrisonHolder = Engine.QueryInterface(ent, IID_GarrisonHolder);
@@ -377,7 +377,7 @@ GarrisonHolder.prototype.OrderWalkToRallyPoint = function(entities)
// ignore the rally point if it is autogarrison
if (commands[0].type == "garrison" && commands[0].target == this.entity)
return;
for each (var com in commands)
for (var com of commands)
{
ProcessCommand(cmpOwnership.GetOwner(), com);
}
@@ -463,7 +463,7 @@ GarrisonHolder.prototype.UnloadTemplate = function(extendedTemplate, all, forced
var entities = [];
var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
for each (var entity in this.entities)
for (var entity of this.entities)
{
var cmpIdentity = Engine.QueryInterface(entity, IID_Identity);
@@ -549,7 +549,7 @@ GarrisonHolder.prototype.HealTimeout = function(data)
}
else
{
for each (var entity in this.entities)
for (var entity of this.entities)
{
var cmpHealth = Engine.QueryInterface(entity, IID_Health);
if (cmpHealth)
@@ -596,7 +596,7 @@ GarrisonHolder.prototype.OnGlobalOwnershipChanged = function(msg)
if (this.entity == msg.entity)
{
var entities = [];
for each (var entity in this.entities)
for (var entity of this.entities)
{
if (msg.to == -1 || !IsOwnedByMutualAllyOfEntity(this.entity, entity))
entities.push(entity);
@@ -694,7 +694,7 @@ GarrisonHolder.prototype.EjectOrKill = function(entities)
// And destroy all remaining entities
var killedEntities = [];
for each (var entity in entities)
for (var entity of entities)
{
var entityIndex = this.entities.indexOf(entity);
if (entityIndex == -1)
@@ -716,14 +716,12 @@ GarrisonHolder.prototype.EjectOrKill = function(entities)
*/
GarrisonHolder.prototype.IsEjectable = function(entity)
{
var ejectableClasses = this.template.EjectClassesOnDestroy._string;
let ejectableClasses = this.template.EjectClassesOnDestroy._string;
ejectableClasses = ejectableClasses ? ejectableClasses.split(/\s+/) : [];
var entityClasses = (Engine.QueryInterface(entity, IID_Identity)).GetClassesList();
for each (var ejectableClass in ejectableClasses)
if (entityClasses.indexOf(ejectableClass) != -1)
return true;
let entityClasses = Engine.QueryInterface(entity, IID_Identity).GetClassesList();
return false;
return ejectableClasses.some(
ejectableClass => entityClasses.indexOf(ejectableClass) != -1);
};
/**
@@ -829,7 +829,7 @@ GuiInterface.prototype.GetFormationInfoFromTemplate = function(player, data)
GuiInterface.prototype.IsFormationSelected = function(player, data)
{
for each (let ent in data.ents)
for (let ent of data.ents)
{
let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
// GetLastFormationName is named in a strange way as it (also) is
@@ -842,7 +842,7 @@ GuiInterface.prototype.IsFormationSelected = function(player, data)
GuiInterface.prototype.IsStanceSelected = function(player, data)
{
for each (let ent in data.ents)
for (let ent of data.ents)
{
let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
if (cmpUnitAI && cmpUnitAI.GetStanceName() == data.stance)
@@ -854,7 +854,7 @@ GuiInterface.prototype.IsStanceSelected = function(player, data)
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)
@@ -871,7 +871,7 @@ GuiInterface.prototype.SetSelectionHighlight = function(player, cmd)
{
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)
@@ -961,7 +961,7 @@ GuiInterface.prototype.DisplayRallyPoint = function(player, cmd)
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 of this.entsRallyPointsDisplayed)
{
let cmpRallyPointRenderer = Engine.QueryInterface(ent, IID_RallyPointRenderer);
if (cmpRallyPointRenderer)
@@ -971,7 +971,7 @@ GuiInterface.prototype.DisplayRallyPoint = function(player, cmd)
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)
@@ -1008,7 +1008,7 @@ GuiInterface.prototype.DisplayRallyPoint = function(player, cmd)
// 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())
for (let posi of cmpRallyPoint.GetPositions())
cmpRallyPointRenderer.AddPosition({ 'x': posi.x, 'y': posi.z });
cmpRallyPointRenderer.SetDisplayed(true);
@@ -1188,7 +1188,7 @@ GuiInterface.prototype.SetWallPlacementPreview = function(player, cmd)
// 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)
for (let ent of this.placementWallEntities[tpl].entities)
Engine.DestroyEntity(ent);
this.placementWallEntities[tpl].numUsed = 0;
@@ -1203,7 +1203,7 @@ GuiInterface.prototype.SetWallPlacementPreview = function(player, cmd)
// 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 of this.placementWallEntities[tpl].entities)
{
let pos = Engine.QueryInterface(ent, IID_Position);
if (pos)
@@ -1214,8 +1214,9 @@ GuiInterface.prototype.SetWallPlacementPreview = function(player, cmd)
}
// Create cache entries for templates we haven't seen before
for each (let tpl in wallSet.templates)
for (let type in wallSet.templates)
{
let tpl = wallSet.templates[type];
if (!(tpl in this.placementWallEntities))
{
this.placementWallEntities[tpl] = {
@@ -1642,7 +1643,7 @@ GuiInterface.prototype.GetFoundationSnapData = function(player, data)
let minDistEntitySnapData = null;
let radius2 = data.snapRadius * data.snapRadius;
for each (let ent in data.snapEntities)
for (let ent of data.snapEntities)
{
let cmpPosition = Engine.QueryInterface(ent, IID_Position);
if (!cmpPosition || !cmpPosition.IsInWorld())
@@ -1897,7 +1898,7 @@ GuiInterface.prototype.SetObstructionDebugOverlay = function(player, enabled)
GuiInterface.prototype.SetMotionDebugOverlay = function(player, data)
{
for each (let ent in data.entities)
for (let ent of data.entities)
{
let cmpUnitMotion = Engine.QueryInterface(ent, IID_UnitMotion);
if (cmpUnitMotion)
@@ -1918,7 +1919,7 @@ GuiInterface.prototype.GetTraderNumber = function(player)
let landTrader = { "total": 0, "trading": 0, "garrisoned": 0 };
let shipTrader = { "total": 0, "trading": 0 };
for each (let ent in traders)
for (let ent of traders)
{
let cmpIdentity = Engine.QueryInterface(ent, IID_Identity);
let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
@@ -89,7 +89,7 @@ PlayerManager.prototype.GetNumPlayers = function()
PlayerManager.prototype.RemoveAllPlayers = function()
{
// Destroy existing player entities
for each (var id in this.playerEntities)
for (var id of this.playerEntities)
Engine.DestroyEntity(id);
this.playerEntities = [];
@@ -473,7 +473,7 @@ ProductionQueue.prototype.RemoveBatch = function(id)
ProductionQueue.prototype.GetQueue = function()
{
var out = [];
for each (var item in this.queue)
for (var item of this.queue)
{
out.push({
"id": item.id,
@@ -648,7 +648,7 @@ ProductionQueue.prototype.SpawnUnits = function(templateName, count, metadata)
if (rallyPos)
{
var commands = GetRallyPointCommands(cmpRallyPoint, spawnedEnts);
for each(var com in commands)
for (var com of commands)
ProcessCommand(cmpOwnership.GetOwner(), com);
}
}
@@ -68,7 +68,7 @@ ResourceGatherer.prototype.GetCarryingStatus = function()
*/
ResourceGatherer.prototype.GiveResources = function(resources)
{
for each (let resource in resources)
for (let resource of resources)
{
this.carrying[resource.type] = +(resource.amount);
}
@@ -307,7 +307,7 @@ ResourceGatherer.prototype.CommitResources = function(types)
let cmpPlayer = QueryOwnerInterface(this.entity);
if (cmpPlayer)
for each (let type in types)
for (let type of types)
if (type in this.carrying)
{
cmpPlayer.AddResource(type, this.carrying[type]);
@@ -74,7 +74,7 @@ TriggerPoint.prototype.OnRangeUpdate = function(msg)
collection.splice(index, 1);
}
for each (var entity in msg.added)
for (var entity of msg.added)
collection.push(entity);
var r = {"currentCollection": collection.slice()};
@@ -5527,7 +5527,7 @@ UnitAI.prototype.FindWalkAndFightTargets = function()
{
var cmpUnitAI;
var cmpFormation = Engine.QueryInterface(this.entity, IID_Formation);
for each (var ent in cmpFormation.members)
for (var ent of cmpFormation.members)
{
if (!(cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI)))
continue;
@@ -297,20 +297,17 @@ function TestMoveIntoFormationWhileAttacking()
controllerAI.Attack(enemy, []);
for each (var ent in unitAIs) {
for (var ent of unitAIs)
TS_ASSERT_EQUALS(unitAI.fsmStateName, "INDIVIDUAL.COMBAT.ATTACKING");
}
controllerAI.MoveIntoFormation({"name": "Circle"});
// let all units be in position
for each (var ent in unitAIs) {
for (var ent of unitAIs)
controllerFormation.SetInPosition(ent);
}
for each (var ent in unitAIs) {
for (var ent of unitAIs)
TS_ASSERT_EQUALS(unitAI.fsmStateName, "INDIVIDUAL.COMBAT.ATTACKING");
}
controllerFormation.Disband();
}
@@ -165,7 +165,7 @@ function FSM(spec)
{
var refpath = node.split(".");
var refd = spec;
for each (var p in refpath)
for (var p of refpath)
{
refd = refd[p];
if (!refd)