Skip to content

Commit

Permalink
all: Fix == and != compares
Browse files Browse the repository at this point in the history
  • Loading branch information
magcius committed Dec 7, 2024
1 parent 255ff24 commit d7f7518
Show file tree
Hide file tree
Showing 129 changed files with 639 additions and 641 deletions.
2 changes: 1 addition & 1 deletion src/BanjoKazooie/f3dex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export class RSPState implements RSPStateInterface {

dc.textureIndices.push(this._translateTileTexture(this.SP_TextureState.tile));

if (this.SP_TextureState.level == 0 && RDP.combineParamsUsesT1(dc.DP_Combine)) {
if (this.SP_TextureState.level === 0 && RDP.combineParamsUsesT1(dc.DP_Combine)) {
// if tex1 is used, and it isn't a mipmap, load it
// In 2CYCLE mode, it uses tile and tile + 1.
dc.textureIndices.push(this._translateTileTexture(this.SP_TextureState.tile + 1));
Expand Down
2 changes: 1 addition & 1 deletion src/BanjoKazooie/geo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ export const enum RenderZMode {
function commonSetup<N extends GeoNode>(buffer: ArrayBufferSlice, isTooie: boolean, builder: nodeBuilder<N>, zMode: number, textureData?: ArrayBufferSlice): GeoContext<N> {
const view = buffer.createDataView();

assert(view.getUint32(0x00) == 0x0B);
assert(view.getUint32(0x00) === 0x0B);

const f3dexOffs = view.getUint32(0x0C);
const f3dexCount = view.getUint32(f3dexOffs + 0x00);
Expand Down
4 changes: 2 additions & 2 deletions src/BanjoKazooie/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ void main() {
let alphaThreshold = 0;
if (alphaCompare === 0x01) {
alphaThreshold = this.blendAlpha;
} else if (alphaCompare != 0x00) {
} else if (alphaCompare !== 0x00) {
alphaThreshold = .0125; // should be dither
} else if (cvgXAlpha != 0x00) {
} else if (cvgXAlpha !== 0x00) {
// this line is taken from GlideN64, but here's some rationale:
// With this bit set, the pixel coverage value is multiplied by alpha
// before being sent to the blender. While coverage mostly matters for
Expand Down
2 changes: 1 addition & 1 deletion src/BanjoKazooie/scenes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ class SceneDesc implements Viewer.SceneDesc {

const setupFile = assertExists(findFileByID(obj, obj.SetupFileId));
this.addObjects(device, setupFile.Data, objectData, sceneRenderer);
if (obj.SceneID == 0x0b) {
if (obj.SceneID === 0x0b) {
const clanker = objectData.spawnObject(device, sceneRenderer.sceneEmitters, Actors.clankerID, vec3.fromValues(5500, 1100 /* or 0 */, 0))[0]! as GeometryRenderer;
clanker.animationController.init(15); // seems slower than others, not sure the source
// TODO: make sure Clanker renders before the parts
Expand Down
2 changes: 1 addition & 1 deletion src/BanjoKazooie/tools/extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ function extractObjectLoadFromAssembly(map: RAMMapper, entryAddress: number): Ob
break;
case MIPSOpcode.JAL:
const funcAddr = instr & 0x00ffffff;
assert(funcAddr == appendEntry || funcAddr == conditionalAppendEntry, "unknown function found");
assert(funcAddr === appendEntry || funcAddr === conditionalAppendEntry, "unknown function found");
delay = true;
break;
case MIPSOpcode.ADDIU:
Expand Down
2 changes: 1 addition & 1 deletion src/BanjoTooie/tools/extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ function dumpNames(fs: FS, rom: ArrayBufferSlice): Map<number, string> {
for (let j = 0; j < nameCount; j++) {
const x = txtView.getUint8(txtOffs + 0x00) & 0x7F;
const length = txtView.getUint8(txtOffs + 0x01);
if (x == index) {
if (x === index) {
names.set(level, readString(table, txtOffs + 2, length - 1));
break;
} else {
Expand Down
24 changes: 12 additions & 12 deletions src/BeetleAdventureRacing/MaterialRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,40 +172,40 @@ export class MaterialRenderer {
let otherModeLRenderMode = 0;
if (renderOpts & RenderOptionsFlags.UNK_18) {
let m = (renderOpts & (RenderOptionsFlags.UNK_17 | RenderOptionsFlags.UNK_16));
if (m == 0)
if (m === 0)
otherModeLRenderMode = 0x00112e10;
if (m == 0x400000)
if (m === 0x400000)
otherModeLRenderMode = 0x00112d58;
if (m == 0x800000)
if (m === 0x800000)
otherModeLRenderMode = 0x00104e50;
if (m == 0xc00000)
if (m === 0xc00000)
otherModeLRenderMode = 0x00104dd8;
} else if (renderOpts & RenderOptionsFlags.UNK_17) {
let m = (renderOpts & (RenderOptionsFlags.UNK_16 | RenderOptionsFlags.ENABLE_DEPTH_CALCULATIONS));

if (m == 0) {
if (m === 0) {
if (!this.isTextured)
otherModeLRenderMode = 0x00104340;
else
otherModeLRenderMode = 0x00104240;
}
if (m == 0x200000) {
if (m === 0x200000) {
if (!this.isTextured)
otherModeLRenderMode = 0x00104b50;
else if (this.uvtx.usesAlphaBlending)
otherModeLRenderMode = 0x00105278;
else
otherModeLRenderMode = 0x00104a50;
}
if (m == 0x400000) {
if (m === 0x400000) {
if (!this.isTextured)
otherModeLRenderMode = 0x001041c8;
else if (/* TODO: complicated flag checks */ false)
otherModeLRenderMode = 0x00103048;
else
otherModeLRenderMode = 0x001041c8;
}
if (m == 0x600000) {
if (m === 0x600000) {
if (!this.isTextured)
otherModeLRenderMode = 0x001045d8;
else if (this.uvtx.usesAlphaBlending)
Expand All @@ -217,13 +217,13 @@ export class MaterialRenderer {
}
} else {
let m = (renderOpts & (RenderOptionsFlags.UNK_16 | RenderOptionsFlags.ENABLE_DEPTH_CALCULATIONS));
if (m == 0)
if (m === 0)
otherModeLRenderMode = 0x03024000;
if (m == 0x200000)
if (m === 0x200000)
otherModeLRenderMode = 0x00112230;
if (m == 0x400000)
if (m === 0x400000)
otherModeLRenderMode = 0x00102048;
if (m == 0x600000)
if (m === 0x600000)
otherModeLRenderMode = 0x00102078;
}

Expand Down
2 changes: 1 addition & 1 deletion src/BeetleAdventureRacing/ParsedFiles/UVCT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class UVCT {
for (let j = 0; j < matrixCount; j++) {
const mtx = mat4.create();
curPos += RDP.readMatrixRDP(mtx, view, curPos);
if (j == 0) { // [PW64] TODO: figure out what other matrices are for
if (j === 0) { // [PW64] TODO: figure out what other matrices are for
placement = mtx;
}
assert(mtx[15] === 1.0);
Expand Down
2 changes: 1 addition & 1 deletion src/BeetleAdventureRacing/ParsedFiles/UVMD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class UVMD {
let material: Material;
({ material, curPos } = parseMaterial(view, curPos, filesystem));

if ((material.renderOptions & RenderOptionsFlags.ENABLE_TEX_GEN_SPHERICAL) != 0) {
if ((material.renderOptions & RenderOptionsFlags.ENABLE_TEX_GEN_SPHERICAL) !== 0) {
unknownBool = true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/BeetleAdventureRacing/ParsedFiles/UVTX.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export class UVTX {
// (so it can be compared to otherUVTXIndex, maybe other things?)
this.flagsAndIndex = view.getUint32(curPos + 7);
let otherUVTXIndex = view.getUint16(curPos + 11);
if(otherUVTXIndex != 0xFFF) {
if (otherUVTXIndex !== 0xFFF) {
//TODO: I think this is right?
if(otherUVTXIndex === (this.flagsAndIndex & 0xFFF)) {
this.otherUVTX = this;
Expand Down Expand Up @@ -228,7 +228,7 @@ export class UVTX {
// then read palettes if there are any to read
// TODO: this.unkByte1 is not just a bool - what is it
const palettesData: ArrayBufferSlice[] = [];
if (this.unkByte1 == 0) {
if (this.unkByte1 === 0) {
for (let i = 0; i < this.levelCount; i++) {
//TODO(?)
// i+1 because 0 palette is reserved or something
Expand Down
2 changes: 1 addition & 1 deletion src/BeetleAdventureRacing/TrackData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ let curHue = 0;
let curLightness = 0.5;
function nextConsistentRandomColor() {
curHue = (curHue + (107 / 360)) % 1;
curLightness = (curLightness == 0.5 ? 1 : 0.5);
curLightness = (curLightness === 0.5 ? 1 : 0.5);

let color: Color = colorNewFromRGBA(0, 0, 0, 0);
colorFromHSL(color, curHue, curLightness, 0.5);
Expand Down
2 changes: 1 addition & 1 deletion src/CodeEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function visibleRAF(elem: HTMLElement, func: (t: number) => void) {

let isRunning: boolean = false;
function setRunning(running: boolean) {
if (isRunning == running)
if (isRunning === running)
return;

isRunning = running;
Expand Down
2 changes: 1 addition & 1 deletion src/Common/JSYSTEM/J3D/J3DGraphAnimator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function sampleAnimationData(track: AnimationTrack, frame: number): numbe
}

function sampleANF1AnimationData(frames: number[], animFrame: number): number {
if (frames.length == 1) {
if (frames.length === 1) {
return frames[0];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Common/JSYSTEM/J3D/J3DLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ function readSHP1Chunk(buffer: ArrayBufferSlice, bmd: BMD): SHP1 {
let shapeInitDataIdx = shapeInitDataOffs;
for (let i = 0; i < shapeCount; i++) {
const shapeMtxType = view.getUint8(shapeInitDataIdx + 0x00);
assert(view.getUint8(shapeInitDataIdx + 0x01) == 0xFF);
assert(view.getUint8(shapeInitDataIdx + 0x01) === 0xFF);
const mtxGroupCount = view.getUint16(shapeInitDataIdx + 0x02);
const vtxDeclListIndex = view.getUint16(shapeInitDataIdx + 0x04);
const shapeMtxInitDataIndex = view.getUint16(shapeInitDataIdx + 0x06);
Expand Down
2 changes: 1 addition & 1 deletion src/Common/JSYSTEM/JPA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2990,7 +2990,7 @@ export class JPABaseParticle {

this.time = this.age / this.lifeTime;

if (this.age != 0) {
if (this.age !== 0) {
if (!!(this.status & JPAParticleStatus.FOLLOW_EMITTER))
vec3.copy(this.offsetPosition, workData.emitterGlobalCenterPos);

Expand Down
Loading

0 comments on commit d7f7518

Please sign in to comment.