Skip to content

Commit

Permalink
Remove unused variables and make them fatal in lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
kpreid committed Jul 29, 2012
1 parent d25e55e commit 626ff0b
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 27 deletions.
5 changes: 0 additions & 5 deletions audio.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@
footstep: [0.18, 0.1, 0, true, 1], footstep: [0.18, 0.1, 0, true, 1],
become: [0.05, 0.1, 0, false, 0.2] become: [0.05, 0.1, 0, false, 0.2]
}; };

// argument is time in wavelengths
function square(t) {
return Math.floor(t % 1 * 2);
}


function SynthData(type) { function SynthData(type) {
var blockWorld = type.world; var blockWorld = type.world;
Expand Down
2 changes: 0 additions & 2 deletions blockset.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.bindTexture(gl.TEXTURE_2D, null); gl.bindTexture(gl.TEXTURE_2D, null);


var blockTextureData;
var tileAllocMap; var tileAllocMap;
var freePointer; var freePointer;
var usageMap; var usageMap;
Expand Down Expand Up @@ -713,7 +712,6 @@
iconTodoSet[toRerenderIcon.value] = true; iconTodoSet[toRerenderIcon.value] = true;
start = true; start = true;
} }
var nonempty = false;
if (!iconRendererInterval) { if (!iconRendererInterval) {
iconRendererInterval = window.setInterval(function () { iconRendererInterval = window.setInterval(function () {
for (var idStr in iconTodoSet) { for (var idStr in iconTodoSet) {
Expand Down
2 changes: 2 additions & 0 deletions body.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -262,5 +262,7 @@
} }
}; };


Body.GRAVITY = GRAVITY;

cubes.Body = Object.freeze(Body); cubes.Body = Object.freeze(Body);
}()); }());
3 changes: 0 additions & 3 deletions input.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
(function () { (function () {
"use strict"; "use strict";


var Circuit = cubes.Circuit;
var exponentialStep = cubes.util.exponentialStep; var exponentialStep = cubes.util.exponentialStep;
var mkelement = cubes.util.mkelement; var mkelement = cubes.util.mkelement;
var signum = cubes.util.signum; var signum = cubes.util.signum;
Expand Down Expand Up @@ -993,8 +992,6 @@
clearChildren(hud.blocksetAll); clearChildren(hud.blocksetAll);


forAllMenuBlocks(function (blockID) { forAllMenuBlocks(function (blockID) {
var blockType = blocksetInMenu.get(blockID);

// element structure and style // element structure and style
var item = menuItemsByBlockId[blockID] = mkelement("span", "menu-item"); var item = menuItemsByBlockId[blockID] = mkelement("span", "menu-item");


Expand Down
5 changes: 1 addition & 4 deletions player.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
// physics constants // physics constants
var WALKING_SPEED = 4; // cubes/s var WALKING_SPEED = 4; // cubes/s
var FLYING_SPEED = 10; // cubes/s var FLYING_SPEED = 10; // cubes/s
var GRAVITY = 20; // cubes/s^2
var JUMP_SPEED = 8; // cubes/s var JUMP_SPEED = 8; // cubes/s
var MAX_STEP_UP = 0.57; // cubes
var CONTROL_STIFFNESS = 0.18; var CONTROL_STIFFNESS = 0.18;
var AIRSTEER_STIFFNESS = 0.03; var AIRSTEER_STIFFNESS = 0.03;


Expand Down Expand Up @@ -273,7 +271,7 @@
body.addVelocity([ body.addVelocity([
(movAdj[0] - body.vel[0]) * stiffness, (movAdj[0] - body.vel[0]) * stiffness,
body.flying ? (movAdj[1] - body.vel[1]) * stiffness body.flying ? (movAdj[1] - body.vel[1]) * stiffness
: movAdj[1] !== 0 ? (movAdj[1] - body.vel[1]) * stiffness + timestep * GRAVITY : 0, : movAdj[1] !== 0 ? (movAdj[1] - body.vel[1]) * stiffness + timestep * Body.GRAVITY : 0,
(movAdj[2] - body.vel[2]) * stiffness]); (movAdj[2] - body.vel[2]) * stiffness]);


if (config.lighting.get()) { if (config.lighting.get()) {
Expand Down Expand Up @@ -553,7 +551,6 @@
var cube = currentPlace.cursor.cube; var cube = currentPlace.cursor.cube;
var x = cube[0], y = cube[1], z = cube[2]; var x = cube[0], y = cube[1], z = cube[2];
if (currentPlace.world.g(x,y,z) !== 0 /* i.e. would destruction do anything */) { if (currentPlace.world.g(x,y,z) !== 0 /* i.e. would destruction do anything */) {
var value = currentPlace.world.g(x,y,z);
currentPlace.world.transientEvent(cube, "destroy"); currentPlace.world.transientEvent(cube, "destroy");
currentPlace.world.s(x, y, z, 0); currentPlace.world.s(x, y, z, 0);
aimChanged(); aimChanged();
Expand Down
2 changes: 1 addition & 1 deletion test/test-special.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe("Source code", function () {
testFiles.forEach(function (jsFilename) { testFiles.forEach(function (jsFilename) {
fetchResource(jsFilename, "text", runscallback(jsFilename, 1000, function (jsSource) { fetchResource(jsFilename, "text", runscallback(jsFilename, 1000, function (jsSource) {
var res = JSHINT(jsSource, jshintOptions); var res = JSHINT(jsSource, jshintOptions);
if (!res) { if (!res || JSHINT.data().unused) {
failures++ failures++
var container = mkelement("div", "jshint-report"); var container = mkelement("div", "jshint-report");
container.innerHTML/*ew*/ = JSHINT.report(true); container.innerHTML/*ew*/ = JSHINT.report(true);
Expand Down
1 change: 1 addition & 0 deletions util.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
failures += nullError; failures += nullError;
} else { } else {
for (var p in nullo) { for (var p in nullo) {
/*jshint expr: true */ p;
failures += nullError; failures += nullError;
break; break;
} }
Expand Down
6 changes: 3 additions & 3 deletions world-gen.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@
// Using raw array access because it lets us cache the altitude computation by iterating over y last, not because the overhead of .edit() is especially high. // Using raw array access because it lets us cache the altitude computation by iterating over y last, not because the overhead of .edit() is especially high.
var raw = topWorld.raw; var raw = topWorld.raw;
var rawSubData = topWorld.rawSubData; var rawSubData = topWorld.rawSubData;
var t0 = Date.now(); //var t0 = Date.now();
for (var x = 0; x < wx; x++) { for (var x = 0; x < wx; x++) {
var xbase = x*wy*wz; var xbase = x*wy*wz;
for (var z = 0; z < wz; z++) { for (var z = 0; z < wz; z++) {
Expand All @@ -825,9 +825,9 @@
} }
} }
} }
var t1 = Date.now(); //var t1 = Date.now();
topWorld.notifyRawEdit(); topWorld.notifyRawEdit();
var t2 = Date.now(); //var t2 = Date.now();
//console.log("Generation", t1 - t0, "ms updating", t2 - t1, "ms"); //console.log("Generation", t1 - t0, "ms updating", t2 - t1, "ms");
} }


Expand Down
13 changes: 5 additions & 8 deletions world-render.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@


// Cached blockset characteristics // Cached blockset characteristics
var tileSize = blockset.tileSize; var tileSize = blockset.tileSize;
var pixelSize = 1/tileSize;
var ID_EMPTY = Blockset.ID_EMPTY; var ID_EMPTY = Blockset.ID_EMPTY;


var particles = []; var particles = [];
Expand Down Expand Up @@ -583,7 +582,6 @@


var rotIndex = rawRotations[rawIndex]; var rotIndex = rawRotations[rawIndex];
var rot = rotationsByCode[rotIndex]; var rot = rotationsByCode[rotIndex];
var btype = types[value];
var faceData = (rotatedBlockFaceData[value] || BOGUS_BLOCK_DATA)[rotIndex]; var faceData = (rotatedBlockFaceData[value] || BOGUS_BLOCK_DATA)[rotIndex];
thisOpaque = opaques[value]; thisOpaque = opaques[value];


Expand Down Expand Up @@ -721,7 +719,7 @@
} }


var CENTER = [0.5, 0.5, 0.5]; var CENTER = [0.5, 0.5, 0.5];
var CYL_RADIUS = round(0.08 * tileSize) / tileSize; var beamRadius = round(0.08 * tileSize) / tileSize;
function makeCircuitRenderer(circuit) { function makeCircuitRenderer(circuit) {
var dyns; var dyns;
var circuitRenderer = new renderer.RenderBundle(gl.TRIANGLES, null, function (vertices, normals, colors) { var circuitRenderer = new renderer.RenderBundle(gl.TRIANGLES, null, function (vertices, normals, colors) {
Expand All @@ -730,13 +728,12 @@
var net = record[0]; var net = record[0];
var fromBlock = record[1]; var fromBlock = record[1];
var block = record[2]; var block = record[2];


var vbase = vertices.length;
var cbase = colors.length; var cbase = colors.length;
var numVertices = calcCylinder( var numVertices = calcCylinder(
vec3.add(record[1], CENTER, vec3.create()), vec3.add(fromBlock, CENTER, vec3.create()),
vec3.add(record[2], CENTER, vec3.create()), vec3.add(block, CENTER, vec3.create()),
0.1, beamRadius,
vertices, normals); vertices, normals);
for (var i = 0; i < numVertices; i++) for (var i = 0; i < numVertices; i++)
colors.push(1,1,1,1); colors.push(1,1,1,1);
Expand Down
1 change: 0 additions & 1 deletion world.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@
var x = Math.floor(Math.random() * wx); var x = Math.floor(Math.random() * wx);
var y = Math.floor(Math.random() * wy); var y = Math.floor(Math.random() * wy);
var z = Math.floor(Math.random() * wz); var z = Math.floor(Math.random() * wz);
var index = x*wy*wz + y*wz + z;


// The input value given is chosen so that if you want a rate of k, you can // The input value given is chosen so that if you want a rate of k, you can
// multiply k*value to get the chance you should do your thing. // multiply k*value to get the chance you should do your thing.
Expand Down

0 comments on commit 626ff0b

Please sign in to comment.