Fix some whitespace and remove unneeded parenthesis and brackets in the RallyPointCommands simulation helper.

This was SVN commit r18783.
This commit is contained in:
elexis 2016-09-26 10:25:47 +00:00
parent 8d4af29faf
commit 2e488571de

View File

@ -10,13 +10,9 @@ function GetRallyPointCommands(cmpRallyPoint, spawnedEnts)
// Look and see if there is a command in the rally point data, otherwise just walk there.
var command = undefined;
if (data[i] && data[i].command)
{
command = data[i].command;
}
else
{
command = "walk";
}
// If a target was set and the target no longer exists, or no longer
// has a valid position, then just walk to the rally point.
@ -24,9 +20,7 @@ function GetRallyPointCommands(cmpRallyPoint, spawnedEnts)
{
var cmpPosition = Engine.QueryInterface(data[i].target, IID_Position);
if (!cmpPosition || !cmpPosition.IsInWorld())
{
command = "walk";
}
}
switch (command)
@ -44,16 +38,16 @@ function GetRallyPointCommands(cmpRallyPoint, spawnedEnts)
break;
case "repair":
case "build":
ret.push( {
ret.push({
"type": "repair",
"entities": spawnedEnts,
"target": data[i].target,
"queued": true,
"autocontinue": (i == rallyPos.length-1)
"autocontinue": i == rallyPos.length - 1
});
break;
case "garrison":
ret.push( {
ret.push({
"type": "garrison",
"entities": spawnedEnts,
"target": data[i].target,
@ -61,7 +55,7 @@ function GetRallyPointCommands(cmpRallyPoint, spawnedEnts)
});
break;
case "attack-walk":
ret.push( {
ret.push({
"type": "attack-walk",
"entities": spawnedEnts,
"x": rallyPos[i].x,
@ -71,7 +65,7 @@ function GetRallyPointCommands(cmpRallyPoint, spawnedEnts)
});
break;
case "patrol":
ret.push( {
ret.push({
"type": "patrol",
"entities": spawnedEnts,
"x": rallyPos[i].x,
@ -82,7 +76,7 @@ function GetRallyPointCommands(cmpRallyPoint, spawnedEnts)
});
break;
case "attack":
ret.push( {
ret.push({
"type": "attack",
"entities": spawnedEnts,
"target": data[i].target,
@ -90,7 +84,7 @@ function GetRallyPointCommands(cmpRallyPoint, spawnedEnts)
});
break;
case "trade":
ret.push( {
ret.push({
"type": "setup-trade-route",
"entities": spawnedEnts,
"source": data[i].source,
@ -100,7 +94,7 @@ function GetRallyPointCommands(cmpRallyPoint, spawnedEnts)
});
break;
default:
ret.push( {
ret.push({
"type": "walk",
"entities": spawnedEnts,
"x": rallyPos[i].x,
@ -115,9 +109,9 @@ function GetRallyPointCommands(cmpRallyPoint, spawnedEnts)
// (we do not modify the RallyPoint before, as we want it to be displayed with all way-points)
if (ret.length > 1 && ret[ret.length-1].type == "setup-trade-route")
{
var route = [];
var waypoints = ret.length - 1;
for (var i = 0; i < waypoints; ++i)
{
if (ret[i].type != "walk")
@ -125,8 +119,9 @@ function GetRallyPointCommands(cmpRallyPoint, spawnedEnts)
route = undefined;
break;
}
route.push( {"x": ret[i].x, "z": ret[i].z} );
route.push({ "x": ret[i].x, "z": ret[i].z });
}
if (route && route.length > 0)
{
ret.splice(0, waypoints);