1
0
forked from 0ad/0ad

Remove trailing whitespace and simplify some length checks. Refs #252.

This was SVN commit r18214.
This commit is contained in:
elexis 2016-05-21 16:20:27 +00:00
parent a2bd82d171
commit 4b5f8dfca6
17 changed files with 91 additions and 92 deletions

View File

@ -488,7 +488,7 @@ function getPreferredEntities(ents)
for (var i = 0; i < filters.length; ++i) for (var i = 0; i < filters.length; ++i)
{ {
preferredEnts = ents.filter(filters[i]); preferredEnts = ents.filter(filters[i]);
if (preferredEnts.length > 0) if (preferredEnts.length)
break; break;
} }
return preferredEnts; return preferredEnts;

View File

@ -728,7 +728,7 @@ var g_EntityCommands =
return; return;
var selection = g_Selection.toList(); var selection = g_Selection.toList();
if (selection.length < 1) if (!selection.length)
return; return;
if (!entState.resourceSupply || !entState.resourceSupply.killBeforeGather || g_DevSettings.controlAll) if (!entState.resourceSupply || !entState.resourceSupply.killBeforeGather || g_DevSettings.controlAll)
openDeleteDialog(selection); openDeleteDialog(selection);
@ -748,7 +748,7 @@ var g_EntityCommands =
"execute": function(entState) "execute": function(entState)
{ {
var selection = g_Selection.toList(); var selection = g_Selection.toList();
if (selection.length > 0) if (selection.length)
stopUnits(selection); stopUnits(selection);
}, },
}, },
@ -950,7 +950,7 @@ var g_AllyEntityCommands =
{ {
var state = GetEntityState(entity); var state = GetEntityState(entity);
if (state.player == player) if (state.player == player)
count++; ++count;
} }
} }
} }

View File

@ -111,7 +111,7 @@ function getTradingTooltip(gain)
function getEntityOrHolder(ent) function getEntityOrHolder(ent)
{ {
var entState = GetEntityState(ent); var entState = GetEntityState(ent);
if (entState && !entState.position && entState.unitAI && entState.unitAI.orders.length > 0 && if (entState && !entState.position && entState.unitAI && entState.unitAI.orders.length &&
(entState.unitAI.orders[0].type == "Garrison" || entState.unitAI.orders[0].type == "Autogarrison")) (entState.unitAI.orders[0].type == "Garrison" || entState.unitAI.orders[0].type == "Autogarrison"))
return entState.unitAI.orders[0].data.target; return entState.unitAI.orders[0].data.target;

View File

@ -208,7 +208,7 @@ function loadTechnology(techName)
break; break;
case "all": case "all":
if (req[0].length < 1) if (!req[0].length)
tech.reqs.generic = req[1]; tech.reqs.generic = req[1];
else else
for (let r of req[0]) for (let r of req[0])

View File

@ -36,7 +36,7 @@ m.ResearchPlan.prototype.start = function(gameState)
// Prefer training buildings with short queues // Prefer training buildings with short queues
// (TODO: this should also account for units added to the queue by // (TODO: this should also account for units added to the queue by
// plans that have already been executed this turn) // plans that have already been executed this turn)
if (trainers.length > 0) if (trainers.length)
{ {
trainers.sort((a, b) => a.trainingQueueTime() - b.trainingQueueTime()); trainers.sort((a, b) => a.trainingQueueTime() - b.trainingQueueTime());
// drop anything in the queue if we rush it. // drop anything in the queue if we rush it.

View File

@ -53,7 +53,7 @@ m.TrainingPlan.prototype.start = function(gameState)
// Prefer training buildings with short queues // Prefer training buildings with short queues
// (TODO: this should also account for units added to the queue by // (TODO: this should also account for units added to the queue by
// plans that have already been executed this turn) // plans that have already been executed this turn)
if (trainersColl.length > 0) if (trainersColl.length)
{ {
let trainers = trainersColl.toEntityArray(); let trainers = trainersColl.toEntityArray();
let wantedIndex; let wantedIndex;

View File

@ -51,9 +51,8 @@ m.TutorialAI.prototype.OnUpdate = function() {
return; return;
} }
if (this.events.length > 0){ if (this.events.length)
this.savedEvents = this.savedEvents.concat(this.events); this.savedEvents = this.savedEvents.concat(this.events);
}
Engine.ProfileStart("tutorialBot"); Engine.ProfileStart("tutorialBot");