From d7f751887897cf0fe3cdcf15d91b5e6c71996300 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Fri, 6 Dec 2024 20:31:33 -0800 Subject: [PATCH] all: Fix == and != compares --- src/BanjoKazooie/f3dex.ts | 2 +- src/BanjoKazooie/geo.ts | 2 +- src/BanjoKazooie/render.ts | 4 +- src/BanjoKazooie/scenes.ts | 2 +- src/BanjoKazooie/tools/extractor.ts | 2 +- src/BanjoTooie/tools/extractor.ts | 2 +- src/BeetleAdventureRacing/MaterialRenderer.ts | 24 ++-- src/BeetleAdventureRacing/ParsedFiles/UVCT.ts | 2 +- src/BeetleAdventureRacing/ParsedFiles/UVMD.ts | 2 +- src/BeetleAdventureRacing/ParsedFiles/UVTX.ts | 4 +- src/BeetleAdventureRacing/TrackData.ts | 2 +- src/CodeEditor.ts | 2 +- src/Common/JSYSTEM/J3D/J3DGraphAnimator.ts | 2 +- src/Common/JSYSTEM/J3D/J3DLoader.ts | 2 +- src/Common/JSYSTEM/JPA.ts | 2 +- src/Common/JSYSTEM/JStudio.ts | 80 ++++++------- src/Common/N64/RDP.ts | 22 ++-- src/Common/NW4R/lyt/Font.ts | 2 +- src/Common/PS2/GS.ts | 10 +- src/DarkSouls/dcx.ts | 32 +++--- src/DarkSouls/flver.ts | 2 +- src/DarkSouls/msb.ts | 16 +-- src/DarkSouls/tools/bhd5.ts | 8 +- src/DarkSouls/tpf.ts | 2 +- src/DataFetcher.ts | 2 +- src/DiddyKongRacing/DkrAnimationTrack.ts | 14 +-- src/DiddyKongRacing/DkrDrawCall.ts | 6 +- src/DiddyKongRacing/DkrLevelObjectMap.ts | 2 +- src/DiddyKongRacing/DkrObject.ts | 12 +- src/DiddyKongRacing/DkrObjectAnimation.ts | 2 +- src/DiddyKongRacing/DkrTexture.ts | 2 +- src/DonkeyKong64/scenes.ts | 2 +- src/FinalFantasyX/bin.ts | 2 +- src/FinalFantasyX/script.ts | 8 +- src/Glover/actor.ts | 52 ++++----- src/Glover/bullets.ts | 10 +- src/Glover/enemy.ts | 52 ++++----- src/Glover/fla2.ts | 8 +- src/Glover/particles.ts | 6 +- src/Glover/render.ts | 26 ++--- src/Glover/scenes.ts | 48 ++++---- src/Glover/sprite.ts | 16 +-- src/Glover/textures.ts | 12 +- src/Glover/util.ts | 4 +- src/HeavyIron/HIModelBucket.ts | 2 +- src/HeavyIron/HIP.ts | 4 +- src/HeavyIron/HIScene.ts | 6 +- src/InputManager.ts | 8 +- src/JetSetRadio/Ninja.ts | 6 +- src/KatamariDamacy/bin.ts | 2 +- src/KatamariDamacy/tools/extractor.ts | 2 +- src/KingdomHearts/bin.ts | 36 +++--- src/KingdomHearts/bin_tex.ts | 24 ++-- src/KingdomHearts/render.ts | 6 +- src/KingdomHearts2FinalMix/map.ts | 2 +- src/MetroidPrime/ancs.ts | 8 +- src/MetroidPrime/collision.ts | 4 +- src/MetroidPrime/mlvl.ts | 16 +-- src/MetroidPrime/mrea.ts | 18 +-- .../particles/element_generator.ts | 4 +- src/MetroidPrime/render.ts | 2 +- src/MetroidPrime/script.ts | 8 +- src/MetroidPrime/stream.ts | 2 +- src/MetroidPrime/strg.ts | 4 +- src/MetroidPrimeHunters/mph_binModel.ts | 10 +- src/MetroidPrimeHunters/render.ts | 8 +- src/Morrowind/Render.ts | 2 +- src/NeedForSpeedMostWanted/datanode.ts | 6 +- src/NeedForSpeedMostWanted/map.ts | 40 +++---- src/NeedForSpeedMostWanted/particles.ts | 2 +- src/NeedForSpeedMostWanted/region.ts | 84 +++++++------- src/NeedForSpeedMostWanted/render.ts | 30 ++--- src/OcarinaOfTime3D/cmb.ts | 4 +- src/OcarinaOfTime3D/lm3d_scenes.ts | 8 +- src/OcarinaOfTime3D/render.ts | 12 +- src/OcarinaOfTime3D/zar.ts | 2 +- src/OcarinaOfTime3D/zsi.ts | 4 +- src/PaperMario64/render.ts | 2 +- src/Pilotwings64/Scenes.ts | 16 +-- src/PokemonSnap/motion.ts | 2 +- src/PokemonSnap/render.ts | 2 +- src/PokemonSnap/room.ts | 2 +- src/SourceEngine/BSPFile.ts | 2 +- .../Materials/MaterialParameters.ts | 4 +- src/SourceEngine/VMT.ts | 2 +- src/StarFoxAdventures/Objects/Classes.ts | 4 +- src/StarFoxAdventures/WorldLights.ts | 2 +- src/StarFoxAdventures/maps.ts | 6 +- src/StarFoxAdventures/materials.ts | 4 +- src/StarFoxAdventures/modelexhibit.ts | 2 +- src/StarFoxAdventures/modelloader.ts | 4 +- src/StarFoxAdventures/objects.ts | 2 +- src/StarFoxAdventures/resource.ts | 2 +- src/StarFoxAdventures/textures.ts | 6 +- src/SuperMarioGalaxy/Actors/LegacyActor.ts | 2 +- src/SuperMonkeyBall/AVTpl.ts | 2 +- src/SuperMonkeyBall/Shape.ts | 2 +- src/SuperMonkeyBall/Stagedef.ts | 10 +- src/WiiSports/Scenes_WiiSports.ts | 12 +- src/WorldOfWarcraft/data.ts | 2 +- src/WorldOfWarcraft/render.ts | 2 +- src/ZeldaSkywardSword/Main.ts | 106 +++++++++--------- src/ZeldaTwilightPrincess/LegacyActor.ts | 2 +- src/ZeldaTwilightPrincess/d_a.ts | 24 ++-- src/ZeldaTwilightPrincess/d_kankyo.ts | 8 +- src/ZeldaTwilightPrincess/d_kankyo_wether.ts | 6 +- src/ZeldaWindWaker/LegacyActor.ts | 16 +-- src/ZeldaWindWaker/Main.ts | 6 +- src/ZeldaWindWaker/d_a.ts | 20 ++-- src/ZeldaWindWaker/d_demo.ts | 8 +- src/ZeldaWindWaker/d_kankyo_wether.ts | 2 +- src/ZeldaWindWaker/d_wood.ts | 20 ++-- src/ZeldaWindWaker/f_op_actor.ts | 6 +- src/ZeldaWindWaker/framework.ts | 2 +- src/byml.ts | 10 +- src/endian.ts | 2 +- src/gfx/platform/GfxPlatformObjUtil.ts | 2 +- src/gfx/platform/GfxPlatformWebGL2.ts | 4 +- src/gfx/render/GfxRenderInstManager.ts | 2 +- src/j3d/mkdd_scenes.ts | 8 +- src/nns_g3d/NNS_G3D.ts | 4 +- src/nns_g3d/Scenes_PokemonHGSS.ts | 4 +- src/nns_g3d/Scenes_PokemonPlatinum.ts | 4 +- src/nns_g3d/nsmbds_scenes.ts | 10 +- src/psychonauts/plb.ts | 4 +- src/psychonauts/ppf.ts | 2 +- src/rres/render.ts | 2 +- src/ui.ts | 2 +- src/zelview/f3dzex.ts | 6 +- 129 files changed, 639 insertions(+), 641 deletions(-) diff --git a/src/BanjoKazooie/f3dex.ts b/src/BanjoKazooie/f3dex.ts index 7c969d126..b606b8d6d 100644 --- a/src/BanjoKazooie/f3dex.ts +++ b/src/BanjoKazooie/f3dex.ts @@ -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)); diff --git a/src/BanjoKazooie/geo.ts b/src/BanjoKazooie/geo.ts index 7e7266903..d0dfead47 100644 --- a/src/BanjoKazooie/geo.ts +++ b/src/BanjoKazooie/geo.ts @@ -723,7 +723,7 @@ export const enum RenderZMode { function commonSetup(buffer: ArrayBufferSlice, isTooie: boolean, builder: nodeBuilder, zMode: number, textureData?: ArrayBufferSlice): GeoContext { 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); diff --git a/src/BanjoKazooie/render.ts b/src/BanjoKazooie/render.ts index 6c25f6224..40cd1462f 100644 --- a/src/BanjoKazooie/render.ts +++ b/src/BanjoKazooie/render.ts @@ -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 diff --git a/src/BanjoKazooie/scenes.ts b/src/BanjoKazooie/scenes.ts index 661a15561..dcf72e7d2 100644 --- a/src/BanjoKazooie/scenes.ts +++ b/src/BanjoKazooie/scenes.ts @@ -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 diff --git a/src/BanjoKazooie/tools/extractor.ts b/src/BanjoKazooie/tools/extractor.ts index b4942cacd..5a6e80860 100644 --- a/src/BanjoKazooie/tools/extractor.ts +++ b/src/BanjoKazooie/tools/extractor.ts @@ -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: diff --git a/src/BanjoTooie/tools/extractor.ts b/src/BanjoTooie/tools/extractor.ts index 40983aeea..4403697a6 100644 --- a/src/BanjoTooie/tools/extractor.ts +++ b/src/BanjoTooie/tools/extractor.ts @@ -323,7 +323,7 @@ function dumpNames(fs: FS, rom: ArrayBufferSlice): Map { 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 { diff --git a/src/BeetleAdventureRacing/MaterialRenderer.ts b/src/BeetleAdventureRacing/MaterialRenderer.ts index cb0a2261a..561ed9899 100644 --- a/src/BeetleAdventureRacing/MaterialRenderer.ts +++ b/src/BeetleAdventureRacing/MaterialRenderer.ts @@ -172,24 +172,24 @@ 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) @@ -197,7 +197,7 @@ export class MaterialRenderer { else otherModeLRenderMode = 0x00104a50; } - if (m == 0x400000) { + if (m === 0x400000) { if (!this.isTextured) otherModeLRenderMode = 0x001041c8; else if (/* TODO: complicated flag checks */ false) @@ -205,7 +205,7 @@ export class MaterialRenderer { else otherModeLRenderMode = 0x001041c8; } - if (m == 0x600000) { + if (m === 0x600000) { if (!this.isTextured) otherModeLRenderMode = 0x001045d8; else if (this.uvtx.usesAlphaBlending) @@ -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; } diff --git a/src/BeetleAdventureRacing/ParsedFiles/UVCT.ts b/src/BeetleAdventureRacing/ParsedFiles/UVCT.ts index e8f188582..75844f8a5 100644 --- a/src/BeetleAdventureRacing/ParsedFiles/UVCT.ts +++ b/src/BeetleAdventureRacing/ParsedFiles/UVCT.ts @@ -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); diff --git a/src/BeetleAdventureRacing/ParsedFiles/UVMD.ts b/src/BeetleAdventureRacing/ParsedFiles/UVMD.ts index 6e7ff1474..b574d4713 100644 --- a/src/BeetleAdventureRacing/ParsedFiles/UVMD.ts +++ b/src/BeetleAdventureRacing/ParsedFiles/UVMD.ts @@ -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; } diff --git a/src/BeetleAdventureRacing/ParsedFiles/UVTX.ts b/src/BeetleAdventureRacing/ParsedFiles/UVTX.ts index 470f66248..9c7929d02 100644 --- a/src/BeetleAdventureRacing/ParsedFiles/UVTX.ts +++ b/src/BeetleAdventureRacing/ParsedFiles/UVTX.ts @@ -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; @@ -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 diff --git a/src/BeetleAdventureRacing/TrackData.ts b/src/BeetleAdventureRacing/TrackData.ts index ca0d5d333..0e265d895 100644 --- a/src/BeetleAdventureRacing/TrackData.ts +++ b/src/BeetleAdventureRacing/TrackData.ts @@ -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); diff --git a/src/CodeEditor.ts b/src/CodeEditor.ts index e10c77a87..24de73c9f 100644 --- a/src/CodeEditor.ts +++ b/src/CodeEditor.ts @@ -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; diff --git a/src/Common/JSYSTEM/J3D/J3DGraphAnimator.ts b/src/Common/JSYSTEM/J3D/J3DGraphAnimator.ts index c4e2a0130..4761a13f8 100644 --- a/src/Common/JSYSTEM/J3D/J3DGraphAnimator.ts +++ b/src/Common/JSYSTEM/J3D/J3DGraphAnimator.ts @@ -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]; } diff --git a/src/Common/JSYSTEM/J3D/J3DLoader.ts b/src/Common/JSYSTEM/J3D/J3DLoader.ts index 3fed94a94..2483a05dc 100644 --- a/src/Common/JSYSTEM/J3D/J3DLoader.ts +++ b/src/Common/JSYSTEM/J3D/J3DLoader.ts @@ -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); diff --git a/src/Common/JSYSTEM/JPA.ts b/src/Common/JSYSTEM/JPA.ts index ca079e124..e6a32597c 100644 --- a/src/Common/JSYSTEM/JPA.ts +++ b/src/Common/JSYSTEM/JPA.ts @@ -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); diff --git a/src/Common/JSYSTEM/JStudio.ts b/src/Common/JSYSTEM/JStudio.ts index e591c1634..0d032e7dd 100644 --- a/src/Common/JSYSTEM/JStudio.ts +++ b/src/Common/JSYSTEM/JStudio.ts @@ -336,7 +336,7 @@ abstract class STBObject { while (true) { // Top bit of mFlags makes this object immediately inactive, restarting any existing sequence if (this.flags & 0x8000) { - if (this.status != EStatus.Inactive) { + if (this.status !== EStatus.Inactive) { this.status = EStatus.Inactive; if (this.isSequence) { this.do_end(); @@ -345,7 +345,7 @@ abstract class STBObject { return true; } - if (this.status == EStatus.Inactive) { + if (this.status === EStatus.Inactive) { assert(this.isSequence); this.do_begin(); this.status = EStatus.Wait; @@ -353,7 +353,7 @@ abstract class STBObject { if ((this.control && this.control.isSuspended()) || this.isSuspended()) { if (this.isSequence) { - assert((this.status == EStatus.Wait) || (this.status == EStatus.Suspend)); + assert((this.status === EStatus.Wait) || (this.status === EStatus.Suspend)); this.status = EStatus.Suspend; this.do_wait(frameCount); } @@ -366,7 +366,7 @@ abstract class STBObject { // If there is nothing left in the sequence, end it if (!this.sequence) { if (this.isSequence) { - assert(this.status != EStatus.Still); + assert(this.status !== EStatus.Still); if (!hasWaited) { this.do_wait(0); } @@ -379,16 +379,16 @@ abstract class STBObject { // If we're not currently running a sequence, start it if (!this.isSequence) { - assert(this.status == EStatus.Still); + assert(this.status === EStatus.Still); this.isSequence = true; this.do_begin(); } this.status = EStatus.Wait; - if (this.wait == 0) { + if (this.wait === 0) { this.process_sequence(); - if (this.wait == 0) { + if (this.wait === 0) { break; } } @@ -417,7 +417,7 @@ abstract class STBObject { let param = view.getUint32(byteIdx) & 0xFFFFFF; let next = 0; - if (cmd != 0) { + if (cmd !== 0) { if (cmd <= 0x7f) { next = byteIdx + 4; } else { @@ -477,7 +477,7 @@ abstract class STBObject { case 0x80: debugger; break; case 0x81: const idSize = file.view.getUint16(dataOffset + 2); - assert(idSize == 4); + assert(idSize === 4); const id = file.view.getUint32(dataOffset + 4); const contentOffset = dataOffset + 4 + align(idSize, 4); const contentSize = dataSize - (contentOffset - dataOffset); @@ -637,7 +637,7 @@ class TActorAdaptor extends TAdaptor { } public adaptor_do_PARENT(data: ParagraphData): void { - assert(data.dataOp == EDataOp.ObjectName); + assert(data.dataOp === EDataOp.ObjectName); this.log(`SetParent: ${data.value}`); this.parent = this.system.JSGFindObject(data.value, JStage.EObject.PreExistingActor); } @@ -658,14 +658,14 @@ class TActorAdaptor extends TAdaptor { } public adaptor_do_PARENT_ENABLE(data: ParagraphData): void { - assert(data.dataOp == EDataOp.Immediate); + assert(data.dataOp === EDataOp.Immediate); this.log(`SetParentEnable: ${data.valueInt}`); if (data.valueInt) { this.object.JSGSetParent(this.parent!, this.parentNodeID); } else { this.object.JSGSetParent(null, 0xFFFFFFFF); } } public adaptor_do_RELATION(data: ParagraphData): void { - assert(data.dataOp == EDataOp.ObjectName); + assert(data.dataOp === EDataOp.ObjectName); this.log(`SetRelation: ${data.value}`); this.relation = this.system.JSGFindObject(data.value, JStage.EObject.PreExistingActor); } @@ -686,37 +686,37 @@ class TActorAdaptor extends TAdaptor { } public adaptor_do_RELATION_ENABLE(data: ParagraphData): void { - assert(data.dataOp == EDataOp.Immediate); + assert(data.dataOp === EDataOp.Immediate); this.log(`SetRelationEnable: ${data.valueInt}`); this.object.JSGSetRelation(!!data.valueInt, this.relation!, this.relationNodeID); } public adaptor_do_SHAPE(data: ParagraphData): void { - assert(data.dataOp == EDataOp.ObjectIdx); + assert(data.dataOp === EDataOp.ObjectIdx); this.log(`SetShape: ${data.value}`); this.object.JSGSetShape(data.value); } public adaptor_do_ANIMATION(data: ParagraphData): void { - assert(data.dataOp == EDataOp.ObjectIdx); + assert(data.dataOp === EDataOp.ObjectIdx); this.log(`SetAnimation: ${(data.value) & 0xFFFF} (${(data.value) >> 4 & 0x01})`); this.object.JSGSetAnimation(data.value); } public adaptor_do_ANIMATION_MODE(data: ParagraphData): void { - assert(data.dataOp == EDataOp.Immediate); + assert(data.dataOp === EDataOp.Immediate); this.log(`SetAnimationMode: ${data.valueInt}`); this.animMode = data.valueInt; } public adaptor_do_TEXTURE_ANIMATION(data: ParagraphData): void { - assert(data.dataOp == EDataOp.ObjectIdx); + assert(data.dataOp === EDataOp.ObjectIdx); this.log(`SetTexAnim: ${data.value}`); this.object.JSGSetTextureAnimation(data.value); } public adaptor_do_TEXTURE_ANIMATION_MODE(data: ParagraphData): void { - assert(data.dataOp == EDataOp.Immediate); + assert(data.dataOp === EDataOp.Immediate); this.log(`SetTexAnimMode: ${data.valueInt}`); this.animTexMode = data.valueInt; } @@ -772,7 +772,7 @@ class TActorObject extends STBObject { case 0x32: debugger; keyIdx = EActorTrack.Parent; - if (dataOp == EDataOp.FuncValIdx || dataOp == EDataOp.FuncValName) { + if (dataOp === EDataOp.FuncValIdx || dataOp === EDataOp.FuncValName) { debugger; this.adaptor.adaptor_setVariableValue(this, keyIdx, data); this.adaptor.variableValues[keyIdx].setOutput((enabled, adaptor) => { @@ -1005,7 +1005,7 @@ class TParagraph { let type; let offset; - if ((dataSize & 0x8000) == 0) { + if ((dataSize & 0x8000) === 0) { // 16 bit data type = view.getUint16(byteIdx + 2); offset = 4; @@ -1016,7 +1016,7 @@ class TParagraph { offset = 8; } - if (dataSize == 0) { + if (dataSize === 0) { return { dataSize, type, dataOffset: 0, nextOffset: byteIdx + offset }; } else { return { dataSize, type, dataOffset: byteIdx + offset, nextOffset: byteIdx + offset + align(dataSize, 4) }; @@ -1112,7 +1112,7 @@ namespace FVB { switch (para.type) { case EPrepareOp.None: this.funcVal.prepare(); - assert(para.nextOffset == blockNext); + assert(para.nextOffset === blockNext); return; case EPrepareOp.Data: @@ -1120,7 +1120,7 @@ namespace FVB { break; case EPrepareOp.RangeSet: - assert(para.dataSize == 8); + assert(para.dataSize === 8); const range = this.funcVal.getAttrRange(); assert(!!range, 'FVB Paragraph assumes FuncVal has range attribute, but it does not'); const begin = file.view.getFloat32(para.dataOffset + 0); @@ -1137,7 +1137,7 @@ namespace FVB { for (let i = 0; i < objCount; i++) { const idSize = file.view.getUint32(para.dataOffset + 4 + i * 8 + 0); const id = readString(file.buffer, para.dataOffset + 4 + i * 8 + 4, idSize); - const obj = pControl.objects.find(o => o.id == id); + const obj = pControl.objects.find(o => o.id === id); assert(!!obj); refer.fvs.push(obj.funcVal); } @@ -1159,7 +1159,7 @@ namespace FVB { } case EPrepareOp.InterpSet: - assert(para.dataSize == 4); + assert(para.dataSize === 4); const interp = this.funcVal.getAttrInterpolate(); assert(!!interp, 'FVB Paragraph assumes FuncVal has interpolate attribute, but it does not'); const interpType = file.view.getUint32(para.dataOffset + 0); @@ -1176,7 +1176,7 @@ namespace FVB { pOffset = para.nextOffset; } - assert(pOffset == blockNext); + assert(pOffset === blockNext); this.funcVal.prepare(); } } @@ -1241,7 +1241,7 @@ namespace FVB { let version = view.getUint16(0x06); let blockCount = view.getUint32(0x0C); assert(fourCC === 'FVB'); - assert(byteOrder == 0xFEFF); + assert(byteOrder === 0xFEFF); assert(version >= 2 && version <= 256); // As of Wind Waker const blockReader = new Reader(data, 16); @@ -1355,7 +1355,7 @@ namespace FVB { override funcVal = new FunctionValue_Constant; public override prepare_data(para: TParagraph, control: TControl, file: Reader): void { - assert(para.dataSize == 4); + assert(para.dataSize === 4); const value = file.view.getFloat32(para.dataOffset); this.funcVal.setData(value); } @@ -1433,9 +1433,9 @@ namespace FVB { const t = this.range.getParameter(timeSec, this.getStartTime(), this.getEndTime()); // Update our current key. If the current time is between keys, select the later one. - this.curKeyIdx = this.keys.findIndex((k, i) => (i % 2) == 0 && k >= t) / 2; + this.curKeyIdx = this.keys.findIndex((k, i) => (i % 2) === 0 && k >= t) / 2; - if (this.curKeyIdx == 0) { // Time is at or before the start, return the first key + if (this.curKeyIdx === 0) { // Time is at or before the start, return the first key return this.keys[this.curKeyIdx * 2 + 1]; } else if (this.curKeyIdx < 0) { // Time is at or after the end, return the last key this.curKeyIdx = this.keyCount - 1; @@ -1608,7 +1608,7 @@ namespace FVB { public static composite_raw(fvs: TFunctionValue[], dataVal: number, timeSec: number): number { debugger; // Untested. Remove once confirmed working - if (fvs.length == 0) { return 0.0; } + if (fvs.length === 0) { return 0.0; } return fvs[dataVal].getValue(timeSec); } @@ -1633,7 +1633,7 @@ namespace FVB { public static composite_subtract(fvs: TFunctionValue[], dataVal: number, timeSec: number): number { debugger; // Untested. Remove once confirmed working - if (fvs.length == 0) { return 0.0; } + if (fvs.length === 0) { return 0.0; } let val = fvs[0].getValue(timeSec); for (let fv of fvs.slice(1)) { val -= fv.getValue(timeSec); } return val - dataVal; @@ -1648,7 +1648,7 @@ namespace FVB { public static composite_divide(fvs: TFunctionValue[], dataVal: number, timeSec: number): number { debugger; // Untested. Remove once confirmed working - if (fvs.length == 0) { return 0.0; } + if (fvs.length === 0) { return 0.0; } let val = fvs[0].getValue(timeSec); for (let fv of fvs.slice(1)) { val /= fv.getValue(timeSec); } return val / dataVal; @@ -1689,7 +1689,7 @@ namespace FVB { public prepare(): void { this.range.prepare(); } public setData(values: Float32Array, stride: number) { - assert(stride == 3 || stride == 4); + assert(stride === 3 || stride === 4); this.stride = stride this.keys = values; this.keyCount = values.length / stride; @@ -1707,9 +1707,9 @@ namespace FVB { const t = this.range.getParameter(timeSec, this.getStartTime(), this.getEndTime()); // Update our current key. If the current time is between keys, select the later one. - this.curKeyIdx = this.keys.findIndex((k, i) => (i % this.stride) == 0 && k >= t) / this.stride; + this.curKeyIdx = this.keys.findIndex((k, i) => (i % this.stride) === 0 && k >= t) / this.stride; - if (this.curKeyIdx == 0) { // Time is at or before the start, return the first key + if (this.curKeyIdx === 0) { // Time is at or before the start, return the first key return this.keys[this.curKeyIdx * this.stride + 1]; } else if (this.curKeyIdx < 0) { // Time is at or after the end, return the last key this.curKeyIdx = this.keyCount - 1; @@ -1829,7 +1829,7 @@ export class TControl { } public getFunctionValueByIdx(idx: number) { return this.fvbControl.objects[idx].funcVal; } - public getFunctionValueByName(name: string) { return this.fvbControl.objects.find(v => v.id == name)?.funcVal; } + public getFunctionValueByName(name: string) { return this.fvbControl.objects.find(v => v.id === name)?.funcVal; } // Really this is a stb::TFactory method public createObject(blockObj: TBlockObject): STBObject | null { @@ -1878,7 +1878,7 @@ export class TParse { data: file } - if (blockObj.type == BLOCK_TYPE_CONTROL) { + if (blockObj.type === BLOCK_TYPE_CONTROL) { this.control.setControlObject(blockObj); return true; } @@ -1918,14 +1918,14 @@ export class TParse { assert(file.magic === 'STB'); assert(version >= 1 && version <= 3); // As of Wind Waker, only versions 1-3 supported. TP seems to support <7, but untested. assert(targetVersion >= 2 && targetVersion <= 3); // As of Wind Waker, only version 2-3 is supported - assert(byteOrder == 0xFEFF); + assert(byteOrder === 0xFEFF); let byteIdx = file.offs; for (let i = 0; i < file.numChunks; i++) { const blockSize = file.view.getUint32(byteIdx + 0); const blockType = readString(file.buffer, byteIdx + 4, 4); - if (blockType == 'JFVB') { + if (blockType === 'JFVB') { this.fvbParse.parse(file.buffer.subarray(byteIdx + 8, blockSize - 8), flags) } else { this.parseBlockObject(new Reader(file.buffer, byteIdx), flags); diff --git a/src/Common/N64/RDP.ts b/src/Common/N64/RDP.ts index 3e9c5077d..d6f76e849 100644 --- a/src/Common/N64/RDP.ts +++ b/src/Common/N64/RDP.ts @@ -198,14 +198,14 @@ export function decodeCombineParams(w0: number, w1: number): CombineParams { } function colorCombinePassUsesT0(ccp: ColorCombinePass) { - return (ccp.a == CCMUX.TEXEL0) || (ccp.a == CCMUX.TEXEL0_A) || - (ccp.b == CCMUX.TEXEL0) || (ccp.b == CCMUX.TEXEL0_A) || - (ccp.c == CCMUX.TEXEL0) || (ccp.c == CCMUX.TEXEL0_A) || - (ccp.d == CCMUX.TEXEL0) || (ccp.d == CCMUX.TEXEL0_A); + return (ccp.a === CCMUX.TEXEL0) || (ccp.a === CCMUX.TEXEL0_A) || + (ccp.b === CCMUX.TEXEL0) || (ccp.b === CCMUX.TEXEL0_A) || + (ccp.c === CCMUX.TEXEL0) || (ccp.c === CCMUX.TEXEL0_A) || + (ccp.d === CCMUX.TEXEL0) || (ccp.d === CCMUX.TEXEL0_A); } function alphaCombinePassUsesT0(acp: AlphaCombinePass) { - return (acp.a == ACMUX.TEXEL0 || acp.b == ACMUX.TEXEL0 || acp.c == ACMUX.TEXEL0 || acp.d == ACMUX.TEXEL0); + return (acp.a === ACMUX.TEXEL0 || acp.b === ACMUX.TEXEL0 || acp.c === ACMUX.TEXEL0 || acp.d === ACMUX.TEXEL0); } export function combineParamsUsesT0(cp: CombineParams) { @@ -214,14 +214,14 @@ export function combineParamsUsesT0(cp: CombineParams) { } function colorCombinePassUsesT1(ccp: ColorCombinePass) { - return (ccp.a == CCMUX.TEXEL1) || (ccp.a == CCMUX.TEXEL1_A) || - (ccp.b == CCMUX.TEXEL1) || (ccp.b == CCMUX.TEXEL1_A) || - (ccp.c == CCMUX.TEXEL1) || (ccp.c == CCMUX.TEXEL1_A) || - (ccp.d == CCMUX.TEXEL1) || (ccp.d == CCMUX.TEXEL1_A); + return (ccp.a === CCMUX.TEXEL1) || (ccp.a === CCMUX.TEXEL1_A) || + (ccp.b === CCMUX.TEXEL1) || (ccp.b === CCMUX.TEXEL1_A) || + (ccp.c === CCMUX.TEXEL1) || (ccp.c === CCMUX.TEXEL1_A) || + (ccp.d === CCMUX.TEXEL1) || (ccp.d === CCMUX.TEXEL1_A); } function alphaCombinePassUsesT1(acp: AlphaCombinePass) { - return (acp.a == ACMUX.TEXEL1 || acp.b == ACMUX.TEXEL1 || acp.c == ACMUX.TEXEL1 || acp.d == ACMUX.TEXEL1); + return (acp.a === ACMUX.TEXEL1 || acp.b === ACMUX.TEXEL1 || acp.c === ACMUX.TEXEL1 || acp.d === ACMUX.TEXEL1); } export function combineParamsUsesT1(cp: CombineParams) { @@ -233,7 +233,7 @@ export function combineParamsUsesT1(cp: CombineParams) { export function combineParamsUseTexelsInSecondCycle(comb: CombineParams): boolean { for(let param of [comb.a1.a, comb.a1.b, comb.a1.c, comb.a1.d, comb.c1.a, comb.c1.b, comb.c1.c, comb.c1.d]) { // note that I'm using the CCMUX enum even though we're comparing against color and alpha - // (b/c in this case CCMUX.TEXEL0 == ACMUX.TEXEL0 and same for TEXEL1) + // (b/c in this case CCMUX.TEXEL0 === ACMUX.TEXEL0 and same for TEXEL1) // same principle applies to other methods if(param === CCMUX.TEXEL0 || param === CCMUX.TEXEL1) return true; diff --git a/src/Common/NW4R/lyt/Font.ts b/src/Common/NW4R/lyt/Font.ts index b4b5d39ca..208dd5fd1 100644 --- a/src/Common/NW4R/lyt/Font.ts +++ b/src/Common/NW4R/lyt/Font.ts @@ -181,7 +181,7 @@ export function parseBRFNT(buffer: NamedArrayBufferSlice): RFNT { const offset = view.getUint16(blockContentsOffs + 0x0C); for (let i = codeStart; i <= codeEnd; i++) cmap[i] = i - codeStart + offset; - } else if (kind == RFNTCMAPKind.Array) { + } else if (kind === RFNTCMAPKind.Array) { let tableIdx = blockContentsOffs + 0x0C; for (let i = codeStart; i <= codeEnd; i++, tableIdx += 0x02) cmap[i] = view.getUint16(tableIdx + 0x00); diff --git a/src/Common/PS2/GS.ts b/src/Common/PS2/GS.ts index 87aaf560b..d57366535 100644 --- a/src/Common/PS2/GS.ts +++ b/src/Common/PS2/GS.ts @@ -551,7 +551,7 @@ export function gsMemoryMapReadImagePSMT4_PSMCT32(pixels: Uint8Array, map: GSMem pixels[dstIdx + 0] = map.data[p + 0x00]; pixels[dstIdx + 1] = map.data[p + 0x01]; pixels[dstIdx + 2] = map.data[p + 0x02]; - const rawAlpha = alphaReg == -1 ? map.data[p + 0x03] : alphaReg; + const rawAlpha = alphaReg === -1 ? map.data[p + 0x03] : alphaReg; pixels[dstIdx + 3] = Math.min(0xFF, rawAlpha * 2); dstIdx += 0x04; @@ -577,7 +577,7 @@ export function gsMemoryMapReadImagePSMT8_PSMCT32(pixels: Uint8Array, map: GSMem pixels[dstIdx + 0] = map.data[p + 0x00]; pixels[dstIdx + 1] = map.data[p + 0x01]; pixels[dstIdx + 2] = map.data[p + 0x02]; - const rawAlpha = alphaReg == -1 ? map.data[p + 0x03] : alphaReg; + const rawAlpha = alphaReg === -1 ? map.data[p + 0x03] : alphaReg; pixels[dstIdx + 3] = Math.min(0xFF, rawAlpha * 2); dstIdx += 0x04; @@ -603,7 +603,7 @@ export function gsMemoryMapReadImagePSMT8H_PSMCT32(pixels: Uint8Array, map: GSMe pixels[dstIdx + 0] = map.data[p + 0x00]; pixels[dstIdx + 1] = map.data[p + 0x01]; pixels[dstIdx + 2] = map.data[p + 0x02]; - const rawAlpha = alphaReg == -1 ? map.data[p + 0x03] : alphaReg; + const rawAlpha = alphaReg === -1 ? map.data[p + 0x03] : alphaReg; pixels[dstIdx + 3] = Math.min(0xFF, rawAlpha * 2); dstIdx += 0x04; @@ -624,7 +624,7 @@ export function gsMemoryMapReadImagePSMT4HH_PSMCT32(pixels: Uint8Array, map: GSM pixels[dstIdx + 0] = map.data[p + 0x00]; pixels[dstIdx + 1] = map.data[p + 0x01]; pixels[dstIdx + 2] = map.data[p + 0x02]; - const rawAlpha = alphaReg == -1 ? map.data[p + 0x03] : alphaReg; + const rawAlpha = alphaReg === -1 ? map.data[p + 0x03] : alphaReg; pixels[dstIdx + 3] = Math.min(0xFF, rawAlpha * 2); dstIdx += 0x04; @@ -646,7 +646,7 @@ export function gsMemoryMapReadImagePSMT4HL_PSMCT32(pixels: Uint8Array, map: GSM pixels[dstIdx + 0] = map.data[p + 0x00]; pixels[dstIdx + 1] = map.data[p + 0x01]; pixels[dstIdx + 2] = map.data[p + 0x02]; - const rawAlpha = alphaReg == -1 ? map.data[p + 0x03] : alphaReg; + const rawAlpha = alphaReg === -1 ? map.data[p + 0x03] : alphaReg; pixels[dstIdx + 3] = Math.min(0xFF, rawAlpha * 2); dstIdx += 0x04; diff --git a/src/DarkSouls/dcx.ts b/src/DarkSouls/dcx.ts index 51d5bcd0a..8fb3b262f 100644 --- a/src/DarkSouls/dcx.ts +++ b/src/DarkSouls/dcx.ts @@ -8,24 +8,24 @@ import { assert, readString } from '../util.js'; export function decompressBuffer(buffer: ArrayBufferSlice): ArrayBufferSlice { const view = buffer.createDataView(); - assert(readString(buffer, 0x00, 0x04, false) == 'DCX\0'); - assert(view.getUint32(0x04, true) == 0x0100); - assert(view.getUint32(0x08, false) == 0x18); - assert(view.getUint32(0x0C, false) == 0x24); - assert(view.getUint32(0x10, false) == 0x24); - assert(view.getUint32(0x14, false) == 0x2C); - assert(readString(buffer, 0x18, 0x04, false) == 'DCS\0'); + assert(readString(buffer, 0x00, 0x04, false) === 'DCX\0'); + assert(view.getUint32(0x04, true) === 0x0100); + assert(view.getUint32(0x08, false) === 0x18); + assert(view.getUint32(0x0C, false) === 0x24); + assert(view.getUint32(0x10, false) === 0x24); + assert(view.getUint32(0x14, false) === 0x2C); + assert(readString(buffer, 0x18, 0x04, false) === 'DCS\0'); const uncompressedSize = view.getUint32(0x1C, false); const compressedSize = view.getUint32(0x20, false); - assert(readString(buffer, 0x24, 0x08, false) == 'DCP\0DFLT'); - assert(view.getUint32(0x2C, false) == 0x20); - assert(view.getUint32(0x30, true) == 0x09); - assert(view.getUint32(0x34, true) == 0x00); - assert(view.getUint32(0x38, true) == 0x00); - assert(view.getUint32(0x3C, true) == 0x00); - assert(view.getUint32(0x40, true) == 0x010100); - assert(readString(buffer, 0x44, 0x04, false) == 'DCA\0'); - assert(view.getUint32(0x48, false) == 0x08); + assert(readString(buffer, 0x24, 0x08, false) === 'DCP\0DFLT'); + assert(view.getUint32(0x2C, false) === 0x20); + assert(view.getUint32(0x30, true) === 0x09); + assert(view.getUint32(0x34, true) === 0x00); + assert(view.getUint32(0x38, true) === 0x00); + assert(view.getUint32(0x3C, true) === 0x00); + assert(view.getUint32(0x40, true) === 0x010100); + assert(readString(buffer, 0x44, 0x04, false) === 'DCA\0'); + assert(view.getUint32(0x48, false) === 0x08); const contents = buffer.subarray(0x4C, compressedSize); return Deflate.decompress(contents); } diff --git a/src/DarkSouls/flver.ts b/src/DarkSouls/flver.ts index 465a100c6..beb6cefa1 100644 --- a/src/DarkSouls/flver.ts +++ b/src/DarkSouls/flver.ts @@ -94,7 +94,7 @@ export interface FLVER { export function parse(buffer: ArrayBufferSlice): FLVER { const view = buffer.createDataView(); - assert(readString(buffer, 0x0, 0x06, false) == 'FLVER\0'); + assert(readString(buffer, 0x0, 0x06, false) === 'FLVER\0'); const endianMarker = readString(buffer, 0x06, 0x02, false); assert(endianMarker === 'B\0' || endianMarker === 'L\0'); diff --git a/src/DarkSouls/msb.ts b/src/DarkSouls/msb.ts index 6c1e51b93..861c2987e 100644 --- a/src/DarkSouls/msb.ts +++ b/src/DarkSouls/msb.ts @@ -75,8 +75,8 @@ export function parse(buffer: ArrayBufferSlice, mapID: string): MSB { let paramTableIdx = 0x00; - assert(view.getUint32(paramTableIdx + 0x00, true) == 0); - assert(readString(buffer, view.getUint32(paramTableIdx + 0x04, true), -1, true) == 'MODEL_PARAM_ST'); + assert(view.getUint32(paramTableIdx + 0x00, true) === 0); + assert(readString(buffer, view.getUint32(paramTableIdx + 0x04, true), -1, true) === 'MODEL_PARAM_ST'); const modelTableCount = view.getUint32(paramTableIdx + 0x08, true) - 1; const areaID = mapID.slice(0, 3); // "m10" @@ -109,8 +109,8 @@ export function parse(buffer: ArrayBufferSlice, mapID: string): MSB { // Chain to next chunk paramTableIdx = view.getUint32(modelTableIdx + 0x00, true); - assert(view.getUint32(paramTableIdx + 0x00, true) == 0); - assert(readString(buffer, view.getUint32(paramTableIdx + 0x04, true), -1, true) == 'EVENT_PARAM_ST'); + assert(view.getUint32(paramTableIdx + 0x00, true) === 0); + assert(readString(buffer, view.getUint32(paramTableIdx + 0x04, true), -1, true) === 'EVENT_PARAM_ST'); const eventTableCount = view.getUint32(paramTableIdx + 0x08, true) - 1; let eventTableIdx = paramTableIdx + 0x0C; @@ -122,8 +122,8 @@ export function parse(buffer: ArrayBufferSlice, mapID: string): MSB { // Chain to next chunk. paramTableIdx = view.getUint32(eventTableIdx + 0x00, true); - assert(view.getUint32(paramTableIdx + 0x00, true) == 0); - assert(readString(buffer, view.getUint32(paramTableIdx + 0x04, true), -1, true) == 'POINT_PARAM_ST'); + assert(view.getUint32(paramTableIdx + 0x00, true) === 0); + assert(readString(buffer, view.getUint32(paramTableIdx + 0x04, true), -1, true) === 'POINT_PARAM_ST'); const pointTableCount = view.getUint32(paramTableIdx + 0x08, true) - 1; let pointTableIdx = paramTableIdx + 0x0C; @@ -135,8 +135,8 @@ export function parse(buffer: ArrayBufferSlice, mapID: string): MSB { // Chain to next chunk. paramTableIdx = view.getUint32(pointTableIdx + 0x00, true); - assert(view.getUint32(paramTableIdx + 0x00, true) == 0); - assert(readString(buffer, view.getUint32(paramTableIdx + 0x04, true), -1, true) == 'PARTS_PARAM_ST'); + assert(view.getUint32(paramTableIdx + 0x00, true) === 0); + assert(readString(buffer, view.getUint32(paramTableIdx + 0x04, true), -1, true) === 'PARTS_PARAM_ST'); const partsTableCount = view.getUint32(paramTableIdx + 0x08, true) - 1; function readPart(offs: number): Part { diff --git a/src/DarkSouls/tools/bhd5.ts b/src/DarkSouls/tools/bhd5.ts index 97c108930..70283c650 100644 --- a/src/DarkSouls/tools/bhd5.ts +++ b/src/DarkSouls/tools/bhd5.ts @@ -14,9 +14,9 @@ export interface BHD5 { export function parse(buffer: ArrayBufferSlice): BHD5 { const view = buffer.createDataView(); - assert(readString(buffer, 0x00, 0x04) == 'BHD5'); - assert(view.getUint32(0x04, true) == 0x000000FF); - assert(view.getUint32(0x08, true) == 0x00000001); + assert(readString(buffer, 0x00, 0x04) === 'BHD5'); + assert(view.getUint32(0x04, true) === 0x000000FF); + assert(view.getUint32(0x08, true) === 0x00000001); const unk1 = view.getUint32(0x0C, true); // Seems related to fize size? const groupTableCount = view.getUint32(0x10, true); @@ -43,7 +43,7 @@ export function parse(buffer: ArrayBufferSlice): BHD5 { recordTableIdx += 0x04; const byteOffset = view.getUint32(recordTableIdx, true); recordTableIdx += 0x04; - assert (view.getUint32(recordTableIdx, true) == 0x00000000); + assert (view.getUint32(recordTableIdx, true) === 0x00000000); recordTableIdx += 0x04; const fileRecord: FileRecord = { nameHash, byteOffset, byteSize }; diff --git a/src/DarkSouls/tpf.ts b/src/DarkSouls/tpf.ts index fef720f77..bce6e4db1 100644 --- a/src/DarkSouls/tpf.ts +++ b/src/DarkSouls/tpf.ts @@ -10,7 +10,7 @@ export interface TPF { export function parse(buffer: ArrayBufferSlice): TPF { const view = buffer.createDataView(); - assert(readString(buffer, 0x00, 0x04, false) == 'TPF\0'); + assert(readString(buffer, 0x00, 0x04, false) === 'TPF\0'); const count = view.getUint32(0x08, true); diff --git a/src/DataFetcher.ts b/src/DataFetcher.ts index f79afe472..a38312a7a 100644 --- a/src/DataFetcher.ts +++ b/src/DataFetcher.ts @@ -356,7 +356,7 @@ export class DataFetcher { return; } - if (this.debugDisplay == null) { + if (this.debugDisplay === null) { this.debugDisplay = document.createElement('div'); this.debugDisplay.style.position = 'absolute'; this.debugDisplay.style.bottom = '16px'; diff --git a/src/DiddyKongRacing/DkrAnimationTrack.ts b/src/DiddyKongRacing/DkrAnimationTrack.ts index faf2598cd..671378a22 100644 --- a/src/DiddyKongRacing/DkrAnimationTrack.ts +++ b/src/DiddyKongRacing/DkrAnimationTrack.ts @@ -265,7 +265,7 @@ export class DkrAnimationTrack { let spawnActorId = this.nodes[0].getProperties().objectToSpawn; assert(spawnActorId >= 0); const lastProperties = this.nodes[this.nodes.length - 1].getProperties(); - if (lastProperties.gotoNode == 0x00) { + if (lastProperties.gotoNode === 0x00) { this.doesLoop = true; this.isLoopConnected = true; } else if (lastProperties.pauseFrameCount >= 0) { @@ -344,7 +344,7 @@ export class DkrAnimationTrack { } } - if(curNodeIndex != lastNodeIndex) { + if (curNodeIndex !== lastNodeIndex) { this.fadeCheck(curNodeIndex); this.ObjAnimIndexCheck(curNodeIndex); const currentProperties = this.getCurrentNode(curNodeIndex).getProperties(); @@ -368,7 +368,7 @@ export class DkrAnimationTrack { const stopNode = this.doesLoop ? this.nodes.length : this.nodes.length - 1; if(curNodeIndex >= stopNode) { this.fadeCheck(curNodeIndex); - if(this.currentAlpha != this.points[this.points.length - 1].alpha) { + if (this.currentAlpha !== this.points[this.points.length - 1].alpha) { this.points[this.points.length - 1].alpha = this.currentAlpha; } //console.log(this.actorName); @@ -508,11 +508,11 @@ export class DkrAnimationTrack { deltaZ = pos[2] - curPos[2]; let dist = Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2) + Math.pow(deltaZ, 2)) / speedMult; - if(dist != 0.0) { + if (dist !== 0.0) { speeds.objSpeed *= speeds.nodeSpeed / dist; } } - } while(++i != 2); + } while (++i !== 2); curPos[0] += deltaX; curPos[1] += deltaY; @@ -802,11 +802,11 @@ export class DkrAnimationTracks { if(!this.channels[key].hasAnimationCamera()) { continue; } - if(key == '1') { + if(key === '1') { hasFlyby = trackSelectStrings.length; } let indexStr = parseInt(key).toString(16).toUpperCase(); - if(indexStr.length == 1) { + if(indexStr.length === 1) { indexStr = '0' + indexStr; } let trackName; diff --git a/src/DiddyKongRacing/DkrDrawCall.ts b/src/DiddyKongRacing/DkrDrawCall.ts index 56908f684..6307bfa61 100644 --- a/src/DiddyKongRacing/DkrDrawCall.ts +++ b/src/DiddyKongRacing/DkrDrawCall.ts @@ -63,7 +63,7 @@ export class DkrDrawCall { } public addTriangleBatch(triBatch: DkrTriangleBatch): void { - if(this.flags == undefined || this.flags == null) { + if(this.flags === undefined || this.flags === null) { this.flags = triBatch.getFlags(); } this.vertices = this.vertices.concat(triBatch.getVertices()); @@ -183,7 +183,7 @@ export class DkrDrawCall { } else { texLayer = GfxRendererLayer.TRANSLUCENT; } - if(texLayer == GfxRendererLayer.ALPHA_TEST) { + if(texLayer === GfxRendererLayer.ALPHA_TEST) { texLayer = GfxRendererLayer.TRANSLUCENT; renderInst.setMegaStateFlags(setAttachmentStateSimple({ depthWrite: true @@ -192,7 +192,7 @@ export class DkrDrawCall { blendSrcFactor: GfxBlendFactor.SrcAlpha, blendDstFactor: GfxBlendFactor.OneMinusSrcAlpha, })); - } else if(texLayer == GfxRendererLayer.TRANSLUCENT) { + } else if(texLayer === GfxRendererLayer.TRANSLUCENT) { renderInst.setMegaStateFlags(setAttachmentStateSimple({ depthWrite: !!(this.flags & FLAG_ENABLE_DEPTH_WRITE), }, { diff --git a/src/DiddyKongRacing/DkrLevelObjectMap.ts b/src/DiddyKongRacing/DkrLevelObjectMap.ts index 568a1a762..354ff06db 100644 --- a/src/DiddyKongRacing/DkrLevelObjectMap.ts +++ b/src/DiddyKongRacing/DkrLevelObjectMap.ts @@ -88,7 +88,7 @@ export class DkrLevelObjectMap { continue; } - if(obj.getModelType() == MODEL_TYPE_3D_MODEL) { + if(obj.getModelType() === MODEL_TYPE_3D_MODEL) { const model = obj.getModel(); if(!!model) { const params: DkrDrawCallParams = { diff --git a/src/DiddyKongRacing/DkrObject.ts b/src/DiddyKongRacing/DkrObject.ts index c246fe8ff..d8f579bb6 100644 --- a/src/DiddyKongRacing/DkrObject.ts +++ b/src/DiddyKongRacing/DkrObject.ts @@ -232,7 +232,7 @@ export class DkrObject { if(!DkrControlGlobals.SHOW_DEV_OBJECTS.on && this.isDeveloperObject) { return vec4DontShowObject; } - if(this.name == 'GoldCoin' && DkrControlGlobals.DARKEN_ADV2_COINS.on) { + if(this.name === 'GoldCoin' && DkrControlGlobals.DARKEN_ADV2_COINS.on) { return vec4.fromValues(0.4, 0.4, 0.4, 1.0); } return this.spriteColor; @@ -291,15 +291,15 @@ export class DkrObject { public update(deltaTime: number): void { const delta = deltaTime / 1000; let updateMatrix = false; - if(this.angularSpeed[0] != 0) { + if(this.angularSpeed[0] !== 0) { this.rotation[0] += this.angularSpeed[0] * delta; updateMatrix = true; } - if(this.angularSpeed[1] != 0) { + if(this.angularSpeed[1] !== 0) { this.rotation[1] += this.angularSpeed[1] * delta; updateMatrix = true; } - if(this.angularSpeed[2] != 0) { + if(this.angularSpeed[2] !== 0) { this.rotation[2] += this.angularSpeed[2] * delta; updateMatrix = true; } @@ -409,7 +409,7 @@ export class DkrObject { const numberBalloonsToOpen = view.getUint8(0xD); this.properties.numberToOpen = numberBalloonsToOpen; this.modelScale *= view.getUint8(0x12) / 64.0; - if(this.name == 'LevelDoor' || this.name == 'WorldGate') { + if(this.name === 'LevelDoor' || this.name === 'WorldGate') { this.texFrameOverride.set(1016, numberBalloonsToOpen % 10); // Tex #1016 = Ones place (0 to 9) this.texFrameOverride.set(1017, Math.floor(numberBalloonsToOpen / 10) - 1); // Tex #1017 = Tens place (1 to 8) } @@ -557,7 +557,7 @@ export class DkrObject { gotoNode: view.getUint8(0x1D), channel: view.getUint8(0x21), pauseFrameCount: view.getInt8(0x24), - specialHide: view.getUint8(0x26) != 0, // Needs a better name. + specialHide: view.getUint8(0x26) !== 0, // Needs a better name. messageId: view.getUint8(0x27), fadeAlpha: view.getUint8(0x2B), nextAnim: view.getUint8(0x2C), diff --git a/src/DiddyKongRacing/DkrObjectAnimation.ts b/src/DiddyKongRacing/DkrObjectAnimation.ts index 2b7de348c..5e89ef919 100644 --- a/src/DiddyKongRacing/DkrObjectAnimation.ts +++ b/src/DiddyKongRacing/DkrObjectAnimation.ts @@ -100,7 +100,7 @@ export class DkrObjectAnimation { case 1: { if(timeProgress >= this.duration) { - if((Math.floor(timeProgress / this.duration) % 2) == 1) { + if((Math.floor(timeProgress / this.duration) % 2) === 1) { timeProgress %= this.duration; timeProgress = this.duration - timeProgress; } else { diff --git a/src/DiddyKongRacing/DkrTexture.ts b/src/DiddyKongRacing/DkrTexture.ts index 41f9ff6c1..4f40f7132 100644 --- a/src/DiddyKongRacing/DkrTexture.ts +++ b/src/DiddyKongRacing/DkrTexture.ts @@ -112,7 +112,7 @@ export class DkrTexture { let alpha = this.pixels[index + 3]; if (alpha > 0 && alpha < 255) { return GfxRendererLayer.TRANSLUCENT; - } else if (isOpaque && alpha == 0) { + } else if (isOpaque && alpha === 0) { isOpaque = false; } } diff --git a/src/DonkeyKong64/scenes.ts b/src/DonkeyKong64/scenes.ts index 95c183a48..6d41fb813 100644 --- a/src/DonkeyKong64/scenes.ts +++ b/src/DonkeyKong64/scenes.ts @@ -612,7 +612,7 @@ export class Map { if (command === 0x00) { snoopPresent = true; const sectionID = view.getUint32(currf3dexOffset + 0x04, false); - const currSection = this.sections.find((section) => section.meshID == sectionID); + const currSection = this.sections.find((section) => section.meshID === sectionID); if (currSection !== undefined) { this.displayLists.push({ diff --git a/src/FinalFantasyX/bin.ts b/src/FinalFantasyX/bin.ts index 489cc015d..6d4d6e122 100644 --- a/src/FinalFantasyX/bin.ts +++ b/src/FinalFantasyX/bin.ts @@ -618,7 +618,7 @@ function parseLevelModel(view: DataView, offs: number, gsMap: GSMemoryMap, textu } else if (cmd === 0x00 || cmd === 0x10 || cmd === 0x11) { // NOP and FLUSH commands can be ignored } else if (cmd === 0x01) { // CYCLE - assert(imm == 0x0101); // equal CL and WL, can ignore + assert(imm === 0x0101); // equal CL and WL, can ignore } else if (cmd === 0x05) { // STMOD assert(imm === 0); // normal, no addition } else if (cmd === 0x30) { // STROW diff --git a/src/FinalFantasyX/script.ts b/src/FinalFantasyX/script.ts index e055cc54a..5e3254f9e 100644 --- a/src/FinalFantasyX/script.ts +++ b/src/FinalFantasyX/script.ts @@ -692,7 +692,7 @@ class Controller { } public finishThread(cutoff: number, runMain: boolean): void { - if (this.currSignal != null) { + if (this.currSignal !== null) { if (this.currSignal.type === SignalType.ON_END) this.script.ack(this.currSignal); this.deleteOwnSignal(this.currSignal); @@ -1117,11 +1117,11 @@ export class EventScript { } else if (op === Opcode.EQ) { const a = c.stack.pop(); const b = c.stack.pop(); - c.stack.push(a == b ? 1 : 0); + c.stack.push(a === b ? 1 : 0); } else if (op === Opcode.NEQ) { const a = c.stack.pop(); const b = c.stack.pop(); - c.stack.push(a != b ? 1 : 0); + c.stack.push(a !== b ? 1 : 0); } else if (op === Opcode.LT || op === Opcode.LT_2) { const a = c.stack.pop(); const b = c.stack.pop(); @@ -1176,7 +1176,7 @@ export class EventScript { c.stack.push(b % a); } else if (op === Opcode.NOT_LOGIC) { const a = c.stack.pop(); - c.stack.push(a == 0 ? 1 : 0); + c.stack.push(a === 0 ? 1 : 0); } else if (op === Opcode.NEG) { const a = c.stack.pop(); c.stack.push(-a); diff --git a/src/Glover/actor.ts b/src/Glover/actor.ts index 8e8c48b48..1a9cf0a2b 100644 --- a/src/Glover/actor.ts +++ b/src/Glover/actor.ts @@ -38,7 +38,7 @@ interface ActorKeyframeSet { function keyframeLerp(dst: vec3, cur: GloverObjbank.AffineFrame, next: GloverObjbank.AffineFrame, t: number): vec3 { let duration = next.t - cur.t - if (duration == 0) { + if (duration === 0) { t = 1 } else { t = (t - cur.t) / duration; @@ -53,7 +53,7 @@ function keyframeLerp(dst: vec3, cur: GloverObjbank.AffineFrame, next: GloverObj const slerpScratchVec4 = vec4.create(); function keyframeSlerp(dst: vec4, cur: GloverObjbank.AffineFrame, next: GloverObjbank.AffineFrame, t: number): vec4 { let duration = next.t - cur.t - if (duration == 0) { + if (duration === 0) { t = 1 } else { t = (t - cur.t) / duration; @@ -182,7 +182,7 @@ export class ActorMeshNode { if (nextKeyframes.scale >= this.mesh.numScale) { nextKeyframes.scale = this.keyframeState.scale; } - if (this.keyframeState.scale == startIdx) { + if (this.keyframeState.scale === startIdx) { // TODO: confirm this is the right behavior: this.keyframeState.scale = this.mesh.scale.length - 1; nextKeyframes.scale = this.keyframeState.scale; @@ -199,7 +199,7 @@ export class ActorMeshNode { if (nextKeyframes.translation >= this.mesh.numTranslation) { nextKeyframes.translation = this.keyframeState.translation; } - if (this.keyframeState.translation == startIdx) { + if (this.keyframeState.translation === startIdx) { // TODO: confirm this is the right behavior: this.keyframeState.translation = this.mesh.translation.length - 1; nextKeyframes.translation = this.keyframeState.translation; @@ -216,7 +216,7 @@ export class ActorMeshNode { if (nextKeyframes.rotation >= this.mesh.numRotation) { nextKeyframes.rotation = this.keyframeState.rotation; } - if (this.keyframeState.rotation == startIdx) { + if (this.keyframeState.rotation === startIdx) { // TODO: confirm this is the right behavior: this.keyframeState.rotation = this.mesh.rotation.length - 1; nextKeyframes.rotation = this.keyframeState.rotation; @@ -352,8 +352,8 @@ export class GloverActorRenderer implements Shadows.Collidable, Shadows.ShadowCa blendDstFactor: GfxBlendFactor.OneMinusSrcAlpha, }); - const overlay = (this.actorObject.mesh.renderMode & 0x80) != 0; - const xlu = (this.actorObject.mesh.renderMode & 0x2) != 0; + const overlay = (this.actorObject.mesh.renderMode & 0x80) !== 0; + const xlu = (this.actorObject.mesh.renderMode & 0x2) !== 0; this.rootMesh = new ActorMeshNode(device, cache, segments, textures, sceneLights, overlay, actorObject.objId, actorObject.mesh) @@ -372,7 +372,7 @@ export class GloverActorRenderer implements Shadows.Collidable, Shadows.ShadowCa this.allocateLightingBuffer = false; this.rootMesh.forEachMesh((node) => { - if ((node.mesh.renderMode & 0x8) == 0) { + if ((node.mesh.renderMode & 0x8) === 0) { this.allocateLightingBuffer = true; } }) @@ -387,7 +387,7 @@ export class GloverActorRenderer implements Shadows.Collidable, Shadows.ShadowCa // Hardcoded fix: // Force crysbk to render behind crystf - if (this.actorObject.objId == 0x530E329C) { + if (this.actorObject.objId === 0x530E329C) { this.sortKey = makeSortKey(GfxRendererLayer.TRANSLUCENT + Render.GloverRendererLayer.OPAQUE); } } @@ -613,8 +613,8 @@ class GloverMeshRenderer { { const buffer = meshData._io.buffer; const rspState = new Render.GloverRSPState(segments, textures); - const xlu = (this.meshData.renderMode & 0x2) != 0; - const decals = (this.meshData.renderMode & 0x4) != 0; + const xlu = (this.meshData.renderMode & 0x2) !== 0; + const decals = (this.meshData.renderMode & 0x4) !== 0; this.id = meshData.id; @@ -623,7 +623,7 @@ class GloverMeshRenderer { rspState.gSPSetGeometryMode(F3DEX.RSP_Geometry.G_SHADE | F3DEX.RSP_Geometry.G_SHADING_SMOOTH); Render.setRenderMode(rspState, decals, xlu, overlay, meshData.alpha/255); - if ((this.meshData.renderMode & 0x8) == 0) { + if ((this.meshData.renderMode & 0x8) === 0) { rspState.gSPSetGeometryMode(F3DEX.RSP_Geometry.G_LIGHTING); } else { rspState.gSPClearGeometryMode(F3DEX.RSP_Geometry.G_LIGHTING); @@ -635,7 +635,7 @@ class GloverMeshRenderer { rspState.gSPSetGeometryMode(F3DEX.RSP_Geometry.G_CULL_BACK); } try { - if (meshData.displayListPtr != 0) { + if (meshData.displayListPtr !== 0) { const displayListOffs = meshData.displayListPtr & 0x00FFFFFF; rspState.gSPTexture(true, 0, 5, 0.999985 * 0x10000, 0.999985 * 0x10000); @@ -684,19 +684,19 @@ class GloverMeshRenderer { if (this.meshData.numSprites > 0) { for (let spriteData of this.meshData.sprites) { const sprite = new Sprite.GloverSpriteRenderer( - device, cache, textures, [spriteData.textureId], this.meshData.alpha != 0xFF); + device, cache, textures, [spriteData.textureId], this.meshData.alpha !== 0xFF); const spriteMatrix = mat4.create(); mat4.translate(spriteMatrix, spriteMatrix, [spriteData.x, spriteData.y, spriteData.z]); mat4.scale(spriteMatrix, spriteMatrix, [spriteData.width/3, spriteData.height/3, 1]); this.sprites.push(sprite); this.spriteMatrices.push(spriteMatrix); - // if ((spriteData.flags & 0x8) == 0) { + // if ((spriteData.flags & 0x8) === 0) { // TODO: weird special-case 0x10 sprite scaling: // spriteData.flags |= 0x8; - // if (spriteData->tex->width == 0x10) { + // if (spriteData->tex->width === 0x10) { // sprite.width *= 2; // } - // if (spriteData->tex->height == 0x10) { + // if (spriteData->tex->height === 0x10) { // sprite.height *= 2; // } // } @@ -720,14 +720,14 @@ class GloverMeshRenderer { let drawCall = rspState._newDrawCall(); drawCall.dynamicGeometry = true; - if ((texFile.flags & 4) != 0) { + if ((texFile.flags & 4) !== 0) { drawCall.dynamicTextures.add(texFile.id); } drawCall.textureIndices.push(Render.loadRspTexture(rspState, this.textures, textureId)); for (let faceIdx = 0; faceIdx < geo.numFaces; faceIdx++) { - if (geo.textureIds[faceIdx] != textureId) { + if (geo.textureIds[faceIdx] !== textureId) { continue; } drawCall.vertices.push( @@ -946,7 +946,7 @@ export class GloverBlurRenderer { v.c0 = 0xC8; v.c1 = 0xC8; v.c2 = 0xC8; - v.a = ((x & 1) == 0) ? this.bottomAlpha : this.topAlpha; + v.a = ((x & 1) === 0) ? this.bottomAlpha : this.topAlpha; this.vertexPool.push(v); } @@ -975,7 +975,7 @@ export class GloverBlurRenderer { private decayVertices() { for (let idx = 0; idx < this.vertexPool.length; idx += 1) { - const decay = ((idx & 1) == 0) ? this.bottomAlphaDecay : this.topAlphaDecay; + const decay = ((idx & 1) === 0) ? this.bottomAlphaDecay : this.topAlphaDecay; const vertex = this.vertexPool[idx]; if (vertex.a < .008) { vertex.a = 0; @@ -995,7 +995,7 @@ export class GloverBlurRenderer { const len = this.vertexPool.length; let cursor = (this.vertexPoolWritePtr + 2) % len; - while (cursor != this.vertexPoolWritePtr) { + while (cursor !== this.vertexPoolWritePtr) { if (!all) { if (this.vertexPool[(cursor+2)%len].a < 0.008 && @@ -1237,23 +1237,23 @@ export class GloverElectricityRenderer implements Render.GenericRenderable { let v0 = this.vertexPool[x*2]; let v1 = this.vertexPool[x*2+1]; - if (this.randStyle == ElectricityRandStyle.Straight) { + if (this.randStyle === ElectricityRandStyle.Straight) { vec3.set(rndPoint, Math.floor(Math.random() * rndMax) - rndMax / 2, Math.floor(Math.random() * rndMax) - rndMax / 2, Math.floor(Math.random() * rndMax) - rndMax / 2); - } else if (this.randStyle == ElectricityRandStyle.CurveUp) { + } else if (this.randStyle === ElectricityRandStyle.CurveUp) { vec3.set(rndPoint, Math.floor(Math.random() * rndMax), Math.floor(Math.random() * rndMax), Math.floor(Math.random() * rndMax)); - } else if (this.randStyle == ElectricityRandStyle.CurveDown) { + } else if (this.randStyle === ElectricityRandStyle.CurveDown) { vec3.set(rndPoint, Math.floor(Math.random() * rndMax), Math.floor(Math.random() * rndMax), Math.floor(Math.random() * rndMax)); } - if (x == 1 || x == this.numSegments - 2) { + if (x === 1 || x === this.numSegments - 2) { rndPoint[0] *= 0.5; rndPoint[1] *= 0.5; rndPoint[2] *= 0.5; diff --git a/src/Glover/bullets.ts b/src/Glover/bullets.ts index 585b16c0b..282dce0fa 100644 --- a/src/Glover/bullets.ts +++ b/src/Glover/bullets.ts @@ -265,8 +265,8 @@ export class Bullet { } if ((params.actorFlags & 1) !== 0) { - const gravAccel = (params.actorFlags & 0x40) == 0 ? 1.2 : 0.6; - const terminalVelocity = (params.actorFlags & 0x1000000) == 0 ? -15 : -100000; + const gravAccel = (params.actorFlags & 0x40) === 0 ? 1.2 : 0.6; + const terminalVelocity = (params.actorFlags & 0x1000000) === 0 ? -15 : -100000; this.velocity[1] = Math.max(this.velocity[1] - gravAccel, terminalVelocity); } @@ -279,7 +279,7 @@ export class Bullet { // (trailParticle->billboard).color.r = (&DAT_801f19c4)[((char)bullet->idx_0x162 + 1) * 8]; // (trailParticle->billboard).color.g = (&DAT_801f19c5)[((char)bullet->idx_0x162 + 1) * 8]; // (trailParticle->billboard).color.b = (&DAT_801f19c6)[((char)bullet->idx_0x162 + 1) * 8]; - // if (bullet->bulletType == '\x1a') { + // if (bullet->bulletType === '\x1a') { // sVar3 = (trailParticle->billboard).width; // sVar4 = (trailParticle->billboard).height; // (trailParticle->billboard).width = (short)((int)sVar3 << 2) + sVar3; @@ -288,7 +288,7 @@ export class Bullet { // (trailParticle->billboard).startSize = (trailParticle->billboard).startSize * 5; // } // } - // if (bullet->bulletType == '\x02') { + // if (bullet->bulletType === '\x02') { // aPStack104[0].z = 0.0; // aPStack104[0].y = 0.0; // aPStack104[0].x = DAT_8010b510; @@ -301,7 +301,7 @@ export class Bullet { vec3.lerp(this.position, this.lastPosition, this.nextPosition, Math.min(1.0, this.lastFrameAdvance/(SRC_FRAME_TO_MS*1.1))); - if (this.lifetime == 0 && this.flipbooks.every((flipbook)=>!flipbook.playing)) { + if (this.lifetime === 0 && this.flipbooks.every((flipbook)=>!flipbook.playing)) { this.destruct(); this.active = false; } diff --git a/src/Glover/enemy.ts b/src/Glover/enemy.ts index 2d6816345..5d3f8d754 100644 --- a/src/Glover/enemy.ts +++ b/src/Glover/enemy.ts @@ -761,7 +761,7 @@ export class GloverEnemy implements GenericRenderable { return true; } - if ((instrFlags & 0x1) != 0) { + if ((instrFlags & 0x1) !== 0) { journeyVec[0] /= distXZ; journeyVec[2] /= distXZ; journeyVec[0] *= enemy_beh[this.enemyType].walkSpeed; @@ -773,7 +773,7 @@ export class GloverEnemy implements GenericRenderable { this.setXZVelocityBasedOnRotation(enemy_beh[this.enemyType].walkSpeed, enemy_beh[this.enemyType].maxVelocity); } - if ((instrFlags & 0x2) != 0) { + if ((instrFlags & 0x2) !== 0) { if ((enemy_beh[this.enemyType].actorFlags & 0x1000000) === 0) { const xz_speed = Math.sqrt(this.velocity[0]*this.velocity[0] + this.velocity[2]*this.velocity[2]); if (xz_speed >= enemy_beh[this.enemyType].maxVelocity) { @@ -788,7 +788,7 @@ export class GloverEnemy implements GenericRenderable { } } - if ((instrFlags & 0x2000) != 0) { + if ((instrFlags & 0x2000) !== 0) { const theta_diff = subtractAngles(this.dstEulers[1], this.nextEulers[1]) * enemy_roll_modulation[this.enemyType]; if (Math.abs(theta_diff) > 0.08) { this.dstEulers[2] = theta_diff; @@ -804,7 +804,7 @@ export class GloverEnemy implements GenericRenderable { assert(this.curInstr.params !== undefined); assert(this.curInstr.params.__type === "EnemyInstructionRandomWalk"); let chooseNewPoint = false; - if (this.curInstrExecCount == 0) { + if (this.curInstrExecCount === 0) { if ((this.curInstr.flags & 0x4000) === 0) { if (this.enemyType === EnemyType.yoofow) { this.actor.playSkeletalAnimation(0xd, false, false); @@ -862,42 +862,42 @@ export class GloverEnemy implements GenericRenderable { assert(this.curInstr.params !== undefined); assert(this.curInstr.params.__type === "EnemyInstructionRest"); - if (this.enemyType == EnemyType.hubchicken) { + if (this.enemyType === EnemyType.hubchicken) { // TODO: hack to let chicken swing, because the rest of this // is not properly implemented return; } - if (this.enemyType == EnemyType.dibber) { + if (this.enemyType === EnemyType.dibber) { vec3.scale(this.velocity, this.velocity, 0.5); } const restFlags = this.curInstr.params.flags; - if (this.curInstrExecCount == 0) { + if (this.curInstrExecCount === 0) { let queueAnim = false; - if ((restFlags & 2) == 0) { - if ((this.curInstr.flags & 0x4000) == 0) { - if ((restFlags & 4) == 0) { + if ((restFlags & 2) === 0) { + if ((this.curInstr.flags & 0x4000) === 0) { + if ((restFlags & 4) === 0) { queueAnim = false; } else { this.actor.isPlaying = false; queueAnim = true; } - this.actor.playSkeletalAnimation(5, this.curInstr.params.animStartPlaying != 0, queueAnim); + this.actor.playSkeletalAnimation(5, this.curInstr.params.animStartPlaying !== 0, queueAnim); } } else { - if ((restFlags & 4) != 0) { + if ((restFlags & 4) !== 0) { this.actor.isPlaying = false; queueAnim = true; } this.actor.playSkeletalAnimation(0xe, false, queueAnim); - if ((this.curInstr.flags & 0x4000) == 0) { + if ((this.curInstr.flags & 0x4000) === 0) { queueAnim = true; - this.actor.playSkeletalAnimation(5, this.curInstr.params.animStartPlaying != 0, queueAnim); + this.actor.playSkeletalAnimation(5, this.curInstr.params.animStartPlaying !== 0, queueAnim); } } } // TODO: - // if (((restFlags & 1) != 0) && this.curInstrExecCount < 5) { + // if (((restFlags & 1) !== 0) && this.curInstrExecCount < 5) { // spawnParticles_801b70f8(this.actor.pos,2,0.0,0.8); // } } @@ -934,8 +934,8 @@ export class GloverEnemy implements GenericRenderable { } case 'EnemyInstructionDash': { if (this.curInstrExecCount === 0) { - if ((this.curInstr.flags & 0x40000) == 0) { - if ((this.curInstr.flags & 0x4000) == 0) { + if ((this.curInstr.flags & 0x40000) === 0) { + if ((this.curInstr.flags & 0x4000) === 0) { this.actor.playSkeletalAnimation(0xd, true, false); this.actor.playSkeletalAnimation(0xf, true, true); } @@ -944,7 +944,7 @@ export class GloverEnemy implements GenericRenderable { this.actor.playSkeletalAnimation(9, true, true); } } - if ((this.curInstr.flags & 0x80000) === 0 || this.actor.currentAnimIdx != 0xd) { + if ((this.curInstr.flags & 0x80000) === 0 || this.actor.currentAnimIdx !== 0xd) { advanceInstr = this.walkTo( [instrParams.destinationX, instrParams.destinationY, instrParams.destinationZ], instrParams.velMagnitude, @@ -962,7 +962,7 @@ export class GloverEnemy implements GenericRenderable { // TODO: this is a hack to keep dibbers from flipping out. // figure out why, in game, they don't need this: // TODO: even with this, a dibber near the beginning of PH2 flips out. investigate - if (this.curInstrExecCount == 0) { + if (this.curInstrExecCount === 0) { vec3.zero(this.velocity); } advanceInstr = this.instrTurn(); @@ -981,19 +981,19 @@ export class GloverEnemy implements GenericRenderable { } case 'EnemyInstructionPlayAnimation': { - if (this.curInstrExecCount == 0) { + if (this.curInstrExecCount === 0) { // TODO: - // if (((enemy->curInstruction).flags & INSTR_FLAG_SLOW_DOWN_CLOSE_TO_DESTINATION) != 0) { + // if (((enemy->curInstruction).flags & INSTR_FLAG_SLOW_DOWN_CLOSE_TO_DESTINATION) !== 0) { // animReset_80133b9c(&enemy->actor); // } let animIdx = 0; if (instrParams.animIdx1 < 0) { - if ((this.curInstr.flags & 0x2) != 0) { + if ((this.curInstr.flags & 0x2) !== 0) { this.actor.isPlaying = false; } animIdx = instrParams.animIdx2; } else { - if ((this.curInstr.flags & 0x2) != 0) { + if ((this.curInstr.flags & 0x2) !== 0) { this.actor.isPlaying = false; } animIdx = instrParams.animIdx1 + 10; @@ -1025,7 +1025,7 @@ export class GloverEnemy implements GenericRenderable { if (this.curInstrLifetime > 0) { this.curInstrLifetime -= 1; } - if (this.curInstrLifetime == 0 && !advanceInstr) { + if (this.curInstrLifetime === 0 && !advanceInstr) { // TODO: if guard is a hack for incomplete fumble ai if (this.enemyType !== EnemyType.fumble) { this.curInstrIdx++ @@ -1096,8 +1096,8 @@ export class GloverEnemy implements GenericRenderable { if ((beh.actorFlags & 1) !== 0) { // TODO: need floor collision, first: - // const gravAccel = (beh.actorFlags & 0x40) == 0 ? 1.2 : 0.6; - // const terminalVelocity = (beh.actorFlags & 0x1000000) == 0 ? -15 : -100000; + // const gravAccel = (beh.actorFlags & 0x40) === 0 ? 1.2 : 0.6; + // const terminalVelocity = (beh.actorFlags & 0x1000000) === 0 ? -15 : -100000; // this.velocity[1] = Math.max(this.velocity[1] - gravAccel, terminalVelocity); vec3.scale(this.velocity, this.velocity, Math.max(0, beh.decel0x18)); diff --git a/src/Glover/fla2.ts b/src/Glover/fla2.ts index 25ee924d5..ae1f33621 100644 --- a/src/Glover/fla2.ts +++ b/src/Glover/fla2.ts @@ -21,7 +21,7 @@ export var decompress = function (buffer: ArrayBufferSlice, srcOffs: number = 0) for (let i = 0; i < 8; i++) { const cmd = cmd_chunk & (0x80 >> i); - if (cmd == 0) { + if (cmd === 0) { // New data uncompressed_data[bytes_written] = data[data_cursor]; window[window_cursor] = data[data_cursor]; @@ -32,8 +32,8 @@ export var decompress = function (buffer: ArrayBufferSlice, srcOffs: number = 0) } else { // Backreference - if (data[data_cursor] == 0 && data[data_cursor + 1] == 0) { - assert(uncompressed_length == bytes_written); + if (data[data_cursor] === 0 && data[data_cursor + 1] === 0) { + assert(uncompressed_length === bytes_written); return new ArrayBufferSlice(uncompressed_data.buffer); } @@ -60,7 +60,7 @@ export var decompress = function (buffer: ArrayBufferSlice, srcOffs: number = 0) } } - assert(uncompressed_length == bytes_written); + assert(uncompressed_length === bytes_written); return new ArrayBufferSlice(uncompressed_data.buffer) } diff --git a/src/Glover/particles.ts b/src/Glover/particles.ts index eff79f09e..c7f9ae2c9 100644 --- a/src/Glover/particles.ts +++ b/src/Glover/particles.ts @@ -646,8 +646,8 @@ export class Particle { vec3.scale(this.velocity, this.velocity, params.friction); if ((params.actorFlags & 1) !== 0) { - const gravAccel = (params.actorFlags & 0x40) == 0 ? 1.2 : 0.6; - const terminalVelocity = (params.actorFlags & 0x1000000) == 0 ? -15 : -100000; + const gravAccel = (params.actorFlags & 0x40) === 0 ? 1.2 : 0.6; + const terminalVelocity = (params.actorFlags & 0x1000000) === 0 ? -15 : -100000; this.velocity[1] = Math.max(this.velocity[1] - gravAccel, terminalVelocity); } @@ -784,7 +784,7 @@ export class MeshSparkle implements GenericRenderable { this.frameCount = 0; const face = this.geo.faces[Math.floor(Math.random()*this.geo.numFaces)]; const vertRnd = Math.floor(Math.random()*3); - const vertIdx = vertRnd == 0 ? face.v0 : vertRnd == 1 ? face.v1 : face.v2; + const vertIdx = vertRnd === 0 ? face.v0 : vertRnd === 1 ? face.v1 : face.v2; const vert = this.geo.vertices[vertIdx]; const origin = MeshSparkle.positionScratch1; diff --git a/src/Glover/render.ts b/src/Glover/render.ts index a352af952..a58f2ef47 100644 --- a/src/Glover/render.ts +++ b/src/Glover/render.ts @@ -272,18 +272,18 @@ export class GloverRSPState implements F3DEX.RSPStateInterface { public gSPModifyVertex(vtx: number, where: number, val: number): void { assert(vtx < this.vertexCache.length); const vertex = this.vertexCache[vtx]; - if (where == F3DEX.MODIFYVTX_Locations.G_MWO_POINT_RGBA) { + if (where === F3DEX.MODIFYVTX_Locations.G_MWO_POINT_RGBA) { vertex.c0 = ((val >>> 24) & 0xFF) / 0xFF; vertex.c1 = ((val >>> 16) & 0xFF) / 0xFF; vertex.c2 = ((val >>> 8) & 0xFF) / 0xFF; vertex.a = ((val >>> 0) & 0xFF) / 0xFF; - } else if (where == F3DEX.MODIFYVTX_Locations.G_MWO_POINT_ST) { + } else if (where === F3DEX.MODIFYVTX_Locations.G_MWO_POINT_ST) { vertex.tx = ((val >>> 16) & 0xFFFF) / 2**5; vertex.ty = ((val >>> 0) & 0xFFFF) / 2**5; - } else if (where == F3DEX.MODIFYVTX_Locations.G_MWO_POINT_XYSCREEN) { + } else if (where === F3DEX.MODIFYVTX_Locations.G_MWO_POINT_XYSCREEN) { vertex.x = (val >>> 16) & 0xFFFF; vertex.y = (val >>> 0) & 0xFFFF; - } else if (where == F3DEX.MODIFYVTX_Locations.G_MWO_POINT_ZSCREEN) { + } else if (where === F3DEX.MODIFYVTX_Locations.G_MWO_POINT_ZSCREEN) { vertex.z = (val >>> 16) & 0xFFFF; } else { console.error(`Unknown gSPModifyVertex location: ${where.toString(16)}`); @@ -340,7 +340,7 @@ export class GloverRSPState implements F3DEX.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)); @@ -697,11 +697,11 @@ export function f3dexFromGeometry(geo: GloverObjbank.Geometry, faceIdx: number, f3dexVertex.y = Math.floor(geoVert.y); f3dexVertex.z = Math.floor(geoVert.z); - f3dexVertex.tx = (faceVertIdx == 0) ? geo.uvs[faceIdx].u1.raw : - (faceVertIdx == 1) ? geo.uvs[faceIdx].u2.raw : + f3dexVertex.tx = (faceVertIdx === 0) ? geo.uvs[faceIdx].u1.raw : + (faceVertIdx === 1) ? geo.uvs[faceIdx].u2.raw : geo.uvs[faceIdx].u3.raw; - f3dexVertex.ty = (faceVertIdx == 0) ? geo.uvs[faceIdx].v1.raw : - (faceVertIdx == 1) ? geo.uvs[faceIdx].v2.raw : + f3dexVertex.ty = (faceVertIdx === 0) ? geo.uvs[faceIdx].v1.raw : + (faceVertIdx === 1) ? geo.uvs[faceIdx].v2.raw : geo.uvs[faceIdx].v3.raw; const colorsNorms = geo.colorsNorms[vertIdx]; @@ -740,12 +740,12 @@ export function loadRspTexture(rspState: GloverRSPState, textureHolder: Textures rspState.gDPSetTile( texFile.colorFormat, - texFile.compressionFormat == 0 ? ImageSize.G_IM_SIZ_4b : ImageSize.G_IM_SIZ_8b, + texFile.compressionFormat === 0 ? ImageSize.G_IM_SIZ_4b : ImageSize.G_IM_SIZ_8b, 0, 0x0100, G_TX_LOADTILE, 0, cmT, 0, 0, cmS, 0, 0); - rspState.gDPLoadTLUT(G_TX_LOADTILE, texFile.compressionFormat == 0 ? 15 : 255); + rspState.gDPLoadTLUT(G_TX_LOADTILE, texFile.compressionFormat === 0 ? 15 : 255); rspState.gDPSetTextureImage(texFile.colorFormat, ImageSize.G_IM_SIZ_16b, 1, textureId); @@ -761,7 +761,7 @@ export function loadRspTexture(rspState: GloverRSPState, textureHolder: Textures rspState.gDPSetTile( texFile.colorFormat, - texFile.compressionFormat == 0 ? ImageSize.G_IM_SIZ_4b : ImageSize.G_IM_SIZ_8b, + texFile.compressionFormat === 0 ? ImageSize.G_IM_SIZ_4b : ImageSize.G_IM_SIZ_8b, 0, 0x0000, G_TX_RENDERTILE, 0, cmT, texFile.maskt, G_TX_NOLOD, cmS, texFile.masks, G_TX_NOLOD) @@ -774,7 +774,7 @@ export function loadRspTexture(rspState: GloverRSPState, textureHolder: Textures } else { rspState.gDPSetOtherModeH(0x0E, 0x02, 0x0000); // gsDPSetTextureLUT(G_TT_NONE) - const siz = texFile.compressionFormat == 2 ? ImageSize.G_IM_SIZ_16b : ImageSize.G_IM_SIZ_32b; + const siz = texFile.compressionFormat === 2 ? ImageSize.G_IM_SIZ_16b : ImageSize.G_IM_SIZ_32b; rspState.gDPSetTextureImage(texFile.colorFormat, siz, 1, textureId); rspState.gDPSetTile( diff --git a/src/Glover/scenes.ts b/src/Glover/scenes.ts index 898044123..4e09cd51f 100644 --- a/src/Glover/scenes.ts +++ b/src/Glover/scenes.ts @@ -266,7 +266,7 @@ class GloverVent implements GenericRenderable { } const bullet = this.bullets.spawn(finalPos); vec3.copy(bullet.velocity, this.velocity); - if (this.bullets.bulletType != 0x12) { + if (this.bullets.bulletType !== 0x12) { bullet.velocity[0] += (Math.floor(Math.random()*11) - 5) / 20.0; bullet.velocity[1] += (Math.floor(Math.random()*11) - 5) / 20.0; bullet.velocity[2] += (Math.floor(Math.random()*11) - 5) / 20.0; @@ -512,7 +512,7 @@ export class GloverPlatform implements Shadows.ShadowCaster { public initExitSparkle(): ParticlePool { assert(this.actor !== null); - assert(this.exitSparkle == false); + assert(this.exitSparkle === false); this.exitSparkle = true; this.exitSparkleParticles = new ParticlePool( this.actor.device, this.actor.cache, this.actor.textures, 0x15); @@ -521,7 +521,7 @@ export class GloverPlatform implements Shadows.ShadowCaster { public pushPathPoint(point: PlatformPathPoint) { this.path.push(point); - if (this.path.length == 1) { + if (this.path.length === 1) { this.setPosition(point.pos[0], point.pos[1], point.pos[2]); vec3.copy(this.lastPosition, this.position); vec3.copy(this.nextPosition, this.position); @@ -575,7 +575,7 @@ export class GloverPlatform implements Shadows.ShadowCaster { } public setSpinFlip(theta: number, cooldownTimer: number) { - if (cooldownTimer == 0) { + if (cooldownTimer === 0) { cooldownTimer = 5; } this.spinFlip = true; @@ -677,10 +677,10 @@ export class GloverPlatform implements Shadows.ShadowCaster { vec3.sub(this.scratchVec3, this.position, this.orbitPt); let dist = 0; let theta = 0; - if (axis == 0) { + if (axis === 0) { theta = Math.atan2(this.scratchVec3[1],this.scratchVec3[2]); dist = Math.sqrt(Math.pow(this.scratchVec3[1],2) + Math.pow(this.scratchVec3[2],2)); - } else if (axis == 1) { + } else if (axis === 1) { theta = Math.atan2(this.scratchVec3[0],this.scratchVec3[2]); dist = Math.sqrt(Math.pow(this.scratchVec3[0],2) + Math.pow(this.scratchVec3[2],2)); } else { @@ -720,10 +720,10 @@ export class GloverPlatform implements Shadows.ShadowCaster { theta -= this.orbitSpeed * deltaTime; const x = Math.cos(theta) * dist; const y = Math.sin(theta) * dist; - if (axis == 0) { + if (axis === 0) { this.position[1] = this.orbitPt[1] + y; this.position[2] = this.orbitPt[2] + x; - } else if (axis == 1) { + } else if (axis === 1) { this.position[0] = this.orbitPt[0] + y; this.position[2] = this.orbitPt[2] + x; } else { @@ -771,7 +771,7 @@ export class GloverPlatform implements Shadows.ShadowCaster { } public advanceFrame(deltaTime : number, viewerInput : Viewer.ViewerRenderInput | null = null): void { - if (deltaTime == 0) { + if (deltaTime === 0) { return; } deltaTime = Math.min(deltaTime, SRC_FRAME_TO_MS); @@ -842,7 +842,7 @@ export class GloverPlatform implements Shadows.ShadowCaster { } if (distRemaining < curSpeed + 0.01) { - if (this.pathTimeLeft == 0) { + if (this.pathTimeLeft === 0) { this.pathCurPt = (this.pathCurPt + this.pathDirection) % this.path.length; this.pathTimeLeft = this.path[this.pathCurPt].duration; this.pathPaused = this.path[this.pathCurPt].duration < 0; @@ -997,7 +997,7 @@ export class GloverWind implements GenericRenderable { const jitter = this.turbulence * (Math.floor(Math.random()*10)/4 + 12); let lifetime = 0; for (let axis = 0; axis < 3; axis++) { - if (this.scratchVelocity[axis] == 0) { + if (this.scratchVelocity[axis] === 0) { this.scratchOrigin[axis] = Math.floor(Math.random() * this.whd[axis]); } else { lifetime = Math.max(lifetime, this.whd[axis] / jitter); @@ -1074,12 +1074,12 @@ export class GloverMrTip implements Shadows.ShadowCaster { this.lastFrameAdvance = 0; this.frameCount += 1; const blink = Math.floor(Math.random() * 0x14); - if (blink == 1) { + if (blink === 1) { this.curFrame = 1; } else { this.curFrame = 0; } - if ((this.frameCount & 1) != 0) { + if ((this.frameCount & 1) !== 0) { const particleOrigin = [ this.position[0] + Math.floor(Math.random()*7) - 3, this.position[1] + 5, @@ -1651,9 +1651,9 @@ class SceneDesc implements Viewer.SceneDesc { const landscape = new GloverLevel(new KaitaiStream(raw_landscape.arrayBuffer)); const object_banks = raw_object_banks.map( - (raw) => { return raw == null ? null : new GloverObjbank(new KaitaiStream(decompress(raw).arrayBuffer))}) + (raw) => { return raw === null ? null : new GloverObjbank(new KaitaiStream(decompress(raw).arrayBuffer))}) const texture_banks = raw_texture_banks.map( - (raw) => { return raw == null ? null : new GloverTexbank(new KaitaiStream(decompress(raw).arrayBuffer))}) + (raw) => { return raw === null ? null : new GloverTexbank(new KaitaiStream(decompress(raw).arrayBuffer))}) const textureHolder = new GloverTextureHolder(); const sceneRenderer = new GloverRenderer(device, textureHolder); @@ -1856,7 +1856,7 @@ class SceneDesc implements Viewer.SceneDesc { sceneRenderer.actors.push(ballActor) mat4.fromTranslation(ballActor.modelMatrix, [cmd.params.x, cmd.params.y, cmd.params.z]); mat4.scale(ballActor.modelMatrix, ballActor.modelMatrix, [0.05, 0.05, 0.05]); - if (cmd.params.type != 1) { + if (cmd.params.type !== 1) { ballActor.shadowSize = 5; shadowCasters.push([ballActor, false]); ballActors.push(ballActor); @@ -1885,7 +1885,7 @@ class SceneDesc implements Viewer.SceneDesc { cmd.params.type, null, sceneRenderer.waterVolumes); - if (cmd.params.parentTag != 0) { + if (cmd.params.parentTag !== 0) { ventParents.push([currentVent, cmd.params.parentTag]); } currentObject = currentVent; @@ -1904,7 +1904,7 @@ class SceneDesc implements Viewer.SceneDesc { sceneRenderer.actors.push(currentPlatform.actor!) currentObject = currentPlatform; - if (cmd.params.objectId == 0x7FDADB91) { + if (cmd.params.objectId === 0x7FDADB91) { // special case exitpost.ndo currentPlatform.setScale(1.5, 2.0, 1.5); currentPlatform.actor!.playSkeletalAnimation(0, true, false); @@ -1983,7 +1983,7 @@ class SceneDesc implements Viewer.SceneDesc { if (currentPlatform === null) { throw `No active platform for ${cmd.params.__type}!`; } - const duration = (cmd.params.duration == 0) ? 1 : cmd.params.duration; + const duration = (cmd.params.duration === 0) ? 1 : cmd.params.duration; currentPlatform.pushPathPoint(new PlatformPathPoint( vec3.fromValues(cmd.params.x, cmd.params.y, cmd.params.z), duration)) break; @@ -2068,7 +2068,7 @@ class SceneDesc implements Viewer.SceneDesc { if (currentPlatform === null) { throw `No active platform for ${cmd.params.__type}!`; } - if (cmd.params.type == 1 || cmd.params.type == 3 || this.id == "09") { + if (cmd.params.type === 1 || cmd.params.type === 3 || this.id === "09") { const emitter = currentPlatform.initExitSparkle(); sceneRenderer.miscRenderers.push(emitter); } @@ -2089,13 +2089,13 @@ class SceneDesc implements Viewer.SceneDesc { throw `Unrecognized collectible type!`; } const flipbook = new GloverFlipbookRenderer(device, cache, textureHolder, flipbookMetadata) - flipbook.isGarib = cmd.params.type == 0; + flipbook.isGarib = cmd.params.type === 0; const pos = vec3.fromValues(cmd.params.x, cmd.params.y, cmd.params.z); mat4.fromTranslation(flipbook.drawMatrix, pos); sceneRenderer.flipbooks.push(flipbook); shadowCasters.push([flipbook, cmd.params.dynamicShadow !== 0]); flipbook.visible = (currentGaribState !== 0); - if (cmd.params.type == 2) { + if (cmd.params.type === 2) { // Extra lives are sparkly const emitter = new CollectibleSparkle(device, cache, textureHolder, pos, CollectibleSparkleType.ExtraLife); sceneRenderer.miscRenderers.push(emitter); @@ -2104,7 +2104,7 @@ class SceneDesc implements Viewer.SceneDesc { break; } case 'Powerup': { - if (cmd.params.type != 7 && cmd.params.type != 9) { + if (cmd.params.type !== 7 && cmd.params.type !== 9) { const actor = loadActor(powerup_objects[cmd.params.type]); sceneRenderer.actors.push(actor) const pos = vec3.fromValues(cmd.params.x, cmd.params.y, cmd.params.z); @@ -2184,7 +2184,7 @@ class SceneDesc implements Viewer.SceneDesc { const ballPos = ballActor.getPosition(); ballPos[1] += radius; let collision = Shadows.projectOntoTerrain(ballPos, ballActor, shadowTerrain); - if (collision != null) { + if (collision !== null) { const dist = collision.position[1] - (ballPos[1] - 2*radius); ballActor.modelMatrix[13] += dist; } diff --git a/src/Glover/sprite.ts b/src/Glover/sprite.ts index a3d31571e..c3c659ee3 100644 --- a/src/Glover/sprite.ts +++ b/src/Glover/sprite.ts @@ -280,7 +280,7 @@ export class GloverBackdropRenderer extends GloverBaseSpriteRenderer { rect.ulS = rect.sW * 32; rect.ulT = rect.sH * 32; - if (this.backdropObject.flipY != 0) { + if (this.backdropObject.flipY !== 0) { [rect.ulT, rect.lrT] = [rect.lrT, rect.ulT]; } @@ -397,7 +397,7 @@ export class GloverFlipbookRenderer implements Shadows.ShadowCaster { if (GloverFlipbookRenderer.renderCache.has(key)) { this.spriteRenderer = GloverFlipbookRenderer.renderCache.get(key)!; } else { - const xlu = (flipbookMetadata.startAlpha != flipbookMetadata.endAlpha) || (flipbookMetadata.flags & 0x10000) != 0; + const xlu = (flipbookMetadata.startAlpha !== flipbookMetadata.endAlpha) || (flipbookMetadata.flags & 0x10000) !== 0; this.spriteRenderer = new GloverSpriteRenderer(this.device, this.cache, this.textures, flipbookMetadata.frameset, xlu); GloverFlipbookRenderer.renderCache.set(key, this.spriteRenderer); } @@ -464,7 +464,7 @@ export class GloverFlipbookRenderer implements Shadows.ShadowCaster { } let alpha = this.endAlpha; - if (this.startAlpha != this.endAlpha) { + if (this.startAlpha !== this.endAlpha) { alpha = this.startAlpha; if (this.lifetime < 0) { const nFrames = this.flipbookMetadata.frameset.length; @@ -476,7 +476,7 @@ export class GloverFlipbookRenderer implements Shadows.ShadowCaster { this.primColor.a = alpha / 255; let size = this.startSize; - if (this.startSize != this.endSize) { + if (this.startSize !== this.endSize) { if (this.lifetime < 0) { const nFrames = this.flipbookMetadata.frameset.length; size += (this.endSize - this.startSize) * (nFrames - this.curFrame - 1) / (nFrames - 1); @@ -691,9 +691,9 @@ export class GloverWeatherRenderer { } singleDebris.vel = [this.params.velocity[0], this.params.velocity[1]]; singleDebris.countdownToFadeout = 0xf; - if (this.curParticleCycle == 0) { + if (this.curParticleCycle === 0) { singleDebris.curParallaxEffect = 0x400; - } else if (this.curParticleCycle == 1) { + } else if (this.curParticleCycle === 1) { singleDebris.curParallaxEffect = 0x300; singleDebris.vel[0] *= 0.75; singleDebris.vel[1] *= 0.75; @@ -733,7 +733,7 @@ export class GloverWeatherRenderer { if (this.lightningFrame > 0) { this.lightningFrame -= 1; - if ((this.lightningFrame & 1) == 0) { + if ((this.lightningFrame & 1) === 0) { if ((Math.floor(Math.random()*10) & 1)==0) { this.lightningColor.r = 0; this.lightningColor.g = 0; @@ -930,7 +930,7 @@ export class GloverFootprintRenderer extends GloverSpriteRenderer { this.lastFrameAdvance += viewerInput.deltaTime; this.lifetime -= viewerInput.deltaTime; - if (this.lifetime <= 0 || (this.dstAlpha == 0 && this.alpha == 0)) { + if (this.lifetime <= 0 || (this.dstAlpha === 0 && this.alpha === 0)) { this.active = false; return; } diff --git a/src/Glover/textures.ts b/src/Glover/textures.ts index 5cdd07f89..835b5d10b 100644 --- a/src/Glover/textures.ts +++ b/src/Glover/textures.ts @@ -33,7 +33,7 @@ export interface Image { } function blur_ci8(data: Uint8Array, width: number, height: number): void { - if (width == 0) { + if (width === 0) { return; } let idx = 0; @@ -85,20 +85,20 @@ export class GloverTextureHolder extends TextureHolder { this.idToBank.set(texture.id, this.banks.length - 1); this.idToTexture.set(texture.id, texture); - if ((texture.flags & 0x4) != 0) { + if ((texture.flags & 0x4) !== 0) { this.animatedTextures.push(texture); } // Hard-coded blur for animated portal texture - if (texture.id == 0x0fe4919b) { + if (texture.id === 0x0fe4919b) { for (let i = 0; i < 50; i++) { blur_ci8(texture.data, texture.width, texture.height); } } var colorFormat = texture.colorFormat as number as ImageFormat; - if (texture.compressionFormat == GloverTexbank.TextureCompressionFormat.CI4 || - texture.compressionFormat == GloverTexbank.TextureCompressionFormat.CI8) + if (texture.compressionFormat === GloverTexbank.TextureCompressionFormat.CI4 || + texture.compressionFormat === GloverTexbank.TextureCompressionFormat.CI8) { colorFormat = ImageFormat.G_IM_FMT_CI; } @@ -233,7 +233,7 @@ export class GloverTextureHolder extends TextureHolder { const bank = this.idToBank.get(id); const texture = this.idToTexture.get(id); if (bank !== undefined && texture !== undefined) { - return (texture.flags & 4) != 0; + return (texture.flags & 4) !== 0; } else { return false; } diff --git a/src/Glover/util.ts b/src/Glover/util.ts index 42cbce163..2de90fbfe 100644 --- a/src/Glover/util.ts +++ b/src/Glover/util.ts @@ -156,11 +156,11 @@ export function pushAlongLookatVector(dst: vec3, src: vec3, dist: number, viewer let rng_reg = 0x6151f; export function random(max: number): number { - if (max == 0) { + if (max === 0) { return 0; } else { rng_reg ^= rng_reg << 1; - if ((rng_reg & 0x80000000) != 0) { + if ((rng_reg & 0x80000000) !== 0) { if (rng_reg === 0x80000000) { rng_reg = 0; } diff --git a/src/HeavyIron/HIModelBucket.ts b/src/HeavyIron/HIModelBucket.ts index d089dc4c5..4112e541a 100644 --- a/src/HeavyIron/HIModelBucket.ts +++ b/src/HeavyIron/HIModelBucket.ts @@ -91,7 +91,7 @@ export class HIModelBucketManager { } if ((minst.pipeFlags & (HIPipeFlags.SRCBLEND_MASK | HIPipeFlags.DESTBLEND_MASK)) || - alphaFade != 1.0 || minst.alpha != 1.0) { + alphaFade !== 1.0 || minst.alpha !== 1.0) { if (this.alphaCurr < this.alphaList.length) { this.alphaList[this.alphaCurr].data = minst.bucket.data; this.alphaList[this.alphaCurr].minst = minst; diff --git a/src/HeavyIron/HIP.ts b/src/HeavyIron/HIP.ts index 6d13464fc..c79c8c24a 100644 --- a/src/HeavyIron/HIP.ts +++ b/src/HeavyIron/HIP.ts @@ -19,7 +19,7 @@ class HIPStream { let s = ''; while (true) { const c = this.view.getUint8(this.pos++); - if (c == 0) { + if (c === 0) { break; } s += String.fromCharCode(c); @@ -95,7 +95,7 @@ export class HIPFile { public findAsset(id: number): HIPAsset | undefined { return this.assets.find((asset: HIPAsset) => { - return asset.id == id; + return asset.id === id; }); } diff --git a/src/HeavyIron/HIScene.ts b/src/HeavyIron/HIScene.ts index c599aaaeb..22a98983a 100644 --- a/src/HeavyIron/HIScene.ts +++ b/src/HeavyIron/HIScene.ts @@ -212,7 +212,7 @@ export class HIScene implements SceneGfx { public findObject(id: number): HIBase | null { const obj = this.baseList.find((base: HIBase) => { - return base.baseAsset.id == id; + return base.baseAsset.id === id; }); return obj || null; } @@ -220,9 +220,9 @@ export class HIScene implements SceneGfx { public sendEvent(to: HIBase, event: HIEvent, params?: number[] | ArrayBufferSlice, from?: HIBase) { this.debug.eventLog.push(this, to, event, from); - if (event == HIEvent.Disable) { + if (event === HIEvent.Disable) { to.disable(); - } else if (event == HIEvent.Enable) { + } else if (event === HIEvent.Enable) { to.enable(); } diff --git a/src/InputManager.ts b/src/InputManager.ts index af894b1e4..4d11f07d9 100644 --- a/src/InputManager.ts +++ b/src/InputManager.ts @@ -225,14 +225,14 @@ export default class InputManager { private _onTouchChange = (e: TouchEvent) => { // start, end or cancel a touch if (!this.isMouseEnabled) return; - if (e.touches.length == 1) { + if (e.touches.length === 1) { const scaledTouches = this._getScaledTouches(e.touches); this.touchGesture = TouchGesture.Scroll; this.prevTouchX = scaledTouches[0].x; this.prevTouchY = scaledTouches[0].y; this.dTouchX = 0; this.dTouchY = 0; - } else if (e.touches.length == 2) { + } else if (e.touches.length === 2) { const pinchValues = this._getPinchValues(e.touches); this.touchGesture = TouchGesture.Pinch; this.prevTouchX = pinchValues.x; @@ -249,7 +249,7 @@ export default class InputManager { private _onTouchMove = (e: TouchEvent) => { if (!this.isMouseEnabled) return; - if (e.touches.length == 1) { + if (e.touches.length === 1) { const scaledTouches = this._getScaledTouches(e.touches); this.touchGesture = TouchGesture.Scroll; this.dTouchX = scaledTouches[0].x - this.prevTouchX; @@ -257,7 +257,7 @@ export default class InputManager { this.onMotion(this.dTouchX, this.dTouchY); this.prevTouchX = scaledTouches[0].x; this.prevTouchY = scaledTouches[0].y; - } else if (e.touches.length == 2) { + } else if (e.touches.length === 2) { const pinchValues = this._getPinchValues(e.touches); this.touchGesture = TouchGesture.Pinch; this.dTouchX = pinchValues.x - this.prevTouchX; diff --git a/src/JetSetRadio/Ninja.ts b/src/JetSetRadio/Ninja.ts index 529280abe..20f9de514 100644 --- a/src/JetSetRadio/Ninja.ts +++ b/src/JetSetRadio/Ninja.ts @@ -310,9 +310,9 @@ function parseChunkList(buffer: ArrayBufferSlice, offs: number, callback: (type: let extra = undefined; let data: ArrayBufferSlice | undefined; - if (header == 0x00) { + if (header === 0x00) { type = CNK_TYPE.CNK_NULL; - } else if (header == 0xFF) { + } else if (header === 0xFF) { type = CNK_TYPE.CNK_END; } @@ -355,7 +355,7 @@ function parseNjsVlist(buffer: ArrayBufferSlice, offset: number): NJS_VERTS { const specular: Color[] = []; const processVlistChunks = (type: CNK_TYPE, header: number, flags: number, extra: number | undefined, data: ArrayBufferSlice | undefined): void => { - if (type != CNK_TYPE.CNK_VERT || data === undefined) + if (type !== CNK_TYPE.CNK_VERT || data === undefined) return; const view = data.createDataView(); diff --git a/src/KatamariDamacy/bin.ts b/src/KatamariDamacy/bin.ts index df04d94b2..607b03457 100644 --- a/src/KatamariDamacy/bin.ts +++ b/src/KatamariDamacy/bin.ts @@ -1414,7 +1414,7 @@ export function parseMissionSetupBIN(buffers: ArrayBufferSlice[], defs: ArrayBuf const u16NameIdx = view.getUint16(randomSpawnsIdx + 0x00, true); const u8LocPosType = view.getUint8(randomSpawnsIdx + 0x02); const s8RandomLocGroupNo = view.getInt8(randomSpawnsIdx + 0x03); - if (u16NameIdx == 0xFFFF) + if (u16NameIdx === 0xFFFF) break; if (u8LocPosType !== 0) assertExists(randomGroups[s8RandomLocGroupNo]).objectCount++; diff --git a/src/KatamariDamacy/tools/extractor.ts b/src/KatamariDamacy/tools/extractor.ts index 6f33c64a0..b0c8dba84 100644 --- a/src/KatamariDamacy/tools/extractor.ts +++ b/src/KatamariDamacy/tools/extractor.ts @@ -39,7 +39,7 @@ function iso9660GetDataFilename(isoFilename: string, filename: string): ArrayBuf let offs = 0x00; while (true) { const recordLen = rootDirectoryView.getUint8(offs + 0x00); - if (recordLen == 0) + if (recordLen === 0) break; const lba = rootDirectoryView.getUint32(offs + 0x02, true); const byteLength = rootDirectoryView.getUint32(offs + 0x0A, true); diff --git a/src/KingdomHearts/bin.ts b/src/KingdomHearts/bin.ts index 3103cf617..f28004ef8 100644 --- a/src/KingdomHearts/bin.ts +++ b/src/KingdomHearts/bin.ts @@ -69,7 +69,7 @@ function processTriangleStrips(view: DataView, offs: number, submeshOut: Submesh )); const w = view.getFloat32(offs + 0xC, true); if (i > 0 && Math.abs(w) > 1e-6) { - const doubleSided = view.getUint8(offs + 0xC) == 0x2; + const doubleSided = view.getUint8(offs + 0xC) === 0x2; if (w < 0 || doubleSided) { submeshOut.ind.push(i); submeshOut.ind.push(i - 1); @@ -126,7 +126,7 @@ function processUVs(view: DataView, offs: number, submeshOut: Submesh): number { } function processTextureTag(view: DataView, offs: number, mesh: Mesh, submeshOut: Submesh, textureBlocksOut: BinTex.TextureBlock[]): number { - if (view.getUint8(offs) == 0x5) { + if (view.getUint8(offs) === 0x5) { // Indexed data and color table are unpacked directly, not from a texture bank. return processTextureUnpack(view, offs, mesh, submeshOut, textureBlocksOut); } @@ -139,12 +139,12 @@ function processTextureTag(view: DataView, offs: number, mesh: Mesh, submeshOut: } const bank = (view.getUint8(propertiesOffs + 0x2) & 0x80) > 0 ? 1 : 0; const dataOffsBase = view.getUint16(propertiesOffs, true) * 0x100; - const dataOffs = (bank == 0) ? dataOffsBase - 0x260000 : dataOffsBase / 4; + const dataOffs = (bank === 0) ? dataOffsBase - 0x260000 : dataOffsBase / 4; const colorTableOffs = ((view.getUint16(propertiesOffs + 0x4, true) & 0x3FF0) >> 4) * 0x80; let textureBlock: BinTex.TextureBlock | null = null; for (let i = 0; i < textureBlocksOut.length; i++) { - if (textureBlocksOut[i].bank == bank && textureBlocksOut[i].dataOffs == dataOffs) { + if (textureBlocksOut[i].bank === bank && textureBlocksOut[i].dataOffs === dataOffs) { textureBlock = textureBlocksOut[i]; break; } @@ -152,17 +152,17 @@ function processTextureTag(view: DataView, offs: number, mesh: Mesh, submeshOut: if (!textureBlock) { const bitDepth = (view.getUint8(propertiesOffs + 0x2) & 0x40) > 0 ? 4 : 8; const deswizzle = bank === 0 && dataOffs >= 0x100000; - textureBlock = new BinTex.TextureBlock(/*width=*/bitDepth == 8 ? 256 : 512, /*height=*/256, bitDepth, bank, dataOffs, deswizzle); + textureBlock = new BinTex.TextureBlock(/*width=*/bitDepth === 8 ? 256 : 512, /*height=*/256, bitDepth, bank, dataOffs, deswizzle); textureBlocksOut.push(textureBlock); } let textureIndex = 0; for (let i = 0; i < textureBlock.textures.length; i++) { - if (textureBlock.textures[i].colorTableOffs == colorTableOffs) { + if (textureBlock.textures[i].colorTableOffs === colorTableOffs) { break; } textureIndex++; } - if (textureIndex == textureBlock.textures.length) { + if (textureIndex === textureBlock.textures.length) { const texture = new BinTex.Texture(textureIndex, textureBlock, colorTableOffs, mesh.translucent); parseTextureBounds(view, boundsOffs, texture); textureBlock.textures.push(texture); @@ -197,7 +197,7 @@ function processTextureUnpack(view: DataView, offs: number, mesh: Mesh, submeshO } const dataSize = (view.getUint16(offs + 0x54, true) & 0xFFFE) * 0x10; offs += dataSize + 0x68; - } else if (blockId == 0x4) { + } else if (blockId === 0x4) { let propertiesOffs = offs + 0x24; let boundsOffs = offs + 0x34; // Quick hack to handle cases where these two blocks are occasionally stored out of order. @@ -206,7 +206,7 @@ function processTextureUnpack(view: DataView, offs: number, mesh: Mesh, submeshO boundsOffs = offs + 0x24; } texBitDepth = (view.getUint8(propertiesOffs + 0x2) & 0x40) > 0 ? 4 : 8; - const texHeight = Math.floor(texSize / texWidth) * (texBitDepth == 4 ? 2 : 1); + const texHeight = Math.floor(texSize / texWidth) * (texBitDepth === 4 ? 2 : 1); const textureBlock = new BinTex.TextureBlock(texWidth, texHeight, texBitDepth, /*bank=*/-1, texDataOffs, deswizzle); textureBlocksOut.push(textureBlock); @@ -224,8 +224,8 @@ function processTextureUnpack(view: DataView, offs: number, mesh: Mesh, submeshO } function parseTextureBounds(view: DataView, offs: number, textureOut: BinTex.Texture) { - textureOut.tiledU = (view.getUint8(offs) & 0xF0) == 0xF0; - textureOut.tiledV = (view.getUint8(offs + 0x3) & 0xF) == 0xF; + textureOut.tiledU = (view.getUint8(offs) & 0xF0) === 0xF0; + textureOut.tiledV = (view.getUint8(offs + 0x3) & 0xF) === 0xF; if (textureOut.tiledU) { textureOut.clipRight = ((view.getUint8(offs + 0x1) & 0xF) + 1) * 0x10 - 1; } else { @@ -303,19 +303,19 @@ function parseGeometrySector(view: DataView, geomSectorOffs: number, isSkybox: b for (let i = 0; i < vifTableCount; i++) { const index = i >= columnCount ? (i - columnCount) * 2 + 1 : i * 2; const size = (view.getUint32(vifTableOffs + index * 8, true) & 0xFFFFFFF) * 0x10; - if (size == 0) { + if (size === 0) { continue; } const offs = geomSectorOffs + view.getUint32(vifTableOffs + index * 8 + 0x4, true); const endOffs = offs + size; const mesh = new Mesh; - mesh.translucent = (index % 2) == 1; + mesh.translucent = (index % 2) === 1; if (index > 1) { const boundingBoxOffs = boundingBoxTableOffs + (Math.floor(index / 2) - 1) * 0x80; initMesh(view, boundingBoxOffs, mesh); } - parseVifPackets(view, offs, endOffs, /*first=*/index == 0, mesh, textureBlocksOut); + parseVifPackets(view, offs, endOffs, /*first=*/index === 0, mesh, textureBlocksOut); meshesOut.push(mesh); } } @@ -366,7 +366,7 @@ function parseUVAnimSectors(view: DataView, mapTextureBlocks: BinTex.TextureBloc for (let i = 0; i < spriteCount; ++i) { const offs = uvSpriteSectorOffs + i * 0xA0; const numFrames = Math.min(0x20, view.getUint32(offs, true)); - if (numFrames == 0) { + if (numFrames === 0) { continue; } const spriteLeft = view.getUint16(offs + 0x4, true); @@ -374,17 +374,17 @@ function parseUVAnimSectors(view: DataView, mapTextureBlocks: BinTex.TextureBloc const dataOffsetU = view.getUint16(offs + 0x10, true); const dataWidthU = view.getUint16(offs + 0x12, true); const bank = (dataWidthU & 0x800) > 0 ? 1 : 0; - const texDataOffs = bank == 0 ? dataOffsetU * 0x100 - 0x260000 : dataOffsetU * 0x100 / 4; + const texDataOffs = bank === 0 ? dataOffsetU * 0x100 - 0x260000 : dataOffsetU * 0x100 / 4; // Locate texture for this sprite sheet. let textureBlock = null; let texture = null; for (let j = 0; j < mapTextureBlocks.length && !texture; j++) { - if (mapTextureBlocks[j].bank != bank || mapTextureBlocks[j].dataOffs != texDataOffs) { + if (mapTextureBlocks[j].bank !== bank || mapTextureBlocks[j].dataOffs !== texDataOffs) { continue; } for (let k = 0; k < mapTextureBlocks[j].textures.length; k++) { const curTex = mapTextureBlocks[j].textures[k]; - if (curTex.clipLeft == spriteLeft && curTex.clipTop == spriteTop) { + if (curTex.clipLeft === spriteLeft && curTex.clipTop === spriteTop) { textureBlock = mapTextureBlocks[j]; texture = curTex; break; diff --git a/src/KingdomHearts/bin_tex.ts b/src/KingdomHearts/bin_tex.ts index 803554f15..5222c30f1 100644 --- a/src/KingdomHearts/bin_tex.ts +++ b/src/KingdomHearts/bin_tex.ts @@ -27,7 +27,7 @@ export class Texture { public pixels(): Uint8Array { const width = this.clipRight - this.clipLeft + 1; const height = this.clipBottom - this.clipTop + 1; - if (width == this.parent.width && height == this.parent.height) { + if (width === this.parent.width && height === this.parent.height) { return new Uint8Array(this.parent.pixels); } let clipped = new Uint8Array(width * height * 4); @@ -50,18 +50,18 @@ export class TextureBlock { } public isOvf(): boolean { - return this.bank == 0 && this.dataOffs >= 0x100000; + return this.bank === 0 && this.dataOffs >= 0x100000; } public build(texDataView: DataView, texClutView: DataView) { if (this.deswizzle) { let dataOffs = this.dataOffs; - if (this.bank == 0) { + if (this.bank === 0) { dataOffs -= 0x100000; } - if (this.bitDepth == 8) { + if (this.bitDepth === 8) { deswizzleIndexed8(texDataView, dataOffs, this.width, this.height); - } else if (this.bitDepth == 4) { + } else if (this.bitDepth === 4) { deswizzleIndexed4(texDataView, dataOffs, this.width, this.height); } } @@ -88,13 +88,13 @@ export class TextureBlock { if (this.bank >= 0) { dataOffs += 0x100000 * (this.isOvf() ? -1 : this.bank); } - const pixelsPerByte = this.bitDepth == 4 ? 2 : 1; + const pixelsPerByte = this.bitDepth === 4 ? 2 : 1; for (let y = texture.clipTop; y <= texture.clipBottom; y++) { for (let x = texture.clipLeft; x <= texture.clipRight; x++) { const offs = y * this.width + x; let p = texDataView.getUint8(dataOffs + offs / pixelsPerByte); - if (pixelsPerByte == 2) { - p = ((x % 2 == 0) ? p : (p >> 4)) & 0xF; + if (pixelsPerByte === 2) { + p = ((x % 2 === 0) ? p : (p >> 4)) & 0xF; } else { // Flip bits 4 and 5: 000xy000 -> 000yx000 p = ((p & 0xE7) | ((p & 0x8) << 1) | ((p & 0x10) >> 1)); @@ -129,13 +129,13 @@ export class TextureAtlas { private _buildAtlas(textureBlocks: TextureBlock[]) { const textureBlocksSorted = textureBlocks.slice(0).sort((a, b) => { - return a.bitDepth < b.bitDepth || (a.bitDepth == b.bitDepth && a.dataOffs < b.dataOffs) ? -1 : 1; + return a.bitDepth < b.bitDepth || (a.bitDepth === b.bitDepth && a.dataOffs < b.dataOffs) ? -1 : 1; }); // Number of 256x256 blocks to fill in the atlas. let numSquares = 0; for (let i = 0; i < textureBlocksSorted.length; i++) { // Assume 4-bit texture blocks are 512x256, whereas 8-bit texture blocks are 256x256. - numSquares += textureBlocksSorted[i].bitDepth == 4 ? 2 : 1; + numSquares += textureBlocksSorted[i].bitDepth === 4 ? 2 : 1; } const squaresPerRow = Math.round(Math.sqrt(numSquares) / 2) * 2; const squaresPerCol = Math.floor(numSquares / squaresPerRow) + 1; @@ -153,7 +153,7 @@ export class TextureAtlas { const dst = ((atlasY * 256 + y) * squaresPerRow + atlasX) * 1024 this.pixels.set(textureBlock.pixels.slice(src, src + textureBlock.width * 4), dst); } - atlasIndex += textureBlocksSorted[i].bitDepth == 4 ? 2 : 1; + atlasIndex += textureBlocksSorted[i].bitDepth === 4 ? 2 : 1; } } } @@ -220,7 +220,7 @@ export function deswizzleIndexed4(texView: DataView, offs: number, width: number const n = (Math.floor(index / (tiles * 0x100)) % rows) * 0x40; const r = a + b + c + d + e + f + g + h + m + n; let x = source[Math.floor(r / 2)]; - if (r % 2 == 1) { + if (r % 2 === 1) { x >>= 4; } v[j] = x & 0xF; diff --git a/src/KingdomHearts/render.ts b/src/KingdomHearts/render.ts index 9cb499d76..ca858364e 100644 --- a/src/KingdomHearts/render.ts +++ b/src/KingdomHearts/render.ts @@ -150,7 +150,7 @@ export class MapData { let iBufIndex = 0; let n = 0; submeshes.forEach(function (submesh) { - if (submesh.textureBlock == null) { + if (submesh.textureBlock === null) { return; } for (let i = 0; i < submesh.vtx.length; i++) { @@ -254,7 +254,7 @@ export class MapData { } for (let j = 0; j < meshes[i].submeshes.length; j++) { const submesh = meshes[i].submeshes[j]; - if (submesh.textureBlock == null) { + if (submesh.textureBlock === null) { continue; } let spriteAnimIndex = -1; @@ -280,7 +280,7 @@ export class MapData { opaqueSubmeshMap.set(batchKeyStr, []); } opaqueSubmeshMap.get(batchKeyStr)!.push(submesh); - } else if (lastIndex >= 0 && translucentSubmeshes[lastIndex][0] == batchKeyStr) { + } else if (lastIndex >= 0 && translucentSubmeshes[lastIndex][0] === batchKeyStr) { translucentSubmeshes[lastIndex][1].push(submesh); } else { translucentSubmeshes.push([batchKeyStr, [submesh]]); diff --git a/src/KingdomHearts2FinalMix/map.ts b/src/KingdomHearts2FinalMix/map.ts index c8a326f6b..648b2974a 100644 --- a/src/KingdomHearts2FinalMix/map.ts +++ b/src/KingdomHearts2FinalMix/map.ts @@ -630,7 +630,7 @@ function handleVifUnpackVertexData(view: DataView, offs: number, vuState: VUStat view.getFloat32(offs + vuState.ind[i] * 0xC + 0x4, true), // vy view.getFloat32(offs + vuState.ind[i] * 0xC + 0x8, true))); // vz const f = vuState.flg[i] & 0x30; - if (f != 0x10) { + if (f !== 0x10) { if (f === 0x20 || f === 0x0) { mesh.ind.push(indStart + i - 2); // t0 mesh.ind.push(indStart + i - 1); // t1 diff --git a/src/MetroidPrime/ancs.ts b/src/MetroidPrime/ancs.ts index 18082b915..3276624df 100644 --- a/src/MetroidPrime/ancs.ts +++ b/src/MetroidPrime/ancs.ts @@ -29,8 +29,8 @@ export interface ANCS { } export function parse(stream: InputStream, resourceSystem: ResourceSystem, assetID: string): ANCS { - assert(stream.readUint16() == 1); // ANCS version - assert(stream.readUint16() == 1); // character set version + assert(stream.readUint16() === 1); // ANCS version + assert(stream.readUint16() === 1); // character set version const numChars = stream.readUint32(); const charSet: MetroidCharacter[] = []; @@ -61,7 +61,7 @@ export function parse(stream: InputStream, resourceSystem: ResourceSystem, asset const pas4 = stream.readFourCC(); const numAnimStates = stream.readUint32(); const defaultAnimState = stream.readUint32(); - assert(pas4 == 'PAS4'); + assert(pas4 === 'PAS4'); for (let stateIdx = 0; stateIdx < numAnimStates; stateIdx++) { stream.skip(4); @@ -74,7 +74,7 @@ export function parse(stream: InputStream, resourceSystem: ResourceSystem, asset const parmType = stream.readUint32(); assert(parmType >= 0 && parmType <= 4); - const parmValueSize = (parmType == 3 ? 1 : 4); + const parmValueSize = (parmType === 3 ? 1 : 4); stream.skip(8); stream.skip(parmValueSize * 2); combinedParmSize += parmValueSize; diff --git a/src/MetroidPrime/collision.ts b/src/MetroidPrime/collision.ts index 982798637..5e51adb1c 100644 --- a/src/MetroidPrime/collision.ts +++ b/src/MetroidPrime/collision.ts @@ -296,8 +296,8 @@ function octreeNodeLineCheck(p0: ReadonlyVec3, dir: ReadonlyVec3, node: Collisio const matID = indexData.triMaterialIDs[triID]; const material = indexData.materials[matID]; - const isSolid = (material & CollisionMaterial.Solid) != 0; - const isFlipped = (material & CollisionMaterial.FlippedTri) != 0; + const isSolid = (material & CollisionMaterial.Solid) !== 0; + const isFlipped = (material & CollisionMaterial.FlippedTri) !== 0; if (!isSolid) continue; diff --git a/src/MetroidPrime/mlvl.ts b/src/MetroidPrime/mlvl.ts index fc02bcb66..ed4ac83ae 100644 --- a/src/MetroidPrime/mlvl.ts +++ b/src/MetroidPrime/mlvl.ts @@ -25,12 +25,12 @@ enum WorldVersion { } export function parse(stream: InputStream, resourceSystem: ResourceSystem, assetID: string): MLVL { - assert(stream.readUint32() == 0xDEAFBABE); + assert(stream.readUint32() === 0xDEAFBABE); const version: WorldVersion = stream.readUint32(); const worldNameID = stream.readAssetID(); - if (version == WorldVersion.MP2) { + if (version === WorldVersion.MP2) { const darkWorldNameID = stream.readAssetID(); } @@ -38,7 +38,7 @@ export function parse(stream: InputStream, resourceSystem: ResourceSystem, asset const templeKeyWorldIndex = stream.readInt32(); } - if (version == WorldVersion.DKCR) { + if (version === WorldVersion.DKCR) { const hasTimeAttack = stream.readBool(); if (hasTimeAttack) { @@ -54,7 +54,7 @@ export function parse(stream: InputStream, resourceSystem: ResourceSystem, asset const defaultSkyboxID = stream.readAssetID(); // Memory Relay junk. - if (version == WorldVersion.MP1) { + if (version === WorldVersion.MP1) { const memoryRelayTableCount = stream.readUint32(); stream.skip(memoryRelayTableCount * 0xB); } @@ -62,8 +62,8 @@ export function parse(stream: InputStream, resourceSystem: ResourceSystem, asset // Areas const areaCount = stream.readUint32(); - if (version == WorldVersion.MP1) - assert(stream.readInt32() == 1); + if (version === WorldVersion.MP1) + assert(stream.readInt32() === 1); const areaTable: Area[] = []; for (let i = 0; i < areaCount; i++) { @@ -101,7 +101,7 @@ export function parse(stream: InputStream, resourceSystem: ResourceSystem, asset } } - if (version == WorldVersion.MP2) { + if (version === WorldVersion.MP2) { const numModules = stream.readUint32(); for (let j = 0; j < numModules; j++) @@ -111,7 +111,7 @@ export function parse(stream: InputStream, resourceSystem: ResourceSystem, asset stream.skip(numOffsets*4); } - if (version == WorldVersion.DKCR) { + if (version === WorldVersion.DKCR) { stream.skip(4); } diff --git a/src/MetroidPrime/mrea.ts b/src/MetroidPrime/mrea.ts index 12a1bdfe0..75c963d5d 100644 --- a/src/MetroidPrime/mrea.ts +++ b/src/MetroidPrime/mrea.ts @@ -428,7 +428,7 @@ function parseMaterialSet_MP1_MP2(stream: InputStream, resourceSystem: ResourceS const isWhiteAmb = false; // Alpha-blending is biased so that additive blending always appears on top - const sortBias = blendSrcFactor == GX.BlendFactor.SRCALPHA && blendDstFactor == GX.BlendFactor.INVSRCALPHA ? 0 : 1; + const sortBias = blendSrcFactor === GX.BlendFactor.SRCALPHA && blendDstFactor === GX.BlendFactor.INVSRCALPHA ? 0 : 1; materials.push({ isOccluder, @@ -877,7 +877,7 @@ export function parseLightLayer(stream: InputStream, version: number): AreaLight stream.skip(0x4); if (version >= AreaVersion.MP3) stream.skip(0x14); // unknown data - if (lightType == AreaLightType.LocalAmbient) { + if (lightType === AreaLightType.LocalAmbient) { ambientColor.r = Math.min(lightColorR * brightness, 1); ambientColor.g = Math.min(lightColorG * brightness, 1); ambientColor.b = Math.min(lightColorB * brightness, 1); @@ -895,17 +895,17 @@ export function parseLightLayer(stream: InputStream, version: number): AreaLight vec3.normalize(light.gxLight.Direction, light.gxLight.Direction); vec3.negate(light.gxLight.Direction, light.gxLight.Direction); - if (lightType == AreaLightType.Directional) { + if (lightType === AreaLightType.Directional) { vec3.set(light.gxLight.DistAtten, 1, 0, 0); vec3.set(light.gxLight.CosAtten, 1, 0, 0); } else { - const distAttenA = (falloffType == 0) ? (2.0 / brightness) : 0; - const distAttenB = (falloffType == 1) ? (250.0 / brightness) : 0; - const distAttenC = (falloffType == 2) ? (25000.0 / brightness) : 0; + const distAttenA = (falloffType === 0) ? (2.0 / brightness) : 0; + const distAttenB = (falloffType === 1) ? (250.0 / brightness) : 0; + const distAttenC = (falloffType === 2) ? (25000.0 / brightness) : 0; vec3.set(light.gxLight.DistAtten, distAttenA, distAttenB, distAttenC); - if (lightType == AreaLightType.Spot) { + if (lightType === AreaLightType.Spot) { // Calculate angle atten if (spotCutoff < 0 || spotCutoff > 90) { @@ -1153,8 +1153,8 @@ export function parse(stream: InputStream, resourceSystem: ResourceSystem): MREA const sclyMagic = stream.readFourCC(); stream.skip(1); const sclyIndex = stream.readUint32(); - assert(sclyMagic == 'SCLY'); - assert(sclyIndex == i); + assert(sclyMagic === 'SCLY'); + assert(sclyIndex === i); const layer = Script.parseScriptLayer_MP2(stream, version, resourceSystem); scriptLayers.push(layer); diff --git a/src/MetroidPrime/particles/element_generator.ts b/src/MetroidPrime/particles/element_generator.ts index 3be0de308..ad285cc7e 100644 --- a/src/MetroidPrime/particles/element_generator.ts +++ b/src/MetroidPrime/particles/element_generator.ts @@ -59,7 +59,7 @@ export class SpawnSystemKeyframeInfo { constructor(stream: InputStream, resourceSystem: ResourceSystem) { const partId = stream.readAssetID(); const partFourCC = stream.readFourCC(); - if (partFourCC === 'PART' || partFourCC == '\x00\x00\x00\x00') { + if (partFourCC === 'PART' || partFourCC === '\x00\x00\x00\x00') { this.description = assertExists(resourceSystem.loadAssetByID(partId, 'PART')).description; } else if (partFourCC === 'SWHC') { this.description = assertExists(resourceSystem.loadAssetByID(partId, 'SWHC')).description; @@ -927,7 +927,7 @@ export class ElementGenerator extends BaseGenerator { if (particle.endFrame.value < this.curFrame) { //--g_ParticleAliveCount; - if (i + 1 == this.particles.length) { + if (i + 1 === this.particles.length) { this.particles.pop(); break; } else { diff --git a/src/MetroidPrime/render.ts b/src/MetroidPrime/render.ts index 8a8277757..64e4e23c9 100644 --- a/src/MetroidPrime/render.ts +++ b/src/MetroidPrime/render.ts @@ -99,7 +99,7 @@ class ActorLights { if (sqDist < (light.radius ** 2)) { // Shadow cast logic - if (light.castShadows && lightParams.options != WorldLightingOptions.NoShadowCast) { + if (light.castShadows && lightParams.options !== WorldLightingOptions.NoShadowCast) { actorBounds.centerPoint(scratchVec3); vec3.sub(scratchVec3, scratchVec3, light.gxLight.Position); diff --git a/src/MetroidPrime/script.ts b/src/MetroidPrime/script.ts index 408ba6748..a4acf6165 100644 --- a/src/MetroidPrime/script.ts +++ b/src/MetroidPrime/script.ts @@ -140,7 +140,7 @@ export class Entity { if (model !== null) { if (animID !== -1) { const animName = character.animNames[animID]; - const anim = ancs.animationSet.animations.find(v => v.name == animName); + const anim = ancs.animationSet.animations.find(v => v.name === animName); const metaAnim = anim?.animation; const mp2Evnt = anim?.mp2Evnt; const aabb = character.aabbAnimMap.get(animName); @@ -296,7 +296,7 @@ function readLightParameters(buffer: ArrayBufferSlice, offs: number, ent: Entity const view = buffer.createDataView(); const numProperties = view.getUint32(offs + 0x00); - assert(numProperties == 14); + assert(numProperties === 14); const castsShadow = view.getUint8(offs + 0x04); const shadowScale = view.getFloat32(offs + 0x05); @@ -341,7 +341,7 @@ function readActorParameters(buffer: ArrayBufferSlice, offs: number, ent: Entity const originalOffs = offs; const numProperties = view.getUint32(offs); - assert(numProperties == 14); + assert(numProperties === 14); offs += 4; offs += readLightParameters(buffer, offs, ent); @@ -726,7 +726,7 @@ export function parseScriptLayer_MP1(buffer: ArrayBufferSlice, layerOffset: numb case MP1EntityType.AreaAttributes: { const entity = new AreaAttributes(entityType, entityId); - entity.active = (view.getUint32(entityTableIdx) == 1); + entity.active = (view.getUint32(entityTableIdx) === 1); entity.needSky = !!(view.getUint8(entityTableIdx + 0x04)); entity.overrideSky = readAssetID(buffer, entityTableIdx + 0x19, 4, 'CMDL', resourceSystem); entities.push(entity); diff --git a/src/MetroidPrime/stream.ts b/src/MetroidPrime/stream.ts index 06aca0f08..ca412b1c9 100644 --- a/src/MetroidPrime/stream.ts +++ b/src/MetroidPrime/stream.ts @@ -37,7 +37,7 @@ export class InputStream { this.offs = align(this.offs, multiple); } - public readBool(): boolean { const v = this.view.getUint8(this.offs++); assert(v == 0 || v == 1); return (v == 1); } + public readBool(): boolean { const v = this.view.getUint8(this.offs++); assert(v === 0 || v === 1); return (v === 1); } public readInt8(): number { return this.view.getInt8(this.offs++); } public readUint8(): number { return this.view.getUint8(this.offs++); } public readInt16(): number { const v = this.view.getInt16(this.offs); this.offs += 2; return v; } diff --git a/src/MetroidPrime/strg.ts b/src/MetroidPrime/strg.ts index 88d42eb4f..77b7cf81d 100644 --- a/src/MetroidPrime/strg.ts +++ b/src/MetroidPrime/strg.ts @@ -128,11 +128,11 @@ function parse_MP3(stream: InputStream): STRG { } export function parse(stream: InputStream, resourceSystem: ResourceSystem, assetID: string): STRG { - assert(stream.readUint32() == 0x87654321); + assert(stream.readUint32() === 0x87654321); const version = stream.readUint32(); stream.skip(-8); - if (version === 0x00 || version == 0x01) + if (version === 0x00 || version === 0x01) return parse_MP1(stream); if (version === 0x03) diff --git a/src/MetroidPrimeHunters/mph_binModel.ts b/src/MetroidPrimeHunters/mph_binModel.ts index a8372b37a..c71444715 100644 --- a/src/MetroidPrimeHunters/mph_binModel.ts +++ b/src/MetroidPrimeHunters/mph_binModel.ts @@ -86,7 +86,7 @@ function parseMaterial(buffer: ArrayBufferSlice, texs:MPHTex[]): MDL0Material { let width; let height; - if (palletIndex == 0xFFFF || textureIndex == 0xFFFF) { + if (palletIndex === 0xFFFF || textureIndex === 0xFFFF) { paletteName = null; textureName = null; width = 1.0; @@ -423,14 +423,14 @@ export function parseMPH_Model(buffer: ArrayBufferSlice): MPHbin { return transform; } function computeNodeMatrices(index: number){ - if(mphNode.length == 0 || index == -1){ + if(mphNode.length === 0 || index === -1){ return; } - for (let i = index; i != -1;) { + for (let i = index; i !== -1;) { let node = mphNode[i]; let transform = mat4.create(); transform = computeNodeTransforms(node.scale, node.rotation, node.position); - if(node.parent == -1){ + if(node.parent === -1){ node.transform = transform; } else { mat4.multiply(node.transform, transform, mphNode[node.parent].transform); @@ -438,7 +438,7 @@ export function parseMPH_Model(buffer: ArrayBufferSlice): MPHbin { const name = node.name; const jointMatrix = node.transform; nodes.push({ name, jointMatrix }); - if(node.child != -1){ + if(node.child !== -1){ computeNodeMatrices(node.child); } i = node.next; diff --git a/src/MetroidPrimeHunters/render.ts b/src/MetroidPrimeHunters/render.ts index fcb26ca82..3b0f25a5c 100644 --- a/src/MetroidPrimeHunters/render.ts +++ b/src/MetroidPrimeHunters/render.ts @@ -40,14 +40,14 @@ function translateWrapMode(repeat: boolean, flip: boolean): GfxWrapMode { } function parseMPHTexImageParamWrapModeS(w0: number): GfxWrapMode { - const repeatS = (((w0 >> 0) & 0x01) == 0x1); - const flipS = (((w0 >> 1) & 0x01) == 0x1); + const repeatS = (((w0 >> 0) & 0x01) === 0x1); + const flipS = (((w0 >> 1) & 0x01) === 0x1); return translateWrapMode(repeatS, flipS); } function parseMPHTexImageParamWrapModeT(w0: number): GfxWrapMode { - const repeatT = (((w0 >> 8) & 0x01) == 0x1); - const flipT = (((w0 >> 9) & 0x01) == 0x1); + const repeatT = (((w0 >> 8) & 0x01) === 0x1); + const flipT = (((w0 >> 9) & 0x01) === 0x1); return translateWrapMode(repeatT, flipT); } diff --git a/src/Morrowind/Render.ts b/src/Morrowind/Render.ts index 52f42e13a..b9be1ec38 100644 --- a/src/Morrowind/Render.ts +++ b/src/Morrowind/Render.ts @@ -369,7 +369,7 @@ class StaticModel { const d = uniformBuffer.mapBufferF32(); offs += fillMatrix4x3(d, offs, instance.modelMatrix); - if (++numInstances == maxInstances) + if (++numInstances === maxInstances) submitDrawInstanced(); }; diff --git a/src/NeedForSpeedMostWanted/datanode.ts b/src/NeedForSpeedMostWanted/datanode.ts index 3d40a2855..6c3aa0da0 100644 --- a/src/NeedForSpeedMostWanted/datanode.ts +++ b/src/NeedForSpeedMostWanted/datanode.ts @@ -23,9 +23,9 @@ export class NfsNode { const nodeType = this.dataView.getUint32(offset, true); const nodeLength = this.dataView.getUint32(offset + 4, true); offset += 8; - if(nodeType != 0) { + if(nodeType !== 0) { let paddingLength = 0; - while(paddingLength < nodeLength && this.dataView.getUint32(offset + paddingLength) == 0x11111111) { + while(paddingLength < nodeLength && this.dataView.getUint32(offset + paddingLength) === 0x11111111) { paddingLength += 4; } const child = new NfsNode(this.dataBuffer.slice(offset + paddingLength, offset + nodeLength), nodeType); @@ -89,5 +89,5 @@ export enum NodeType { function isDirectory(type: number) { // Checks if highest bit is set to 1 - return (type & 0x80000000) != 0; + return (type & 0x80000000) !== 0; } diff --git a/src/NeedForSpeedMostWanted/map.ts b/src/NeedForSpeedMostWanted/map.ts index 4455493b2..e8e69a397 100644 --- a/src/NeedForSpeedMostWanted/map.ts +++ b/src/NeedForSpeedMostWanted/map.ts @@ -39,17 +39,17 @@ export class NfsMap { region.parseTextures(device, renderHelper, this); region.parseModels(device, renderHelper.renderCache, this); }); - const regionDefNode = baseFileNode.children.filter(node => node.type == NodeType.RegionDefinitions)[0]; - const dataSectionDefNode = baseFileNode.children.filter(node => node.type == NodeType.DataSectionDefinitions)[0]; + const regionDefNode = baseFileNode.children.filter(node => node.type === NodeType.RegionDefinitions)[0]; + const dataSectionDefNode = baseFileNode.children.filter(node => node.type === NodeType.DataSectionDefinitions)[0]; this.regions = this.parseRegions(regionDefNode, dataSectionDefNode); - const pathNode = baseFileNode.children.filter(node => node.type == NodeType.AiPaths)[0]; + const pathNode = baseFileNode.children.filter(node => node.type === NodeType.AiPaths)[0]; this.pathVertices = this.parsePathVertices(pathNode); // Load global data sections immediately await this.regions[2500].load(this); const globalRegions = []; for(let id in this.regions) { - if(this.regions[id].regionType == RegionType.Global) + if(this.regions[id].regionType === RegionType.Global) globalRegions.push(this.regions[id]); } let coll = globalRegions.map(async region => { @@ -115,7 +115,7 @@ export class NfsMap { const rdnDataView = regionDefNode.children[3].dataView; while(offset < rdnDataView.byteLength - 0x10) { // Skip useless data at start of entry - while(rdnDataView.getInt16(offset) == 0) { + while(rdnDataView.getInt16(offset) === 0) { offset += 2; } offset += 0xC; @@ -137,11 +137,11 @@ export class NfsMap { const baseRegion = regionMap[baseRegionId]; if(baseRegion === undefined) continue; - if(baseRegion.regionType == RegionType.Dependency) { + if(baseRegion.regionType === RegionType.Dependency) { dependencies.push(baseRegion); continue; } - if(baseRegionId == depRegionId) { + if(baseRegionId === depRegionId) { connections.push({region: baseRegion, upperPartOnly: false}); } else if(!dependentRegions.includes(baseRegionId)) { @@ -168,7 +168,7 @@ export class NfsMap { activeRegion.connections!.forEach((r => this.regionsToRender.add(r.region))); for(const regionId in this.regions) { const r = this.regions[regionId]; - if (r.regionType == RegionType.Regular && isCloseToRegion(r, pos, this.viewDistance)) + if (r.regionType === RegionType.Regular && isCloseToRegion(r, pos, this.viewDistance)) this.regionsToRender.add(r); } @@ -234,7 +234,7 @@ export class NfsMap { // Then check if we're in any of the neighboring regions for(let i = 0; i < lastRegion.connections!.length; i++) { const r = lastRegion.connections![i]; - if(r.region.regionType == RegionType.Regular && pointInRegion(r.region, pos)) + if(r.region.regionType === RegionType.Regular && pointInRegion(r.region, pos)) return r.region; } } @@ -242,7 +242,7 @@ export class NfsMap { // Otherwise check in all regions for(let id in this.regions) { const r = this.regions[id]; - if(r.regionType == RegionType.Regular && pointInRegion(r, pos)) + if(r.regionType === RegionType.Regular && pointInRegion(r, pos)) return r; } throw 'Path vertex not in any region'; @@ -312,14 +312,14 @@ function pointInPolygon(vertices: vec2[], p: vec2): boolean { do { const next = (i + 1) % vertices.length; if(linesIntersect(vertices[i], vertices[next], p, infPoint)) { - if(orientation(vertices[i], p, vertices[next]) == 0) { + if(orientation(vertices[i], p, vertices[next]) === 0) { return onSegment(vertices[i], p, vertices[next]); } count++; } i = next; - } while(i != 0); - return (count % 2) == 1; + } while(i !== 0); + return (count % 2) === 1; } function linesIntersect(a1: vec2, b1: vec2, a2: vec2, b2: vec2) { @@ -328,18 +328,18 @@ function linesIntersect(a1: vec2, b1: vec2, a2: vec2, b2: vec2) { const o3 = orientation(a2, b2, a1); const o4 = orientation(a2, b2, b1); - if(o1 != o2 && o3 != o4) + if(o1 !== o2 && o3 !== o4) return true; - return o1 == 0 && onSegment(a1, b1, a2) - || o2 == 0 && onSegment(a1, b1, b2) - || o3 == 0 && onSegment(a2, b2, a1) - || o4 == 0 && onSegment(a2, b2, b1); + return o1 === 0 && onSegment(a1, b1, a2) + || o2 === 0 && onSegment(a1, b1, b2) + || o3 === 0 && onSegment(a2, b2, a1) + || o4 === 0 && onSegment(a2, b2, b1); } function orientation(a: vec2, b: vec2, c: vec2) { const val = (b[1] - a[1]) * (c[0] - b[0]) - (b[0] - a[0]) * (c[1] - b[1]); - if(val == 0) + if(val === 0) return 0; return (val > 0) ? 1 : 2; } @@ -401,7 +401,7 @@ function distanceToRegionPolygon(poly: vec2[], p: vec2): number { if(d < minDist) minDist = d; i = next - } while(i != 0); + } while(i !== 0); return minDist; } diff --git a/src/NeedForSpeedMostWanted/particles.ts b/src/NeedForSpeedMostWanted/particles.ts index 63fe58689..b1cf734ca 100644 --- a/src/NeedForSpeedMostWanted/particles.ts +++ b/src/NeedForSpeedMostWanted/particles.ts @@ -183,7 +183,7 @@ export class NfsParticleEmitter { public emitParticle() { let particle; - if(this.minFreeParticle == this.particlePool.length) { + if(this.minFreeParticle === this.particlePool.length) { particle = new NfsParticle(); this.particlePool.push(particle); } diff --git a/src/NeedForSpeedMostWanted/region.ts b/src/NeedForSpeedMostWanted/region.ts index 3a62ee9b1..dbf08039c 100644 --- a/src/NeedForSpeedMostWanted/region.ts +++ b/src/NeedForSpeedMostWanted/region.ts @@ -72,8 +72,8 @@ export class NfsRegion { case LoadStatus.Loaded: return true; case LoadStatus.ReadyToParse: - if(this.regionType == RegionType.Regular) { - const depNotLoaded = this.dependencies!.filter(d => d.loadStatus == LoadStatus.NotLoaded); + if(this.regionType === RegionType.Regular) { + const depNotLoaded = this.dependencies!.filter(d => d.loadStatus === LoadStatus.NotLoaded); if (depNotLoaded.length > 0) { depNotLoaded.forEach(d => { d.loadStatus = LoadStatus.Loading; @@ -82,9 +82,9 @@ export class NfsRegion { }); return false; } - if (this.dependencies!.filter(d => d.loadStatus == LoadStatus.Loading).length > 0) + if (this.dependencies!.filter(d => d.loadStatus === LoadStatus.Loading).length > 0) return false; - const depsToParse = this.dependencies!.filter(d => d.loadStatus == LoadStatus.ReadyToParse); + const depsToParse = this.dependencies!.filter(d => d.loadStatus === LoadStatus.ReadyToParse); depsToParse.forEach(d => d.parseTextures(device, renderHelper, map)); depsToParse.forEach(d => { d.parseModels(device, renderHelper.renderCache, map); @@ -111,32 +111,32 @@ export class NfsRegion { } public isLoaded() { - return this.loadStatus == LoadStatus.Loaded; + return this.loadStatus === LoadStatus.Loaded; } public async load(map: NfsMap) { assert(this.dataSections.length > 0); for(let i = 0; i < this.dataSections.length; i++) { - if(this.dataSections[i].node != undefined) + if(this.dataSections[i].node !== undefined) continue; const dataBuffer = await map.dataFetcher.fetchData(map.streamingFilePath, { rangeStart: this.dataSections[i].offset, rangeSize: this.dataSections[i].length }); - assert(dataBuffer != undefined); + assert(dataBuffer !== undefined); this.dataSections[i].node = new NfsNode(dataBuffer); this.dataSections[i].node!.parseChildren(); } } public parseTextures(device: GfxDevice, renderHelper: GfxRenderHelper, map: NfsMap) { - assert(this.dataSections.filter(s => s.node === undefined).length == 0); - const textureCollections = this.dataSections.flatMap(s => s.node!.children.filter(node => node.type == NodeType.TextureCollection)); + assert(this.dataSections.filter(s => s.node === undefined).length === 0); + const textureCollections = this.dataSections.flatMap(s => s.node!.children.filter(node => node.type === NodeType.TextureCollection)); textureCollections.forEach(node => this.parseTextureCollection(device, renderHelper.renderCache, node, map)); - const textureAnimations = this.dataSections.flatMap(s => s.node!.children.filter(node => node.type == NodeType.TextureAnimation)); + const textureAnimations = this.dataSections.flatMap(s => s.node!.children.filter(node => node.type === NodeType.TextureAnimation)); textureAnimations.forEach(node => this.parseTextureCycleAnimation(node, map)); } public parseModels(device: GfxDevice, cache: GfxRenderCache, map: NfsMap) { - assert(this.dataSections.filter(s => s.node === undefined).length == 0); - const modelCollections = this.dataSections.flatMap(s => s.node!.children.filter(node => node.type == NodeType.ModelCollection)); + assert(this.dataSections.filter(s => s.node === undefined).length === 0); + const modelCollections = this.dataSections.flatMap(s => s.node!.children.filter(node => node.type === NodeType.ModelCollection)); const modelNodes = modelCollections.flatMap(collNode => collNode.children.slice(1)); modelNodes.forEach(node => { const id = node.children[0].dataView.getUint32(0x10, true); @@ -147,12 +147,12 @@ export class NfsRegion { } public parseInstances(map: NfsMap) { - assert(this.dataSections.filter(s => s.node === undefined).length == 0); + assert(this.dataSections.filter(s => s.node === undefined).length === 0); const rootBoundingVolumes = []; for(let i = 0; i < this.dataSections.length; i++) { - if(i == 1) + if(i === 1) this.upperPartOffset = rootBoundingVolumes.length; - const instanceListNodes = this.dataSections[i].node!.children.filter(node => node.type == NodeType.InstanceList); + const instanceListNodes = this.dataSections[i].node!.children.filter(node => node.type === NodeType.InstanceList); rootBoundingVolumes.push(...instanceListNodes.flatMap(node => this.parseInstanceList(node, map))); } this.rootBoundingVolumes = rootBoundingVolumes; @@ -172,25 +172,25 @@ export class NfsRegion { instances.push(newInstance); // Do not use the old PS2 sky - if(this.id == 2600 && (i == 1 || i == 2)) + if(this.id === 2600 && (i === 1 || i === 2)) continue; // A bit messy but I haven't found a better way to determine object type const flags = dataView.getUint32(i * 0x40 + 0x18, true); - newInstance.invertedFaces = (flags & 0x400000) != 0; - if(this.id == 2600 && i == 0) + newInstance.invertedFaces = (flags & 0x400000) !== 0; + if(this.id === 2600 && i === 0) newInstance.type = InstanceType.Sky; - else if(((flags >> 16) & 0xff) == 4) { - if(((flags >> 8) & 0xff) != 0x80) + else if(((flags >> 16) & 0xff) === 4) { + if(((flags >> 8) & 0xff) !== 0x80) newInstance.type = InstanceType.Shadow; else newInstance.type = InstanceType.Hidden; } - else if((flags & 0xff0fffff) == 0x2008070) + else if((flags & 0xff0fffff) === 0x2008070) newInstance.type = InstanceType.TrackBarrier; - else if((flags & 0xf) == 0x2) + else if((flags & 0xf) === 0x2) newInstance.type = InstanceType.Hidden; - else if((flags & 0x10) == 0x10 && NfsRegion.hiddenAnimObjectRegions.includes(this.id)) + else if((flags & 0x10) === 0x10 && NfsRegion.hiddenAnimObjectRegions.includes(this.id)) newInstance.type = InstanceType.Hidden; const worldMat: mat4 = mat4.create(); @@ -208,11 +208,11 @@ export class NfsRegion { const modelIndex = dataView.getUint16(offset, true); newInstance.model = models[modelIndex]; - if(newInstance.model !== undefined && (flags & 0x100010) != 0 && newInstance.model.isHiddenModel) + if(newInstance.model !== undefined && (flags & 0x100010) !== 0 && newInstance.model.isHiddenModel) newInstance.type = InstanceType.Hidden; } - return this.parseBvhTree(instanceNode.children.filter(n => n.type == NodeType.InstanceListBvh)[0], instances); + return this.parseBvhTree(instanceNode.children.filter(n => n.type === NodeType.InstanceListBvh)[0], instances); } private parseBvhTree(bvhTreeNode: NfsNode, instances: NfsInstance[]): NfsBoundingVolume { @@ -259,7 +259,7 @@ export class NfsRegion { const mipMapCount = textureInfoDataView.getUint8(offset + 0x4E); const wrapMode = textureInfoDataView.getUint8(offset + 0x4F); const transparencyInfo = textureInfoDataView.getUint16(offset + 0x55, true); - const alphaTest = (transparencyInfo & 0xFF) == 1 || ((transparencyInfo & 0xFF) == 2 && transparencyInfo != 2); + const alphaTest = (transparencyInfo & 0xFF) === 1 || ((transparencyInfo & 0xFF) === 2 && transparencyInfo !== 2); const transparencyType = transparencyInfo >> 8; const cullMode = textureInfoDataView.getUint8(offset + 0x57); const scrollAnimationType = textureInfoDataView.getUint16(offset + 0x52, true); @@ -299,9 +299,9 @@ export class NfsRegion { texture.alphaTest = alphaTest; texture.transparencyType = transparencyType; texture.faceCulling = cullMode < 2 && !alphaTest; - if(scrollAnimationType != 0) { + if(scrollAnimationType !== 0) { texture.scrollAnimation = { - interval: scrollAnimationType == 2 ? textureInfoDataView.getInt16(offset + 0x58, true) / 256 : -1, + interval: scrollAnimationType === 2 ? textureInfoDataView.getInt16(offset + 0x58, true) / 256 : -1, scrollSpeed: [ textureInfoDataView.getInt16(offset + 0x5a, true) / 1024, textureInfoDataView.getInt16(offset + 0x5c, true) / 1024, @@ -360,21 +360,21 @@ export class NfsRegion { private parseTextureCycleAnimation(node: NfsNode, map: NfsMap) { const texId = node.children[1].dataView.getUint32(0x18, true); const texture = map.textureCache[texId]; - assert(texture != undefined); + assert(texture !== undefined); const frameCount = node.children[1].dataView.getUint32(0x1c, true); const frequency = node.children[1].dataView.getUint32(0x20, true); const frames = []; for(let i = 0; i < frameCount; i++) { const frameTexId = node.children[2].dataView.getUint32(0x10 * i, true); const frame = map.textureCache[frameTexId]; - assert(frame != undefined); + assert(frame !== undefined); frames.push(frame); } texture.cycleAnimation = { frequency, frames }; } private parseParticleEmitterGroups(map: NfsMap) { - const emitterCollections = this.dataSections.flatMap(s => s.node!.children.filter(node => node.type == NodeType.ParticleEmitter)); + const emitterCollections = this.dataSections.flatMap(s => s.node!.children.filter(node => node.type === NodeType.ParticleEmitter)); emitterCollections.forEach(n => this.parseParticleEmitterGroup(n, map)); } @@ -383,7 +383,7 @@ export class NfsRegion { const count = dataView.getUint32(0x8, true); let offset = 0x10; for(let i = 0; i < count; i++) { - while(dataView.getUint32(offset + 0x8, true) == 0) { + while(dataView.getUint32(offset + 0x8, true) === 0) { offset += 0x30; } const type = dataView.getUint32(offset, true); @@ -423,9 +423,9 @@ export class NfsBoundingVolumeGroup { public collectInstancesToRender(collection: NfsInstance[], frustum: Frustum, fullyInside: boolean) { if (!fullyInside) { const state = frustum.intersect(this.boundingBox); - if (state == IntersectionState.Outside) + if (state === IntersectionState.Outside) return; - fullyInside = state == IntersectionState.Inside; + fullyInside = state === IntersectionState.Inside; } this.children.forEach(c => c.collectInstancesToRender(collection, frustum, fullyInside)); @@ -441,7 +441,7 @@ export class NfsInstance { public invertedFaces: boolean; public collectInstancesToRender(collection: NfsInstance[], frustum: Frustum, fullyInside: boolean) { - if(!fullyInside && frustum.intersect(this.boundingBox) == IntersectionState.Outside) + if(!fullyInside && frustum.intersect(this.boundingBox) === IntersectionState.Outside) return; collection.push(this); @@ -457,9 +457,9 @@ export class NfsModel { constructor(device: GfxDevice, cache: GfxRenderCache, map: NfsMap, modelNode: NfsNode) { this.vertInfos = []; - assert(modelNode.type == NodeType.Model); + assert(modelNode.type === NodeType.Model); - const meshDataNode = modelNode.children.filter((node) => node.type == NodeType.Mesh)[0]; + const meshDataNode = modelNode.children.filter((node) => node.type === NodeType.Mesh)[0]; const meshHeaderNode = meshDataNode.children[0]; const dataView = meshHeaderNode.dataView; const submeshCount = dataView.getInt32(0x10, true); @@ -467,7 +467,7 @@ export class NfsModel { const nameStartBytes = modelNode.children[0].dataBuffer.subarray(0xA0, 6).createTypedArray(Uint8Array); const nameStart = NfsModel.textDecoder.decode(nameStartBytes).toUpperCase(); - this.isHiddenModel = nameStart == "SHADOW" || nameStart.startsWith("ANM"); + this.isHiddenModel = nameStart === "SHADOW" || nameStart.startsWith("ANM"); this.indexBuffer = makeStaticDataBufferFromSlice(device, GfxBufferUsage.Index, meshDataNode.children[2].dataBuffer.slice(0, indexCount * 2)); @@ -487,7 +487,7 @@ export class NfsModel { const vertexCount = submeshDataView.getInt32(submeshBaseOffset + 0x24, true); const indexCount = 3 * submeshDataView.getInt32(submeshBaseOffset + 0x28, true); const indexOffset = submeshDataView.getInt32(submeshBaseOffset + 0x2C, true); - const byteStride = shaderType == 0 || shaderType == 6 || shaderType == 5 ? 0x24 : shaderType == 19 ? 0x2c : 0x3c; + const byteStride = shaderType === 0 || shaderType === 6 || shaderType === 5 ? 0x24 : shaderType === 19 ? 0x2c : 0x3c; const diffuseTexture = textureList[submeshDataView.getUint8(submeshBaseOffset)]; const normalMap = textureList[submeshDataView.getUint8(submeshBaseOffset + 1)]; const specularMap = textureList[submeshDataView.getUint8(submeshBaseOffset + 3)]; @@ -495,7 +495,7 @@ export class NfsModel { const vertexOffset = currentVertexOffset; const vertexListIndex = currentVertexListIndex; - if((vertexOffset + vertexCount) * byteStride == meshDataNode.children[3 + currentVertexListIndex].dataBuffer.byteLength) { + if((vertexOffset + vertexCount) * byteStride === meshDataNode.children[3 + currentVertexListIndex].dataBuffer.byteLength) { // Reached end of vertex list currentVertexOffset = 0; currentVertexListIndex++; @@ -504,12 +504,12 @@ export class NfsModel { currentVertexOffset += vertexCount; } - if(this.vertexBuffers.length == vertexListIndex) { + if(this.vertexBuffers.length === vertexListIndex) { // create new buffer if the current vertex list doesn't have one yet this.vertexBuffers.push(makeStaticDataBufferFromSlice(device, GfxBufferUsage.Vertex, meshDataNode.children[3 + vertexListIndex].dataBuffer)); } - if(diffuseTexture == undefined) + if(diffuseTexture === undefined) continue; const textureMappings: NfsTexture[] = [diffuseTexture]; diff --git a/src/NeedForSpeedMostWanted/render.ts b/src/NeedForSpeedMostWanted/render.ts index b7e44aa36..8fc7841ad 100644 --- a/src/NeedForSpeedMostWanted/render.ts +++ b/src/NeedForSpeedMostWanted/render.ts @@ -113,9 +113,9 @@ export class NfsRenderer implements SceneGfx { instancesToRender.forEach(instance => { if(instance.worldMatrix === undefined) return; - if(instance.type == InstanceType.TrackBarrier && !this.showTrackBarriers) + if(instance.type === InstanceType.TrackBarrier && !this.showTrackBarriers) return; - if(instance.type == InstanceType.Hidden && !this.showHidden) + if(instance.type === InstanceType.Hidden && !this.showHidden) return; const model = instance.model; if(model === undefined) @@ -128,7 +128,7 @@ export class NfsRenderer implements SceneGfx { offs += fillMatrix4x3(d, offs, instance.worldMatrix); let cullMode = GfxCullMode.Back; - if(vInfo.shaderType == 5 || vInfo.shaderType == 6 || !vInfo.textureMappings[0].faceCulling) + if(vInfo.shaderType === 5 || vInfo.shaderType === 6 || !vInfo.textureMappings[0].faceCulling) cullMode = GfxCullMode.None; else if(instance.invertedFaces) cullMode = GfxCullMode.Front; @@ -142,13 +142,13 @@ export class NfsRenderer implements SceneGfx { const frameNumber = Math.floor(viewerInput.time * anim.frequency / 1000) % anim.frames.length; texMappings[0] = anim.frames[frameNumber]; } - if(instance.type == InstanceType.Sky) { + if(instance.type === InstanceType.Sky) { renderInst.setMegaStateFlags({attachmentsState: attachmentStatesTranslucent, depthWrite: false}); renderInst.setGfxProgram(this.gfxPrograms[5]); renderInst.sortKey = this.sortKeySky; } else if(diffuseTexture.transparencyType > 0) { - if(instance.type != InstanceType.Shadow) { + if(instance.type !== InstanceType.Shadow) { renderInst.sortKey = this.sortKeyTranslucent; instance.boundingBox.centerPoint(this.aabbCenter); const depth = computeViewSpaceDepthFromWorldSpacePoint(viewerInput.camera.viewMatrix, this.aabbCenter); @@ -157,14 +157,14 @@ export class NfsRenderer implements SceneGfx { else { renderInst.sortKey = this.sortKeyTranslucent; } - if(diffuseTexture.transparencyType == 1) { + if(diffuseTexture.transparencyType === 1) { renderInst.setMegaStateFlags({attachmentsState: attachmentStatesTranslucent, depthWrite: false}); } - if(diffuseTexture.transparencyType == 2) { + if(diffuseTexture.transparencyType === 2) { renderInst.setMegaStateFlags({attachmentsState: attachmentStatesAdditive, depthWrite: false}); fog = 0; } - else if(diffuseTexture.transparencyType == 3) { + else if(diffuseTexture.transparencyType === 3) { renderInst.setMegaStateFlags({attachmentsState: attachmentStatesSubtractive, depthWrite: false}); } } @@ -172,17 +172,17 @@ export class NfsRenderer implements SceneGfx { renderInst.setGfxProgram(this.gfxPrograms[1]); renderInst.sortKey = this.sortKeyAlpha; } - else if(vInfo.shaderType == 1 || vInfo.shaderType == 3) + else if(vInfo.shaderType === 1 || vInfo.shaderType === 3) renderInst.setGfxProgram(this.gfxPrograms[3]); - else if(vInfo.shaderType == 5) + else if(vInfo.shaderType === 5) renderInst.setGfxProgram(this.gfxPrograms[4]); if(diffuseTexture.scrollAnimation !== undefined) { const anim = diffuseTexture.scrollAnimation; - const animFactor = anim.interval == -1 ? viewerInput.time / 1000 : Math.floor(viewerInput.time / anim.interval / 1000); + const animFactor = anim.interval === -1 ? viewerInput.time / 1000 : Math.floor(viewerInput.time / anim.interval / 1000); fillVec4v(d, offs, [(anim.scrollSpeed[0] * animFactor) % 1, (anim.scrollSpeed[1] * animFactor) % 1, fog, 0]); } - else if(instance.type == InstanceType.Sky) { + else if(instance.type === InstanceType.Sky) { fillVec4v(d, offs, [(viewerInput.time / 70000) % 5.0, 0, 0, 0]); } else { @@ -252,7 +252,7 @@ export class NfsRenderer implements SceneGfx { const cameraPos: vec3 = [viewerInput.camera.worldMatrix[12], viewerInput.camera.worldMatrix[13], viewerInput.camera.worldMatrix[14]]; - if(!this.streamingFreezed || this.closestPathVertex == null) { + if(!this.streamingFreezed || this.closestPathVertex === null) { this.closestPathVertex = this.map.getClosestPathVertex([-cameraPos[0], cameraPos[2]]); this.activeRegion = this.closestPathVertex.region; } @@ -265,11 +265,11 @@ export class NfsRenderer implements SceneGfx { this.map.regions[2600].rootBoundingVolumes[0].collectInstancesToRender(instancesToRender, frustum, false); regionsToRender.forEach(regionRenderCommand => { const region = regionRenderCommand.region; - if(region.regionType == RegionType.Panorama && !this.activeRegion.ensureReady(device, this.renderHelper, this.map)) + if(region.regionType === RegionType.Panorama && !this.activeRegion.ensureReady(device, this.renderHelper, this.map)) return; if(!region.ensureReady(device, this.renderHelper, this.map)) return; - if(!this.showPanoramas && region.regionType == RegionType.Panorama) + if(!this.showPanoramas && region.regionType === RegionType.Panorama) return; for(let i = regionRenderCommand.upperPartOnly ? region.upperPartOffset : 0; i < region.rootBoundingVolumes.length; i++) { diff --git a/src/OcarinaOfTime3D/cmb.ts b/src/OcarinaOfTime3D/cmb.ts index 326a301fe..2b3eeed87 100644 --- a/src/OcarinaOfTime3D/cmb.ts +++ b/src/OcarinaOfTime3D/cmb.ts @@ -566,8 +566,8 @@ function readMatsChunk(cmb: CMB, buffer: ArrayBufferSlice) { const blendEnabled = blendMode !== 0; // Making a guess that this is LogicOpEnabled / LogicOp. - assert(view.getUint8(offs + 0x139) == 0); - assert(view.getUint16(offs + 0x13A, true) == 0); + assert(view.getUint8(offs + 0x139) === 0); + assert(view.getUint16(offs + 0x13A, true) === 0); const blendSrcFactorRGB: GfxBlendFactor = blendEnabled ? view.getUint16(offs + 0x13C, true) : GfxBlendFactor.One; const blendDstFactorRGB: GfxBlendFactor = blendEnabled ? view.getUint16(offs + 0x13E, true) : GfxBlendFactor.Zero; diff --git a/src/OcarinaOfTime3D/lm3d_scenes.ts b/src/OcarinaOfTime3D/lm3d_scenes.ts index 438057d78..4bd4ec9e2 100644 --- a/src/OcarinaOfTime3D/lm3d_scenes.ts +++ b/src/OcarinaOfTime3D/lm3d_scenes.ts @@ -150,9 +150,9 @@ class SceneDesc implements Viewer.SceneDesc { const posY = assertExists(getField(lightInfo, record, "pos_y")); const posZ = assertExists(getField(lightInfo, record, "pos_z")); - assert(posX == 0); - assert(posY == 0); - assert(posZ == 0); + assert(posX === 0); + assert(posY === 0); + assert(posZ === 0); const ambientR = assertExists(getField(lightInfo, record, "ambient_x")) / 0xFF; const ambientG = assertExists(getField(lightInfo, record, "ambient_y")) / 0xFF; @@ -230,7 +230,7 @@ class SceneDesc implements Viewer.SceneDesc { const record = roomFurnitureEntries.records[j]; const cmbFilename = assertExists(getField(roomFurnitureEntries, record, "dmd_name")); - const cmbFile = outerRoomGar.files.find((file) => file.name == `${cmbFilename}.cmb`); + const cmbFile = outerRoomGar.files.find((file) => file.name === `${cmbFilename}.cmb`); // TODO(jstpierre): What to do if the file is missing? if (cmbFile === undefined) diff --git a/src/OcarinaOfTime3D/render.ts b/src/OcarinaOfTime3D/render.ts index ef73b7b84..3ac2aa185 100644 --- a/src/OcarinaOfTime3D/render.ts +++ b/src/OcarinaOfTime3D/render.ts @@ -155,7 +155,7 @@ uniform samplerCube u_Cubemap; case 1: // Texture 1 has TexCoord 1 return `texture(SAMPLER_2D(u_Texture1), v_TexCoord1.xy)`; case 2: // Texture 2 has either TexCoord 1 or 2 as input - if (this.material.texCoordConfig == TexCoordConfig.Config0110 || this.material.texCoordConfig == TexCoordConfig.Config0111 || this.material.texCoordConfig == TexCoordConfig.Config0112) + if (this.material.texCoordConfig === TexCoordConfig.Config0110 || this.material.texCoordConfig === TexCoordConfig.Config0111 || this.material.texCoordConfig === TexCoordConfig.Config0112) return `texture(SAMPLER_2D(u_Texture2), v_TexCoord1.xy)`; else return `texture(SAMPLER_2D(u_Texture2), v_TexCoord2.xy)`; @@ -361,12 +361,12 @@ uniform samplerCube u_Cubemap; private IsLUTSupported(lutType: MatLutType): boolean { const config = this.material.lightingConfig; switch(lutType){ - case MatLutType.Distribution0: return config != LightingConfig.Config1; - case MatLutType.Distribution1: return config != LightingConfig.Config0 && config != LightingConfig.Config1 && config != LightingConfig.Config5; + case MatLutType.Distribution0: return config !== LightingConfig.Config1; + case MatLutType.Distribution1: return config !== LightingConfig.Config0 && config !== LightingConfig.Config1 && config !== LightingConfig.Config5; case MatLutType.Fresnel: return config !== LightingConfig.Config0 && config !== LightingConfig.Config2 && config !== LightingConfig.Config4; - case MatLutType.ReflectR: return config != LightingConfig.Config3; + case MatLutType.ReflectR: return config !== LightingConfig.Config3; case MatLutType.ReflectG: - case MatLutType.ReflectB: return config == LightingConfig.Config4 || config == LightingConfig.Config5 || config == LightingConfig.Config7; + case MatLutType.ReflectB: return config === LightingConfig.Config4 || config === LightingConfig.Config5 || config === LightingConfig.Config7; } } @@ -741,7 +741,7 @@ class MaterialInstance { this.gfxSamplers.push(gfxSampler); const cmb = this.cmbData.cmb; - if (i == 0 && cmb.textures[binding.textureIdx].dimension === GfxTextureDimension.Cube) + if (i === 0 && cmb.textures[binding.textureIdx].dimension === GfxTextureDimension.Cube) this.textureMappings[4].gfxSampler = gfxSampler; else this.textureMappings[i].gfxSampler = gfxSampler; diff --git a/src/OcarinaOfTime3D/zar.ts b/src/OcarinaOfTime3D/zar.ts index 932a23840..43ca89569 100644 --- a/src/OcarinaOfTime3D/zar.ts +++ b/src/OcarinaOfTime3D/zar.ts @@ -42,7 +42,7 @@ function parseZelda(buffer: ArrayBufferSlice): ZAR { const magic: Magic = readString(buffer, 0x00, 0x04, false) as Magic; assert([Magic.ZAR1, Magic.GAR2].includes(magic)); - const version = magic == Magic.ZAR1 ? CMB.Version.Ocarina : CMB.Version.Majora; + const version = magic === Magic.ZAR1 ? CMB.Version.Ocarina : CMB.Version.Majora; const size = view.getUint32(0x04, true); const numFileTypes = view.getUint16(0x08, true); diff --git a/src/OcarinaOfTime3D/zsi.ts b/src/OcarinaOfTime3D/zsi.ts index d4a97e65e..f08671f60 100644 --- a/src/OcarinaOfTime3D/zsi.ts +++ b/src/OcarinaOfTime3D/zsi.ts @@ -369,7 +369,7 @@ function readSceneHeaders(version: Version, name: string, buffer: ArrayBufferSli const cmdType = cmd1 >>> 24; - if (cmdType == HeaderCommands.End) + if (cmdType === HeaderCommands.End) break; switch (cmdType) { @@ -421,7 +421,7 @@ function readRoomHeaders(version: Version, buffer: ArrayBufferSlice, offs: numbe const cmdType = cmd1 >>> 24; - if (cmdType == HeaderCommands.End) + if (cmdType === HeaderCommands.End) break; switch (cmdType) { diff --git a/src/PaperMario64/render.ts b/src/PaperMario64/render.ts index b0362f968..215e50b7a 100644 --- a/src/PaperMario64/render.ts +++ b/src/PaperMario64/render.ts @@ -270,7 +270,7 @@ class ModelTreeLeafInstance { if (this.renderModeProperty === 0x01 || this.renderModeProperty === 0x04) { this.renderMode = RenderMode.OPA; - } else if (this.renderModeProperty == 0x05 || this.renderModeProperty === 0x07 || this.renderModeProperty === 0x0D || this.renderModeProperty === 0x10) { + } else if (this.renderModeProperty === 0x05 || this.renderModeProperty === 0x07 || this.renderModeProperty === 0x0D || this.renderModeProperty === 0x10) { this.renderMode = RenderMode.DEC; } else { this.renderMode = RenderMode.XLU; diff --git a/src/Pilotwings64/Scenes.ts b/src/Pilotwings64/Scenes.ts index 34d8ef16d..4ecf01bf0 100644 --- a/src/Pilotwings64/Scenes.ts +++ b/src/Pilotwings64/Scenes.ts @@ -124,7 +124,7 @@ function parseUVCT_Chunk(chunk: Pilotwings64FSFileChunk): UVCT_Chunk { for (let j = 0; j < matrixCount; j++) { const mtx = mat4.create(); offs += RDP.readMatrixRDP(mtx, view, offs); - if (j == 0) { // TODO: figure out what other matrices are for + if (j === 0) { // TODO: figure out what other matrices are for placement = mtx; } assert(mtx[15] === 1.0); @@ -541,7 +541,7 @@ function parseUVTX_Chunk(chunk: Pilotwings64FSFileChunk, name: string): UVTX { const tile = tiles[i]; if (tile.lrs === 0 && tile.lrt === 0) { // technically a 1x1 texture - assert(scaleS != 0 || scaleT != 0 || combineScaleS != 0 || combineScaleT != 0) + assert(scaleS !== 0 || scaleT !== 0 || combineScaleS !== 0 || combineScaleT !== 0) // convert stored dimensions to fixed point tile.lrs = view.getUint16(dlEnd + 0x00) * 4 - 4; tile.lrt = view.getUint16(dlEnd + 0x02) * 4 - 4; @@ -568,7 +568,7 @@ function parseUVTX_Chunk(chunk: Pilotwings64FSFileChunk, name: string): UVTX { levels.push({ width: tileW, height: tileH, pixels: dst, shiftS: tile.shifts, shiftT: tile.shiftt, usesPaired }); // For now, use only one LOD. - if (pairedIndex == 0xfff) + if (pairedIndex === 0xfff) break; } @@ -680,7 +680,7 @@ interface UVMD { } function parseUVMD(file: Pilotwings64FSFile): UVMD { - assert(file.chunks.length == 1); + assert(file.chunks.length === 1); const view = file.chunks[0].buffer.createDataView(); const vertCount = view.getUint16(0x0); const lodCount = view.getUint8(0x02); @@ -743,7 +743,7 @@ function parseUVMD(file: Pilotwings64FSFile): UVMD { vertBuffer[write] = (index & 0x3FFF) + read; } } - assert(indexData.length - indexOffset == 3 * triCount); + assert(indexData.length - indexOffset === 3 * triCount); materials.push({ rspModeInfo, textureIndex, indexOffset, triCount }); } parts.push({ indexData: new Uint16Array(indexData), materials, attachmentLevel }); @@ -833,7 +833,7 @@ function parseSPTH(file: Pilotwings64FSFile): SPTH { } else if (tag === 'SCPR') { currTrack = rTrack; } else { - assert(tag === 'SCP#' && i == file.chunks.length - 1); + assert(tag === 'SCP#' && i === file.chunks.length - 1); break; } @@ -1138,7 +1138,7 @@ function parseUPWT(file: Pilotwings64FSFile): UPWT { // this is read from a table let modelIndex = 0xd9 + special + 2 * other + 4 * size; if (special > 1) { - // goal ring, game skips if special != 3 + // goal ring, game skips if special !== 3 modelIndex = 0xf1; } rings.push({ position, angles, axis, modelIndex }); @@ -1293,7 +1293,7 @@ function parseUVEN_Chunk(chunk: Pilotwings64FSFileChunk): UVEN { let oceanModel: number | undefined; let oceanFlags: number | undefined; let offs = 0x01; - if (modelCount == 2) { + if (modelCount === 2) { skyboxModel = view.getUint16(offs + 0x00); skyboxFlags = view.getUint8(offs + 0x02); offs += 0x03; diff --git a/src/PokemonSnap/motion.ts b/src/PokemonSnap/motion.ts index 1d050b082..2ee4072d7 100644 --- a/src/PokemonSnap/motion.ts +++ b/src/PokemonSnap/motion.ts @@ -290,7 +290,7 @@ export class MotionParser extends MIPS.NaiveInterpreter { console.warn("bad animation address in motion", hexzero(a1.value, 8)); break; } - let index = this.animations.findIndex((a) => a == a1.value); + let index = this.animations.findIndex((a) => a === a1.value); if (index === -1) { index = this.animations.length; this.animations.push(a1.value); diff --git a/src/PokemonSnap/render.ts b/src/PokemonSnap/render.ts index 4bf8c1e71..776963f45 100644 --- a/src/PokemonSnap/render.ts +++ b/src/PokemonSnap/render.ts @@ -380,7 +380,7 @@ export class ModelRenderer { this.renderers[i].animator.setTrack(newAnim.tracks[i]); this.renderers[i].setTransfromFromNode(); - if (newAnim.materialTracks.length == 0 || newAnim.materialTracks[i].length === 0) + if (newAnim.materialTracks.length === 0 || newAnim.materialTracks[i].length === 0) for (let j = 0; j < this.renderers[i].materials.length; j++) this.renderers[i].materials[j].setTrack(null); else diff --git a/src/PokemonSnap/room.ts b/src/PokemonSnap/room.ts index 6201b8b5a..9ef92c3e8 100644 --- a/src/PokemonSnap/room.ts +++ b/src/PokemonSnap/room.ts @@ -1698,7 +1698,7 @@ class StateParser extends MIPS.NaiveInterpreter { this.valid = false; break; } - let index = this.animationAddresses.findIndex((a) => a == a1.value); + let index = this.animationAddresses.findIndex((a) => a === a1.value); if (index === -1) { index = this.animationAddresses.length; this.animationAddresses.push(a1.value); diff --git a/src/SourceEngine/BSPFile.ts b/src/SourceEngine/BSPFile.ts index 655b21b5a..e6d0335a5 100644 --- a/src/SourceEngine/BSPFile.ts +++ b/src/SourceEngine/BSPFile.ts @@ -1984,7 +1984,7 @@ export class BSPFile { vec3.set(overlayInfo.basis[0], vecUVPoint0Z, vecUVPoint1Z, vecUVPoint2Z); vec3.cross(overlayInfo.basis[1], overlayInfo.normal, overlayInfo.basis[0]); - if (vecUVPoint3Z == 1.0) + if (vecUVPoint3Z === 1.0) vec3.negate(overlayInfo.basis[1], overlayInfo.basis[1]); vec2.set(overlayInfo.planePoints[0], vecUVPoint0X, vecUVPoint0Y); diff --git a/src/SourceEngine/Materials/MaterialParameters.ts b/src/SourceEngine/Materials/MaterialParameters.ts index 5e3f96578..3891de10b 100644 --- a/src/SourceEngine/Materials/MaterialParameters.ts +++ b/src/SourceEngine/Materials/MaterialParameters.ts @@ -730,7 +730,7 @@ class MaterialProxy_PlayerProximity { } public update(map: ParameterMap, renderContext: SourceRenderContext, entityParams: EntityMaterialParameters | null): void { - if (entityParams == null) + if (entityParams === null) return; const scale = paramGetNum(map, this.scale); @@ -904,7 +904,7 @@ class MaterialProxy_EntityRandom { } public update(map: ParameterMap, renderContext: SourceRenderContext, entityParams: EntityMaterialParameters | null): void { - if (entityParams == null) + if (entityParams === null) return; const scale = paramGetNum(map, this.scale); diff --git a/src/SourceEngine/VMT.ts b/src/SourceEngine/VMT.ts index e584a0336..0723ae7e6 100644 --- a/src/SourceEngine/VMT.ts +++ b/src/SourceEngine/VMT.ts @@ -106,7 +106,7 @@ export class ValveKeyValueParser { let val = ""; while (this.hastok()) { const tok = this.chew(true); - if (tok == delim) + if (tok === delim) return val; else val += tok; diff --git a/src/StarFoxAdventures/Objects/Classes.ts b/src/StarFoxAdventures/Objects/Classes.ts index 892e74f6a..57ae07a49 100644 --- a/src/StarFoxAdventures/Objects/Classes.ts +++ b/src/StarFoxAdventures/Objects/Classes.ts @@ -482,7 +482,7 @@ export const SFA_CLASSES: {[num: number]: typeof SFAClass} = { constructor(obj: ObjectInstance, data: DataView) { super(obj, data); commonSetup(obj, data, 0x18); - const modelNum = data.getInt8(0x19) != 0 ? 1 : 0; + const modelNum = data.getInt8(0x19) !== 0 ? 1 : 0; obj.setModelNum(modelNum); } }, @@ -597,7 +597,7 @@ export const SFA_CLASSES: {[num: number]: typeof SFAClass} = { commonSetup(obj, data, 0x18, 0x19); obj.roll = 0; const scaleParam = data.getInt16(0x1c); - if (scaleParam != 0) + if (scaleParam !== 0) obj.scale *= 0.1 * scaleParam; } }, diff --git a/src/StarFoxAdventures/WorldLights.ts b/src/StarFoxAdventures/WorldLights.ts index e57949b30..15326dc3e 100644 --- a/src/StarFoxAdventures/WorldLights.ts +++ b/src/StarFoxAdventures/WorldLights.ts @@ -127,7 +127,7 @@ export class WorldLights { if (!(light.type & typeMask)) continue; - if (light.type == LightType.DIRECTIONAL) + if (light.type === LightType.DIRECTIONAL) // Sun and moon get massive influence light.probedInfluence = 1000.0; else { diff --git a/src/StarFoxAdventures/maps.ts b/src/StarFoxAdventures/maps.ts index e0a420c69..f619e78b7 100644 --- a/src/StarFoxAdventures/maps.ts +++ b/src/StarFoxAdventures/maps.ts @@ -38,7 +38,7 @@ export function getBlockInfo(mapsBin: DataView, mapInfo: MapInfo, x: number, y: const blockInfo = mapsBin.getUint32(mapInfo.blockTableOffset + 4 * blockIndex); const sub = (blockInfo >>> 17) & 0x3F; const mod = (blockInfo >>> 23); - if (mod == 0xff) + if (mod === 0xff) return null; return {mod, sub}; } @@ -161,7 +161,7 @@ export class MapInstance { this.blocks.push(row); for (let x = 0; x < this.numCols; x++) { const blockInfo = this.blockInfoTable[z][x]; - if (blockInfo == null) { + if (blockInfo === null) { row.push(null); continue; } @@ -335,7 +335,7 @@ export class AncientMapSceneDesc implements Viewer.SceneDesc { for (let row = 0; row < numRows; row++) { for (let col = 0; col < numCols; col++) { const b = map.blocks[row][col]; - if (b == null) { + if (b === null) { blockTable[row][col] = null; } else { const newValue = b.split('.', 2); diff --git a/src/StarFoxAdventures/materials.ts b/src/StarFoxAdventures/materials.ts index 12a1adcf4..3e4e2e7ab 100644 --- a/src/StarFoxAdventures/materials.ts +++ b/src/StarFoxAdventures/materials.ts @@ -223,7 +223,7 @@ export abstract class StandardMaterial extends MaterialBase { protected rebuildInternal() { this.rebuildSpecialized(); - this.mb.setCullMode((this.shader.flags & ShaderFlags.CullBackface) != 0 ? GX.CullMode.BACK : GX.CullMode.NONE); + this.mb.setCullMode((this.shader.flags & ShaderFlags.CullBackface) !== 0 ? GX.CullMode.BACK : GX.CullMode.NONE); if (this.blendOverride !== undefined) { this.blendOverride(this.mb); @@ -1154,7 +1154,7 @@ class StandardObjectMaterial extends StandardMaterial { private setupShaderLayers(preProbe: boolean, fooFlag: boolean /* TODO: better name */) { for (let i = 0; i < this.shader.layers.length; i++) { const layer = this.shader.layers[i]; - if (!!(layer.tevMode & 0x80) == preProbe) { + if (!!(layer.tevMode & 0x80) === preProbe) { if (layer.texId !== null) { const texMap = this.mb.genTexMap(makeMaterialTexture(this.texFetcher.getTexture(this.cache, layer.texId, true))); // TODO: support scrollable textures (e.g. eyeballs) diff --git a/src/StarFoxAdventures/modelexhibit.ts b/src/StarFoxAdventures/modelexhibit.ts index c71841552..0fcbaa92d 100644 --- a/src/StarFoxAdventures/modelexhibit.ts +++ b/src/StarFoxAdventures/modelexhibit.ts @@ -250,7 +250,7 @@ class ModelExhibitRenderer extends SFARenderer { mat4.mul(jointMtx, jointMtx, matrix); const jointPt = vec3.create(); mat4.getTranslation(jointPt, jointMtx); - if (joint.parent != 0xff) { + if (joint.parent !== 0xff) { const parentMtx = mat4.clone(modelInst.skeletonInst!.getJointMatrix(joint.parent)); mat4.mul(parentMtx, parentMtx, matrix); const parentPt = vec3.create(); diff --git a/src/StarFoxAdventures/modelloader.ts b/src/StarFoxAdventures/modelloader.ts index b973e70dc..dedfc24e5 100644 --- a/src/StarFoxAdventures/modelloader.ts +++ b/src/StarFoxAdventures/modelloader.ts @@ -541,7 +541,7 @@ export function loadModel(data: DataView, texFetcher: TextureFetcher, materialFa } // const transIsPresent = blockDv.getUint32(0xa4); - // if (transIsPresent != 0) { + // if (transIsPresent !== 0) { // console.log(`transIsPresent was 0x${transIsPresent.toString(16)} in this model`); // model.modelTranslate = readVec3(blockDv, 0x44); // console.log(`trans: ${this.modelTranslate}`); @@ -556,7 +556,7 @@ export function loadModel(data: DataView, texFetcher: TextureFetcher, materialFa if (joint.boneNum !== i) throw Error(`wtf? joint's bone number doesn't match its index!`); - model.skeleton.addJoint(joint.parent != 0xff ? joint.parent : undefined, joint.translation); + model.skeleton.addJoint(joint.parent !== 0xff ? joint.parent : undefined, joint.translation); vec3.negate(model.invBindTranslations[i], joint.bindTranslation); } } diff --git a/src/StarFoxAdventures/objects.ts b/src/StarFoxAdventures/objects.ts index 386589604..3eadf92c2 100644 --- a/src/StarFoxAdventures/objects.ts +++ b/src/StarFoxAdventures/objects.ts @@ -69,7 +69,7 @@ export class ObjectType { this.name = ''; let offs = isEarlyObject ? 0x58 : 0x91; let c; - while ((c = this.data.getUint8(offs)) != 0) { + while ((c = this.data.getUint8(offs)) !== 0) { this.name += String.fromCharCode(c); offs++; } diff --git a/src/StarFoxAdventures/resource.ts b/src/StarFoxAdventures/resource.ts index 254cb282e..1c51b6d97 100644 --- a/src/StarFoxAdventures/resource.ts +++ b/src/StarFoxAdventures/resource.ts @@ -36,7 +36,7 @@ function loadZLB(compData: ArrayBufferSlice): ArrayBufferLike { const dv = compData.createDataView(); const header = new ZLBHeader(dv); - if (header.magic != stringToFourCC('ZLB\0')) { + if (header.magic !== stringToFourCC('ZLB\0')) { throw Error(`Invalid magic identifier 0x${hexzero(header.magic, 8)}`); } diff --git a/src/StarFoxAdventures/textures.ts b/src/StarFoxAdventures/textures.ts index 9dc6f984f..9aa0f662a 100644 --- a/src/StarFoxAdventures/textures.ts +++ b/src/StarFoxAdventures/textures.ts @@ -118,7 +118,7 @@ function loadTexture(cache: GfxRenderCache, texData: ArrayBufferSlice, isBeta: b } function isValidTextureTabValue(tabValue: number) { - return tabValue != 0xFFFFFFFF && (tabValue & 0x80000000) != 0; + return tabValue !== 0xFFFFFFFF && (tabValue & 0x80000000) !== 0; } function loadFirstValidTexture(cache: GfxRenderCache, tab: DataView, bin: ArrayBufferSlice, isBeta: boolean): SFATextureArray | null { @@ -126,7 +126,7 @@ function loadFirstValidTexture(cache: GfxRenderCache, tab: DataView, bin: ArrayB let found = false; for (let i = 0; i < tab.byteLength; i += 4) { const tabValue = tab.getUint32(i); - if (tabValue == 0xFFFFFFFF) { + if (tabValue === 0xFFFFFFFF) { console.log(`no valid id found`); break; } @@ -420,7 +420,7 @@ export class SFATextureFetcher extends TextureFetcher { let texNum = texId; if (!useTex1) { const textableValue = this.textableBin.getUint16(texId * 2); - if (texId < 3000 || textableValue == 0) { + if (texId < 3000 || textableValue === 0) { texNum = textableValue; } else { texNum = textableValue + 1; diff --git a/src/SuperMarioGalaxy/Actors/LegacyActor.ts b/src/SuperMarioGalaxy/Actors/LegacyActor.ts index fcc248f1c..e430d3916 100644 --- a/src/SuperMarioGalaxy/Actors/LegacyActor.ts +++ b/src/SuperMarioGalaxy/Actors/LegacyActor.ts @@ -498,7 +498,7 @@ export class NoclipLegacyActorSpawner { assertExists(infoIter.getValueNumber('PointPosZ')), ); - const isPink = infoIter.getValueString('ColorChange') == 'o'; + const isPink = infoIter.getValueString('ColorChange') === 'o'; const isSmall = true; const pointInfo: WorldmapPointInfo = { position, isPink, isSmall, diff --git a/src/SuperMonkeyBall/AVTpl.ts b/src/SuperMonkeyBall/AVTpl.ts index 5c42d7f42..af12eadfd 100644 --- a/src/SuperMonkeyBall/AVTpl.ts +++ b/src/SuperMonkeyBall/AVTpl.ts @@ -14,7 +14,7 @@ function parseAVTplHeader( ): TextureInputGX { let view = texHeaderBuffer.createDataView(); - assert(view.getUint16(0x0e) == 0x1234); + assert(view.getUint16(0x0e) === 0x1234); const name = `${tplName}_${leftPad(idx.toString(), 3, "0")}`; const format: GX.TexFormat = view.getUint32(0x00); const offs = view.getUint32(0x04); diff --git a/src/SuperMonkeyBall/Shape.ts b/src/SuperMonkeyBall/Shape.ts index 42d29f544..704ca9d13 100644 --- a/src/SuperMonkeyBall/Shape.ts +++ b/src/SuperMonkeyBall/Shape.ts @@ -25,7 +25,7 @@ import { TevLayerInst } from "./TevLayer.js"; function fillVatFormat(vtxType: GX.CompType, isNBT: boolean): GX_VtxAttrFmt[] { const vatFormat: GX_VtxAttrFmt[] = []; - const compShift = vtxType == GX.CompType.S16 ? 0x0d : 0x00; + const compShift = vtxType === GX.CompType.S16 ? 0x0d : 0x00; vatFormat[GX.Attr.POS] = { compCnt: GX.CompCnt.POS_XYZ, compType: vtxType, compShift }; vatFormat[GX.Attr.NRM] = { compCnt: isNBT ? GX.CompCnt.NRM_NBT : GX.CompCnt.NRM_XYZ, diff --git a/src/SuperMonkeyBall/Stagedef.ts b/src/SuperMonkeyBall/Stagedef.ts index 2bda0496a..4b43bba0e 100644 --- a/src/SuperMonkeyBall/Stagedef.ts +++ b/src/SuperMonkeyBall/Stagedef.ts @@ -478,9 +478,9 @@ function parseStagedefUncompressed(buffer: ArrayBufferSlice): Stage { const rot = parseVec3s(view, goalOffs + 0xc); const typeStr = readString(buffer, goalOffs + 0x12, 1, false); let type: GoalType; - if (typeStr == "B") type = GoalType.Blue; - else if (typeStr == "G") type = GoalType.Green; - else if (typeStr == "R") type = GoalType.Red; + if (typeStr === "B") type = GoalType.Blue; + else if (typeStr === "G") type = GoalType.Green; + else if (typeStr === "R") type = GoalType.Red; else throw new Error(`Unknown goal type '${typeStr}'`); goals.push({ pos, rot, type }); } @@ -647,10 +647,10 @@ function parseStagedefUncompressed(buffer: ArrayBufferSlice): Stage { // we just use empty lists const triIdxListOffs = view.getUint32(coliTriIdxsOffs + gridIdx * 4); const triIdxList: number[] = []; - if (triIdxListOffs != 0) { + if (triIdxListOffs !== 0) { for (let triIdxIdx = 0; ; triIdxIdx++) { const triIdx = view.getInt16(triIdxListOffs + triIdxIdx * 2); - if (triIdx != -1) { + if (triIdx !== -1) { triIdxList.push(triIdx); } else { break; diff --git a/src/WiiSports/Scenes_WiiSports.ts b/src/WiiSports/Scenes_WiiSports.ts index 6a767a20c..a74c51788 100644 --- a/src/WiiSports/Scenes_WiiSports.ts +++ b/src/WiiSports/Scenes_WiiSports.ts @@ -152,7 +152,7 @@ class BowlingSceneDesc implements Viewer.SceneDesc { const stageBRRES = renderer.mountRRES(device, `G3D/${this.id}.brres`); const scn0BRRES = renderer.mountRRES(device, `G3D/${this.id}_rsca.brres`); - renderer.bindSCN0(assertExists(scn0BRRES.scn0.find(x => x.name == "RPScene"))); + renderer.bindSCN0(assertExists(scn0BRRES.scn0.find(x => x.name === "RPScene"))); for (let mdl0 of stageBRRES.mdl0) { const instance = renderer.spawnModel(device, stageBRRES, mdl0.name); @@ -208,13 +208,13 @@ class GolfSceneDesc implements Viewer.SceneDesc { renderer.bindAnimations(instance, brres, name); mat4.copy(instance.modelMatrix, object.modelMatrix); - if (brres.mdl0.find(x => x.name == waterName)) { + if (brres.mdl0.find(x => x.name === waterName)) { const instanceWater = renderer.spawnModel(device, brres, waterName); renderer.bindAnimations(instanceWater, brres, waterName); mat4.copy(instanceWater.modelMatrix, object.modelMatrix); } - if (brres.mdl0.find(x => x.name == WaveName)) { + if (brres.mdl0.find(x => x.name === WaveName)) { const instanceWave = renderer.spawnModel(device, brres, WaveName); renderer.bindAnimations(instanceWave, brres, WaveName); mat4.copy(instanceWave.modelMatrix, object.modelMatrix); @@ -301,7 +301,7 @@ class GolfSceneDesc implements Viewer.SceneDesc { const courseBRRES = renderer.mountRRES(device, `G3D/${golfName}.brres`); const courseMDL0 = renderer.spawnModel(device, courseBRRES, golfName); - renderer.bindSCN0(assertExists(courseBRRES.scn0.find(x => x.name == sceneName))); + renderer.bindSCN0(assertExists(courseBRRES.scn0.find(x => x.name === sceneName))); courseMDL0.bindLightSetting(renderer.lightSetting); renderer.bindAnimations(courseMDL0, courseBRRES, golfName); @@ -315,7 +315,7 @@ class GolfSceneDesc implements Viewer.SceneDesc { // Hide the height map and show the normal texture for the green // TODO: since the projection is not done correctly, use the height map for now - //const greenMaterial = courseMDL0.materialInstances.find(x => x.materialData.material.name == "M_Green"); + //const greenMaterial = courseMDL0.materialInstances.find(x => x.materialData.material.name === "M_Green"); //if (greenMaterial) { // greenMaterial.materialData.material.colorConstants[2] = colorNewFromRGBA(1, 1, 1, 1); @@ -352,7 +352,7 @@ class BoxingSceneDesc implements Viewer.SceneDesc { // Load main model const stageBRRES = renderer.mountRRES(device, `G3D/${this.id}.brres`); - renderer.bindSCN0(assertExists(stageBRRES.scn0.find(x => x.name == this.id))); + renderer.bindSCN0(assertExists(stageBRRES.scn0.find(x => x.name === this.id))); if (this.id === "box_ring") { // The animation loops, for unknown reason. Set it to play once, diff --git a/src/WorldOfWarcraft/data.ts b/src/WorldOfWarcraft/data.ts index c82752348..51a923a7a 100644 --- a/src/WorldOfWarcraft/data.ts +++ b/src/WorldOfWarcraft/data.ts @@ -1104,7 +1104,7 @@ function setM2BlendModeMegaState(renderInst: GfxRenderInst, blendMode: WowM2Blen }; if (depthWrite === undefined) { - depthWrite = (blendMode == rust.WowM2BlendingMode.Opaque || blendMode === rust.WowM2BlendingMode.AlphaKey); + depthWrite = (blendMode === rust.WowM2BlendingMode.Opaque || blendMode === rust.WowM2BlendingMode.AlphaKey); } const cullMode = doubleSided ? GfxCullMode.None : GfxCullMode.Back; diff --git a/src/WorldOfWarcraft/render.ts b/src/WorldOfWarcraft/render.ts index 4cd0d9136..7b2e76559 100644 --- a/src/WorldOfWarcraft/render.ts +++ b/src/WorldOfWarcraft/render.ts @@ -621,7 +621,7 @@ export class WmoRenderer { for (let def of frame.wmoDefs.get(this.wmo.fileId)) { assert( def.wmoId === this.wmo.fileId, - `WmoRenderer handed a WmoDefinition that doesn't belong to it (${def.wmoId} != ${this.wmo.fileId}`, + `WmoRenderer handed a WmoDefinition that doesn't belong to it (${def.wmoId} !== ${this.wmo.fileId}`, ); const template = renderInstManager.pushTemplate(); let offs = template.allocateUniformBuffer(WmoProgram.ub_ModelParams, 12); diff --git a/src/ZeldaSkywardSword/Main.ts b/src/ZeldaSkywardSword/Main.ts index e7c3d009e..0763fb666 100644 --- a/src/ZeldaSkywardSword/Main.ts +++ b/src/ZeldaSkywardSword/Main.ts @@ -250,7 +250,7 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { this.textureHolder.addRRESTextures(device, roomRRES); - for (let i = 0; i < roomRRES.mdl0.length && this.currentLayer == 0; i++) { + for (let i = 0; i < roomRRES.mdl0.length && this.currentLayer === 0; i++) { const mdl0 = roomRRES.mdl0[i]; const model = this.modelCache.getModel(device, this.renderHelper, mdl0, materialHacks); @@ -343,7 +343,7 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { const layerNames : string[] = []; if (this.layerModels.length > 1){ for (let i = 0; i < this.layerModels.length; i++) { - if (this.layerModels[i].length != 0){ + if (this.layerModels[i].length !== 0){ layerIndecies.push(i); layerNames.push('Layer '+i); } @@ -359,7 +359,7 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { // Set current layer visible // set other layers non-visible for (let i = 0; i < this.layerModels.length; i++){ - if (this.layerModels[i].length != 0) + if (this.layerModels[i].length !== 0) this.layerModels[i].forEach((mdl)=>mdl.setVisible((i === layerIndecies[index] ) || (i===0))); } modelsPanel.syncLayerVisibility(); @@ -581,9 +581,9 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { // Scan add for non-zero nodes // if non-zero -> merge into main using the same name chrAdd.nodeAnimations.forEach( animNode => { - if (animNode.scaleX == undefined) { - const mainAnimNode = chrMain.nodeAnimations.findIndex((node) => node.nodeName == animNode.nodeName); - if (mainAnimNode != -1) + if (animNode.scaleX === undefined) { + const mainAnimNode = chrMain.nodeAnimations.findIndex((node) => node.nodeName === animNode.nodeName); + if (mainAnimNode !== -1) chrMain.nodeAnimations[mainAnimNode] = animNode; else console.log('Unable to find Chr Common Node'); @@ -621,7 +621,7 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { const insideType = (params1 >>> 16) & 0xF; // Outside Model spawnModelFromNames('Tansu', 'Tansu' + ['A','B','C','D','A'][outsideType]); - if (insideType != 0xF) + if (insideType !== 0xF) spawnModelFromNames('TansuInside', 'TansuInside' + ['A','B','C','D','A'][outsideType]); } // @@ -676,34 +676,34 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { } } // Small Key - else if (itemId == 1) { + else if (itemId === 1) { const keyModel = spawnOArcModel('PutKeySmall'); mat4.scale(keyModel.modelMatrix, keyModel.modelMatrix, [1.1, 1.1, 1.1]); } // stamina fruit - else if (itemId == 42) { + else if (itemId === 42) { const gutsRRES = getOArcRRES('PutGuts'); const gutsMdl = spawnModel(gutsRRES, 'PutGuts'); spawnModel(gutsRRES, 'PutGutsLeaf'); gutsMdl.bindSRT0(this.animationController, findSRT0(gutsRRES, 'GutsLight')); } // Babies Rattle - else if (itemId == 160) { + else if (itemId === 160) { spawnOArcModel('PutGaragara'); } // heart piece - else if (itemId == 94) { + else if (itemId === 94) { const m = spawnOArcModel('PutHeartKakera'); scaleModelConstant(m, 1.375); } // Gratitude Crystal - else if (itemId == 48) { + else if (itemId === 48) { const m = spawnOArcModel('GetGenki'); scaleModelConstant(m, 1.7); translateModel(m, [0,30,0]); } // Normal Heart Item - else if (itemId == 6) { + else if (itemId === 6) { const m = spawnOArcModel('PutHeart'); } else { @@ -763,20 +763,20 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { else if (name === 'IvyRope'){ // Ropes const ropeSubtype = params1 & 0xF; - if (ropeSubtype < 3 || ropeSubtype == 4){ + if (ropeSubtype < 3 || ropeSubtype === 4){ // RopeA Bti for a length - } else if (ropeSubtype == 6) { + } else if (ropeSubtype === 6) { // RopeSpider bti - } else if (ropeSubtype == 3) { + } else if (ropeSubtype === 3) { // Coil - } else if (ropeSubtype == 7) { + } else if (ropeSubtype === 7) { // RopeTerry } else { // Common Dummy bti } - if (ropeSubtype == 7){ + if (ropeSubtype === 7){ spawnOArcModel('RopeTerry'); - } else if (ropeSubtype == 4) { + } else if (ropeSubtype === 4) { spawnModelFromNames('GrassCoil', 'GrassCoilCut'); // Can be switched to cut variant } } @@ -820,17 +820,17 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { // Dungeon Doors else if (name === 'TstShtr'){ const doorType = (params1 >>> 4) & 0x3f; - let isLocked = ((rotx & 0x00FF) != 0xFF); - let isLocked2 = ((rotx & 0xFF00) != 0xFF); + let isLocked = ((rotx & 0x00FF) !== 0xFF); + let isLocked2 = ((rotx & 0xFF00) !== 0xFF); const isLockedWithKey = (params1&0xF); const doorModelArcName = 'ShutterFenced0' + [doorType]; let doorModelName = 'ShutterFenced0' + [doorType]; let lockedModelName = 'ShutterFencedFence0' + [doorType]; const doorRRES = getOArcRRES(doorModelArcName); - if (doorType == 2){ // Time Variants + if (doorType === 2){ // Time Variants spawnModel(doorRRES, doorModelName+'N'); spawnModel(doorRRES, doorModelName+'T'); - if ((isLocked || isLocked2) && isLockedWithKey != 2) { + if ((isLocked || isLocked2) && isLockedWithKey !== 2) { spawnModel(doorRRES, lockedModelName+'N'); spawnModel(doorRRES, lockedModelName+'T'); } @@ -858,7 +858,7 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { const bossDoorAnim = spawnOArcModel('DoorBoss'); bossDoorAnim.bindRRESAnimations(this.animationController, getOArcRRES("DoorBoss"), "DoorBoss_Open"); // Spawn Keyhole - if (dungeonNum != 3) // Ancient Cistern + if (dungeonNum !== 3) // Ancient Cistern { let doorL, doorR, lockL, lockR, holeL, holeR : MDL0ModelInstance; // Spawn Door @@ -882,7 +882,7 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { spawnModelFromNames('BossLockD101', 'BossLockD101'); } - if (dungeonNum == 2) { // LMF present doors.... + if (dungeonNum === 2) { // LMF present doors.... let doorL, doorR, lockL, lockR, holeL, holeR : MDL0ModelInstance; // Spawn Door doorL = spawnModelFromNames(bossDoorModel, bossDoorModel+'NL'); @@ -945,17 +945,17 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { scaleModelConstant(mdl, 1.1); let weaponIdx = -1; // Weapon - if (bokoConfig == 9) { + if (bokoConfig === 9) { // Bow - const bowMdl = spawnModel(bcRRES, color == 0 ? 'BocoburinGBow' : 'bow'); + const bowMdl = spawnModel(bcRRES, color === 0 ? 'BocoburinGBow' : 'bow'); this.modelBinds.push({model: bowMdl, modelToBindTo: mdl, nodeName: 'hand_L'}) - } else if (color == 0) { + } else if (color === 0) { weaponIdx = 4; - } else if (color == 2) { + } else if (color === 2) { weaponIdx = 3; - } else if (bokoConfig == 2 || bokoConfig == 8) { + } else if (bokoConfig === 2 || bokoConfig === 8) { weaponIdx = 2; - } else if (bokoConfig != 4) { + } else if (bokoConfig !== 4) { weaponIdx = 1; } else { @@ -963,21 +963,21 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { this.modelBinds.push({model: weaponMdl, modelToBindTo: mdl, nodeName: 'hand_R'}) mdl.bindCHR0(this.animationController, findCHR0(bcRRES, 'Rwait')); } - if (weaponIdx != -1) + if (weaponIdx !== -1) { const weaponName = `Bocoburin${['SwordA', 'Stick', 'BSword','GSword'][weaponIdx-1]}`; const weaponMdl = spawnModel(bcRRES, weaponName); this.modelBinds.push({model: weaponMdl, modelToBindTo: mdl, nodeName: 'hand_R'}) } // Headpiece - if (variant != 0 && color != 0) + if (variant !== 0 && color !== 0) { const headcloth = spawnModel(bcRRES, `Bocoburin${['M','M','B'][color]}Headcloth`); this.modelBinds.push({model: headcloth, modelToBindTo: mdl, nodeName: 'head'}) } // Belt item const beltItem = ["None", 'Horn', 'Key'][(params1 >>> 2) & 3]; - if (beltItem != "None") + if (beltItem !== "None") { if (beltItem === 'Key') { const keyMdl = spawnModel(bcRRES, "KeySmall"); @@ -1024,10 +1024,10 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { const arc = ['None','TreeLong00', 'KanbanTree', 'TreeLongBamboo','TreeLong01', 'TreeLongSky'][type]; const model1 = ['None', 'TreeLong00', 'None', 'None', 'TreeLong01', 'TreeLongSky'][type]; const model2 = ['None', 'TreeLong00Cutmark', 'None', 'None', 'TreeLong01Cutmark', 'TreeLongSkyCutmark'][type]; - // if (arc != 'None') + // if (arc !== 'None') // { // const rres = getOArcRRES(arc); - // if (model1 != 'None') + // if (model1 !== 'None') // { // const m = spawnModel(rres, model1); // translateModel(m, [0, 100, 0]); @@ -1272,7 +1272,7 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { const type = params1 & 0xF; const typeName = 'IslTre'+['A','B','C','D','E','F','G','H'][type]; spawnOArcModel(typeName); - if (type == 2){ + if (type === 2){ spawnModelFromNames(typeName, typeName+'Water00'); spawnModelFromNames(typeName, typeName+'Water01'); } @@ -1469,7 +1469,7 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { // Beedles Shop else if (name === 'Tshop') { const rres = getOArcRRES('TerryShop'); - if (this.stageId == 'F020') // turns it off at night + if (this.stageId === 'F020') // turns it off at night rres.chr0 = []; const m = spawnModel(rres, 'TerryShop'); spawnModel(rres, 'TerryBell'); @@ -1554,7 +1554,7 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { // Fire TODO -> put fire effect in when JPA is implemented else if (name === 'Fire') { const type = params1 & 0xF; - if (type != 1){ + if (type !== 1){ const arcName = 'Candle0'+['0','0','1','2'][type]; const modelName = 'Candle'+['','','01','02'][type]; spawnModelFromNames(arcName, modelName); @@ -1768,7 +1768,7 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { // Waterfalls in Ancient Cistern else if (name === 'wfall') { const type = (params1 >>> 28) & 0xF - if (type != 0){ + if (type !== 0){ const rres = getOArcRRES('WaterfallD101'); spawnModel(rres, 'WaterfallD101'+['A','B','C'][type-1]); } @@ -1811,7 +1811,7 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { else if (name === 'LogWtr') { const type = params1 & 1; const m = spawnOArcModel(['LogFloat','LogStep'][type]); - if (type == 1) + if (type === 1) translateModel(m, [0,500,0]); } // Cistern Boss Door @@ -1842,7 +1842,7 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { const rres = 'Water'+['D100_r02','D100_r03','D100_r04','D100_r06','F103','F100_b','F104A','F104B','F104C','F104D'][type]; const m = spawnModelFromNames(rres, 'model0'); const m1 = spawnModelFromNames(rres, 'model1'); - if (this.stageId == 'D100'){ + if (this.stageId === 'D100'){ translateModel(m , [0,500,0]); translateModel(m1, [0,500,0]); } @@ -1895,7 +1895,7 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { const arcName = ['RockCarrySmall','RockCarryMiddle','RockCarryMiddle','Syako_egg'][type]; const mdlName = ['RockSmall','RockMiddle','RockMiddle','SyakoEgg'][type]; const m = spawnModelFromNames(arcName, mdlName); - if (type == 1 || type == 2) + if (type === 1 || type === 2) translateModel(m, [0,75,0]); } // Little spikey balls @@ -2027,7 +2027,7 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { // Raise And Lowerable floors (magma rocks?) else if (name === 'SnkFlrF') { const type = params1 & 0xF; - const arcName = (type != 3) ? 'SinkRock' : 'FWRockA'; + const arcName = (type !== 3) ? 'SinkRock' : 'FWRockA'; const mdlName = ['SinkRockC', 'SinkRockB', 'SinkRockA', 'FWRockA'][type]; spawnModelFromNames(arcName, mdlName); } @@ -2040,7 +2040,7 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { spawnModel(rres, 'TowerBomb00'); // Little Legs const m = spawnModel(rres, mdlName); // Main Tower const chr = findCHR0(rres, 'Falldown'); - if ((params1&0xFF) == 0xFF) + if ((params1&0xFF) === 0xFF) m.bindCHR0(this.animationController, chr); if (type === 1){ const m2 = spawnModel(rres, 'FX_TowerLight'); @@ -2054,7 +2054,7 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { } // Pyrup Shells else if (name === 'EHidoS') { - const type = ((params1&0xF) != 0x0) ? 'BoneA' : 'BoneB'; + const type = ((params1&0xF) !== 0x0) ? 'BoneA' : 'BoneB'; spawnModelFromNames('HidokariS', type); } @@ -2062,7 +2062,7 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { else if (name === 'RolRock') { const decideType = (params1 >>> 12) & 0xF; let type = decideType; - if (decideType == 0xb) type = 6; + if (decideType === 0xb) type = 6; if ([9,10].includes(type)) type = 4; if ([0,4].includes(type)) spawnOArcModel('RockRollA'); else spawnOArcModel('RockRollB'); @@ -2091,8 +2091,8 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { else if (name === 'NpcMoN') { const type = ((params1&0xF) > 6) ? 0 : params1&0xF; let val = 2; - if (type == 0 || type == 4 || type == 6) val = 0; - else if (type == 1 || type == 3) val = 1; + if (type === 0 || type === 4 || type === 6) val = 0; + else if (type === 1 || type === 3) val = 1; const rres = getOArcRRES('Moguma'); const m = spawnModel(rres, 'Moguma'); const chr = mergeCHR0(rres, 'Moguma_wait', 'Moguma_F_wait'); @@ -2259,19 +2259,19 @@ class SkywardSwordRenderer implements Viewer.SceneGfx { if(['ESm'].includes(obj.name)){ let rotationZ = 0; - if (scaleX == 4) { + if (scaleX === 4) { scaleX = 1.2; scaleY = 1.2; scaleZ = 1.2; - } else if (scaleX == 3) { + } else if (scaleX === 3) { scaleX = 0.25; scaleY = 0.25; scaleZ = 0.25; - } else if (scaleX == 2) { + } else if (scaleX === 2) { scaleX = 0.4; scaleY = 0.4; scaleZ = 0.4; - } else if (scaleX == 1) { + } else if (scaleX === 1) { scaleX = 0.8; scaleY = 0.8; scaleZ = 0.8; diff --git a/src/ZeldaTwilightPrincess/LegacyActor.ts b/src/ZeldaTwilightPrincess/LegacyActor.ts index e2c638558..3b35aa183 100644 --- a/src/ZeldaTwilightPrincess/LegacyActor.ts +++ b/src/ZeldaTwilightPrincess/LegacyActor.ts @@ -1349,7 +1349,7 @@ function spawnLegacyActor(globals: dGlobals, legacy: d_a_noclip_legacy, actor: f }); // Lakebed gates else if (actorName === 'bsGate') fetchArchive(`S_Zgate`).then((rarc) => { - if (((actor.parameters >> 8) & 0xFF) == 1) { + if (((actor.parameters >> 8) & 0xFF) === 1) { actor.rot![1] -= 0x8000; } diff --git a/src/ZeldaTwilightPrincess/d_a.ts b/src/ZeldaTwilightPrincess/d_a.ts index 4c5f70e1a..62a81c75f 100644 --- a/src/ZeldaTwilightPrincess/d_a.ts +++ b/src/ZeldaTwilightPrincess/d_a.ts @@ -237,7 +237,7 @@ function dKy_bg_MAxx_proc(globals: dGlobals, modelInstance: J3DModelInstance): d c1.b = 180 / 255; c1.a = 255 / 255; - if (globals.renderer.currentLayer == 1) + if (globals.renderer.currentLayer === 1) c1.a = 0.0; materialInstance.setColorOverride(ColorKind.C1, c1); @@ -879,10 +879,10 @@ class daBgObj_Spec { const name = readString(buffer, offset); offset += name.length + 1; - if (view.getUint8(offset) != 0) { + if (view.getUint8(offset) !== 0) { const name = readString(buffer, offset); offset += name.length + 1; - } else if (view.getUint8(offset) == 0 && view.getUint8(offset + 1) == 1) { + } else if (view.getUint8(offset) === 0 && view.getUint8(offset + 1) === 1) { offset += 2; } } @@ -2171,7 +2171,7 @@ class kytag06_class extends fopAc_ac_c { case 2: colpat_weather = 1; - if ((deltaTimeFrames & 3) == 0) { + if ((deltaTimeFrames & 3) === 0) { if (envLight.rainCount < 40) { envLight.rainCount++; dKyw_rain_set(envLight, envLight.rainCount); @@ -2220,7 +2220,7 @@ class kytag06_class extends fopAc_ac_c { colpat_weather = 1; if (envLight.snowCount < 125) { - if ((deltaTimeFrames & 3) == 0) { + if ((deltaTimeFrames & 3) === 0) { envLight.snowCount++; } } else { @@ -2235,7 +2235,7 @@ class kytag06_class extends fopAc_ac_c { break; } - if (envLight.colpatWeather != colpat_weather && !envLight.cameraInWater) { + if (envLight.colpatWeather !== colpat_weather && !envLight.cameraInWater) { envLight.colpatWeather = colpat_weather; dKy_change_colpat(envLight, colpat_weather); } @@ -2334,7 +2334,7 @@ class kytag06_class extends fopAc_ac_c { break; } - if (envLight.colpatWeather != colpat_weather && !envLight.cameraInWater) { + if (envLight.colpatWeather !== colpat_weather && !envLight.cameraInWater) { envLight.colpatWeather = colpat_weather; dKy_change_colpat(envLight, colpat_weather); } @@ -2448,7 +2448,7 @@ class daItemBase extends fopAc_ac_c { if (brkID > 0) { const brk_anm = resCtrl.getObjectRes(ResType.Brk, arcName, brkID); - const play_anm = globals.item_resource[this.itemNo].tevFrm == 0xFF ? true : false; + const play_anm = globals.item_resource[this.itemNo].tevFrm === 0xFF ? true : false; this.brk = new mDoExt_brkAnm(); this.brk.init(mdl_data, brk_anm, play_anm, LoopMode.Repeat); } @@ -2465,7 +2465,7 @@ class daItemBase extends fopAc_ac_c { const tevFrm = globals.item_resource[this.itemNo].tevFrm; if (this.brk !== null) { - if (tevFrm != 0xFF) + if (tevFrm !== 0xFF) this.brk.entry(this.model, tevFrm); else this.brk.entry(this.model); @@ -2539,7 +2539,7 @@ class d_a_obj_item extends daItemBase { break; case 6: default: - if (this.switchNo != 0xFF) + if (this.switchNo !== 0xFF) this.hide(); break; } @@ -2623,7 +2623,7 @@ class d_a_obj_item extends daItemBase { break; case 6: default: - if (this.switchNo != 0xFF) + if (this.switchNo !== 0xFF) this.hide(); break; } @@ -3219,7 +3219,7 @@ class d_a_e_hp extends fopAc_ac_c { if (status !== cPhs__Status.Complete) return status; - this.alwaysOn = (this.rot[2] & 1) == 0 ? true : false; + this.alwaysOn = (this.rot[2] & 1) === 0 ? true : false; this.rot[2] = 0; this.rot[0] = 0; diff --git a/src/ZeldaTwilightPrincess/d_kankyo.ts b/src/ZeldaTwilightPrincess/d_kankyo.ts index 11f3aa650..9c8123889 100644 --- a/src/ZeldaTwilightPrincess/d_kankyo.ts +++ b/src/ZeldaTwilightPrincess/d_kankyo.ts @@ -461,7 +461,7 @@ function dKy_light_influence_id(globals: dGlobals, pos: ReadonlyVec3, which: num } } - if (light.index < 0 && var_r25 != 99) { + if (light.index < 0 && var_r25 !== 99) { if (i === 0) bestIdx1 = j; @@ -791,7 +791,7 @@ function setLight_actor(globals: dGlobals, envLight: dScnKy_env_light_c, tevStr: tevStr.ambCol.b = 0; } } else { - if (tevStr.lightType == LightType.UNK_10 || tevStr.lightType == LightType.UNK_9 || tevStr.unk_378 != 0) { + if (tevStr.lightType === LightType.UNK_10 || tevStr.lightType === LightType.UNK_9 || tevStr.unk_378 !== 0) { dKy_calc_color_set(envLight, tevStr.ambCol, ret.palePrevA.actorAmbCol, ret.palePrevB.actorAmbCol, ret.paleCurrA.actorAmbCol, ret.paleCurrB.actorAmbCol, ret.blendPaleAB, tevStr.colpatBlend, envLight.actorAddAmb, tevStr.lightInfluence * envLight.actAmbColRatio * envLight.actAmbColRatio); } else { dKy_calc_color_set(envLight, tevStr.ambCol, ret.palePrevA.actorAmbCol, ret.palePrevB.actorAmbCol, ret.paleCurrA.actorAmbCol, ret.paleCurrB.actorAmbCol, ret.blendPaleAB, tevStr.colpatBlend, envLight.actorAddAmb, tevStr.lightInfluence * envLight.unk_1210 * envLight.actAmbColRatio * envLight.actAmbColRatio); @@ -1662,7 +1662,7 @@ export function dKy_event_proc(globals: dGlobals, deltaTimeFrames: number): void break; } - if (envLight.colpatWeather != colpat) { + if (envLight.colpatWeather !== colpat) { envLight.colpatWeather = colpat; envLight.colpatCurrGather = colpat; } @@ -2250,7 +2250,7 @@ export function dKy_SunMoon_Light_Check(globals: dGlobals): boolean { } export function dKy_Indoor_check(globals: dGlobals): boolean { - if (dStage_stagInfo_GetSTType(globals.dStage_dt.stag) != 0) { + if (dStage_stagInfo_GetSTType(globals.dStage_dt.stag) !== 0) { return true; } diff --git a/src/ZeldaTwilightPrincess/d_kankyo_wether.ts b/src/ZeldaTwilightPrincess/d_kankyo_wether.ts index 601f87716..1381923a7 100644 --- a/src/ZeldaTwilightPrincess/d_kankyo_wether.ts +++ b/src/ZeldaTwilightPrincess/d_kankyo_wether.ts @@ -878,7 +878,7 @@ export class dKankyo_vrkumo_Packet { ddraw.texCoord2f32(GX.Attr.TEX0, 0, 1); const stageName = globals.stageName; - if (stageName == "F_SP127" || stageName == "D_MN07" || stageName == "D_MN08" || stageName == "D_MN07A" || (stageName == "F_SP103" && globals.mStayNo === 0)) { + if (stageName === "F_SP127" || stageName === "D_MN07" || stageName === "D_MN08" || stageName === "D_MN07A" || (stageName === "F_SP103" && globals.mStayNo === 0)) { x = Math.cos(polarY0) * Math.sin(azimuthal + azimuthalOffsY0); y = Math.sin(polarY0); z = Math.cos(polarY0) * Math.cos(azimuthal + azimuthalOffsY0); @@ -1972,7 +1972,7 @@ function vrkumo_move(globals: dGlobals, deltaTimeFrames: number): void { } let x = Math.sin(rnd_0); - if (Math.abs(rnd_1 * x) != 0.0) { + if (Math.abs(rnd_1 * x) !== 0.0) { if (x <= 0.0) { x -= 5000; } else { @@ -1981,7 +1981,7 @@ function vrkumo_move(globals: dGlobals, deltaTimeFrames: number): void { } let z = Math.cos(rnd_0); - if (Math.abs(rnd_1 * z) != 0.0) { + if (Math.abs(rnd_1 * z) !== 0.0) { if (z <= 0.0) { z -= 5000; } else { diff --git a/src/ZeldaWindWaker/LegacyActor.ts b/src/ZeldaWindWaker/LegacyActor.ts index 72484b75c..1d6941c5b 100644 --- a/src/ZeldaWindWaker/LegacyActor.ts +++ b/src/ZeldaWindWaker/LegacyActor.ts @@ -1130,7 +1130,7 @@ function spawnLegacyActor(globals: dGlobals, legacy: d_a_noclip_legacy, actor: f let model: BMDObjectRenderer; - if (actor.parameters == 0xFFFFFFFF) { + if (actor.parameters === 0xFFFFFFFF) { model = buildModelBMT(rarc, bdlmPaths[1], 'bmt/pg_pink.bmt'); } else { model = buildModelBMT(rarc, bdlmPaths[0], bmtPaths[color]); @@ -1192,14 +1192,14 @@ function spawnLegacyActor(globals: dGlobals, legacy: d_a_noclip_legacy, actor: f let lastModel = mainModel; for (let i = 0; i < 20; i++) { let tailModel; - if (i == 19) { + if (i === 19) { tailModel = buildChildModel(rarc, `bdlm/bwd_shippob.bdl`); tailModel.bindTRK1(parseBRK(rarc, `brk/bwd_shippob.brk`), animFrame(0)); } else { tailModel = buildChildModel(rarc, `bdlm/bwd_shippoa.bdl`); tailModel.bindTRK1(parseBRK(rarc, `brk/bwd_shippoa.brk`), animFrame(0)); } - if (i == 0) { + if (i === 0) { tailModel.setParentJoint(lastModel, `hara`); mat4.rotateY(tailModel.modelMatrix, tailModel.modelMatrix, Math.PI * 1.5); } else { @@ -1216,7 +1216,7 @@ function spawnLegacyActor(globals: dGlobals, legacy: d_a_noclip_legacy, actor: f else if (actorName === 'Rdead1' || actorName === 'Rdead2') fetchArchive(`Rd`).then((rarc) => { const m = buildModel(rarc, `bdlm/rd.bdl`); const idleAnimType = (actor.parameters & 0x00000001); - if (idleAnimType == 0) { + if (idleAnimType === 0) { m.bindANK1(parseBCK(rarc, `bcks/tachip.bck`)); } else { m.bindANK1(parseBCK(rarc, `bcks/suwarip.bck`)); @@ -1259,7 +1259,7 @@ function spawnLegacyActor(globals: dGlobals, legacy: d_a_noclip_legacy, actor: f const bubbleType = (actor.parameters & 0x000000FF); - if (bubbleType == 0x80) { + if (bubbleType === 0x80) { m.bindTTK1(parseBTK(rarc, 'btk/off.btk')); } else { m.bindANK1(parseBCK(rarc, 'bck/fly.bck')); @@ -1313,7 +1313,7 @@ function spawnLegacyActor(globals: dGlobals, legacy: d_a_noclip_legacy, actor: f mainModel.bindANK1(mainAnim); let helmetModel; - if (equipmentType == 1 || equipmentType == 3 || equipmentType >= 5) { // Has full face helmet + if (equipmentType === 1 || equipmentType === 3 || equipmentType >= 5) { // Has full face helmet helmetModel = buildChildModel(rarc, `bmdm/tn_kabuto2.bmd`); helmetModel.bindTRK1(parseBRK(rarc, `brk/tn_kabuto2.brk`), animFrame(armorColor)); } else { @@ -1362,7 +1362,7 @@ function spawnLegacyActor(globals: dGlobals, legacy: d_a_noclip_legacy, actor: f // Peahats and Seahats else if (actorName === 'p_hat') { const type = (actor.parameters & 0x000000FF); - if (type == 1) { + if (type === 1) { fetchArchive(`Sh`).then((rarc) => { const mainModel = buildModel(rarc, `bmdm/shb.bmd`); mainModel.bindANK1(parseBCK(rarc, 'bck/bfly.bck')); @@ -1511,7 +1511,7 @@ function spawnLegacyActor(globals: dGlobals, legacy: d_a_noclip_legacy, actor: f shapeType = 0; const m = buildModel(rarc, models[shapeType]); m.bindANK1(parseBCK(rarc, `bck/dooropenbdoor.bck`), animFrame(0)); - m.lightTevColorType = shapeType == 5 ? LightType.Actor : LightType.BG0; + m.lightTevColorType = shapeType === 5 ? LightType.Actor : LightType.BG0; }); else if (actorName === 'MKoppu') fetchArchive(`Mshokki`).then((rarc) => buildModel(rarc, `bdl/koppu.bdl`)); else if (actorName === 'MOsara') fetchArchive(`Mshokki`).then((rarc) => buildModel(rarc, `bdl/osara.bdl`)); diff --git a/src/ZeldaWindWaker/Main.ts b/src/ZeldaWindWaker/Main.ts index 0ae8e1ae9..7a21b1bf0 100644 --- a/src/ZeldaWindWaker/Main.ts +++ b/src/ZeldaWindWaker/Main.ts @@ -795,7 +795,7 @@ class d_s_play extends fopScn { this.demo.update(); // From executeEvtManager() -> SpecialProcPackage() - if (this.demo.getMode() == EDemoMode.Ended) { + if (this.demo.getMode() === EDemoMode.Ended) { this.demo.remove(); } } @@ -1005,7 +1005,7 @@ class DemoDesc extends SceneDesc implements Viewer.SceneDesc { const lbnk = globals.roomCtrl.status[this.roomList[0]].data.lbnk; if (lbnk) { const bank = lbnk[this.layer]; - if (bank != 0xFF) { + if (bank !== 0xFF) { assert(bank >= 0 && bank < 100); globals.roomCtrl.demoArcName = `Demo${bank.toString().padStart(2, '0')}`; console.debug(`Loading stage demo file: ${globals.roomCtrl.demoArcName}`); @@ -1021,7 +1021,7 @@ class DemoDesc extends SceneDesc implements Viewer.SceneDesc { // noclip modification: ensure all the actors are created before we load the cutscene await new Promise(resolve => { (function waitForActors(){ - if (globals.frameworkGlobals.ctQueue.length == 0) return resolve(null); + if (globals.frameworkGlobals.ctQueue.length === 0) return resolve(null); setTimeout(waitForActors, 30); })(); }); diff --git a/src/ZeldaWindWaker/d_a.ts b/src/ZeldaWindWaker/d_a.ts index 0ccfd9dde..77a842342 100644 --- a/src/ZeldaWindWaker/d_a.ts +++ b/src/ZeldaWindWaker/d_a.ts @@ -292,7 +292,7 @@ class d_a_ep extends fopAc_ac_c { } if (this.timers[1] === 0) { - if (true /* field_0x7d4 == 0 */) { + if (true /* field_0x7d4 === 0 */) { this.timers[1] = 3.0 + cM_rndF(6.0); this.alphaModelScaleTarget = 0.75 + cM_rndF(0.075); } else { @@ -4840,7 +4840,7 @@ class d_a_npc_ls1 extends fopNpc_npc_c { case 4: this.type = 4; break; } - return this.type != 0xFF; + return this.type !== 0xFF; } private createInit(globals: dGlobals) { @@ -4867,8 +4867,8 @@ class d_a_npc_ls1 extends fopNpc_npc_c { this.morf = new mDoExt_McaMorf(modelData, null, null, null, LoopMode.Once, 1.0, 0, -1); - const jointIdxHandL = modelData.bmd.jnt1.joints.findIndex(j => j.name == 'handL'); - const jointIdxHandR = modelData.bmd.jnt1.joints.findIndex(j => j.name == 'handR'); + const jointIdxHandL = modelData.bmd.jnt1.joints.findIndex(j => j.name === 'handL'); + const jointIdxHandR = modelData.bmd.jnt1.joints.findIndex(j => j.name === 'handR'); this.jointMtxHandL = this.morf.model.shapeInstanceState.jointToWorldMatrixArray[jointIdxHandL]; this.jointMtxHandR = this.morf.model.shapeInstanceState.jointToWorldMatrixArray[jointIdxHandR]; } @@ -4877,12 +4877,12 @@ class d_a_npc_ls1 extends fopNpc_npc_c { const modelData = globals.resCtrl.getObjectIDRes(ResType.Model, this.arcName, 0xc); this.handModel = new J3DModelInstance(modelData); - const handJointIdxL = modelData.bmd.jnt1.joints.findIndex(j => j.name == 'ls_handL'); - const handJointIdxR = modelData.bmd.jnt1.joints.findIndex(j => j.name == 'ls_handR'); + const handJointIdxL = modelData.bmd.jnt1.joints.findIndex(j => j.name === 'ls_handL'); + const handJointIdxR = modelData.bmd.jnt1.joints.findIndex(j => j.name === 'ls_handR'); this.handModel.jointMatrixCalcCallback = (dst: mat4, modelData: J3DModelData, i: number): void => { - if (i == handJointIdxL) { mat4.copy(dst, this.jointMtxHandL); } - else if (i == handJointIdxR) { mat4.copy(dst, this.jointMtxHandR); } + if (i === handJointIdxL) { mat4.copy(dst, this.jointMtxHandL); } + else if (i === handJointIdxR) { mat4.copy(dst, this.jointMtxHandR); } } } @@ -4898,7 +4898,7 @@ class d_a_npc_ls1 extends fopNpc_npc_c { const params = d_a_npc_ls1.animParamsTable[animIdx]; - if (params.anmIdx > -1 && this.animIdx != params.anmIdx) { + if (params.anmIdx > -1 && this.animIdx !== params.anmIdx) { const bckID = d_a_npc_ls1.bckIdxTable[params.anmIdx]; dNpc_setAnmIDRes(globals, this.morf, params.loopMode, params.morf, params.playSpeed, bckID, this.arcName); this.animIdx = params.anmIdx; @@ -4929,7 +4929,7 @@ class d_a_npc_ls1 extends fopNpc_npc_c { if (this.itemModel) { mat4.copy(calc_mtx, this.jointMtxHandR); - if (this.itemPosType == 0) { + if (this.itemPosType === 0) { MtxTrans([5.5, -3.0, -2.0], true); } else { diff --git a/src/ZeldaWindWaker/d_demo.ts b/src/ZeldaWindWaker/d_demo.ts index db5738549..8aab6a89c 100644 --- a/src/ZeldaWindWaker/d_demo.ts +++ b/src/ZeldaWindWaker/d_demo.ts @@ -195,9 +195,9 @@ export class dDemo_actor_c extends TActor { public getMorfParam() { // Doesn't have anim properties - if ((this.flags & 0x40) == 0) { + if ((this.flags & 0x40) === 0) { // Has STB data - if ((this.flags & 1) == 0) { + if ((this.flags & 1) === 0) { return 0.0; } else { switch (this.stbDataId) { @@ -310,7 +310,7 @@ class dDemo_system_c implements TSystem { case JStage.EObject.PreExistingActor: let actor = fopAcM_searchFromName(this.globals, objName, 0, 0); if (!actor) { - if (objType == JStage.EObject.Actor && objName == "d_act") { + if (objType === JStage.EObject.Actor && objName === "d_act") { debugger; // Untested. Unimplemented actor = {} as fopAc_ac_c; } else { @@ -443,7 +443,7 @@ export function dDemo_setDemoData(globals: dGlobals, dtFrames: number, actor: fo demoActor.model = morf.model; - if ((enable & 0x20) && (demoActor.nextBckId != demoActor.bckId)) { + if ((enable & 0x20) && (demoActor.nextBckId !== demoActor.bckId)) { const bckID = demoActor.nextBckId; if (bckID & 0x10000) arcName = globals.roomCtrl.demoArcName; diff --git a/src/ZeldaWindWaker/d_kankyo_wether.ts b/src/ZeldaWindWaker/d_kankyo_wether.ts index 936e0a6fb..d983ce4d6 100644 --- a/src/ZeldaWindWaker/d_kankyo_wether.ts +++ b/src/ZeldaWindWaker/d_kankyo_wether.ts @@ -1736,7 +1736,7 @@ function dKyr_kamome_move(globals: dGlobals, deltaTimeFrames: number): void { const pkt = envLight.windline!; let spawnBirds = false; - if (globals.stageName === 'sea' && !((envLight.colpatCurr == 1 && envLight.colpatBlend > 0.0) || (envLight.colpatPrev == 1 && envLight.colpatBlend < 1.0) || (envLight.colpatCurr == 2 && envLight.colpatBlend > 0.0) || (envLight.colpatPrev == 2 && envLight.colpatBlend < 1.0))) + if (globals.stageName === 'sea' && !((envLight.colpatCurr === 1 && envLight.colpatBlend > 0.0) || (envLight.colpatPrev === 1 && envLight.colpatBlend < 1.0) || (envLight.colpatCurr === 2 && envLight.colpatBlend > 0.0) || (envLight.colpatPrev === 2 && envLight.colpatBlend < 1.0))) spawnBirds = true; for (let i = 0; i < pkt.kamomeEff.length; i++) { diff --git a/src/ZeldaWindWaker/d_wood.ts b/src/ZeldaWindWaker/d_wood.ts index 847841f4e..ae2e2ca44 100644 --- a/src/ZeldaWindWaker/d_wood.ts +++ b/src/ZeldaWindWaker/d_wood.ts @@ -559,19 +559,19 @@ class Unit_c { if (this.flags & UnitState_e.Active) { if (this.animIdx >= 8) { const anim = packet.get_anm(this.animIdx); - if (anim.mode == AnimMode_e.ToNorm) { + if (anim.mode === AnimMode_e.ToNorm) { if (anim.timer <= 0) { this.animIdx = anim.nextAnimIdx; anim.mode = AnimMode_e._Max; } - } else if (anim.mode == AnimMode_e.Cut) { + } else if (anim.mode === AnimMode_e.Cut) { if (anim.timer <= 0) { const newAnimIdx = packet.search_anm(AnimMode_e.Norm); this.animIdx = newAnimIdx; anim.mode = AnimMode_e._Max; this.flags |= UnitState_e.IsCut; } - } else if (anim.mode == AnimMode_e._Max) { + } else if (anim.mode === AnimMode_e._Max) { this.animIdx = packet.search_anm(AnimMode_e.Norm); } } @@ -606,14 +606,14 @@ export class WoodPacket implements J3DPacket { assert((i_mode >= 0) && (i_mode < AnimMode_e._Max)); - if (i_mode == AnimMode_e.Norm) { + if (i_mode === AnimMode_e.Norm) { animIdx = sAnmNormNum++; sAnmNormNum = sAnmNormNum % 8; } else { // Return the first anim slot which has an unset mode animIdx = 8; for (let i = 0; i < 64; i++) { - if (this.anm[animIdx].mode == AnimMode_e._Max) { + if (this.anm[animIdx].mode === AnimMode_e._Max) { return animIdx; } animIdx++; @@ -658,14 +658,14 @@ export class WoodPacket implements J3DPacket { if ((roomIdx >= 0) && (roomIdx < kRoomCount)) { // dComIfG_Ccsp() -> SetMassAttr(L_attr.kCollisionRad1, L_attr.kCollisionHeight1, (u8)0x13, 1); for (let unit of this.unit[roomIdx]) { - if ((unit.flags & UnitState_e.IsCut) == 0) { + if ((unit.flags & UnitState_e.IsCut) === 0) { unit.cc_hit_before_cut(this); } } // dComIfG_Ccsp() -> SetMassAttr(L_attr.kCollisionRad2, L_attr.kCollisionHeight2, (u8)0x12, 1); for (let unit of this.unit[roomIdx]) { - if ((unit.flags & UnitState_e.IsCut) != 0) { + if ((unit.flags & UnitState_e.IsCut) !== 0) { unit.cc_hit_after_cut(this); } } @@ -770,13 +770,13 @@ export class WoodPacket implements J3DPacket { continue; // If this bush is not chopped down, draw the main body - if ((unit.flags & UnitState_e.IsCut) == 0) { + if ((unit.flags & UnitState_e.IsCut) === 0) { // The cut animation reduces alpha over time const cutAlpha = this.anm[unit.animIdx].alpha; colorFromRGBA(materialParams.u_Color[ColorKind.C2], 1, 1, 1, cutAlpha / 0xFF); // If this bush is fading out, disable alpha testing - if (cutAlpha != 0xff) { + if (cutAlpha !== 0xff) { materialParams.u_DynamicAlphaRefA = 0; materialParams.u_DynamicAlphaRefB = 0; } @@ -788,7 +788,7 @@ export class WoodPacket implements J3DPacket { renderInstManager.submitRenderInst(renderInst); // Return alpha test to normal (50%) - if (cutAlpha != 0xff) { + if (cutAlpha !== 0xff) { materialParams.u_DynamicAlphaRefA = kAlphaCutoff; materialParams.u_DynamicAlphaRefB = kAlphaCutoff; } diff --git a/src/ZeldaWindWaker/f_op_actor.ts b/src/ZeldaWindWaker/f_op_actor.ts index 700bbbebf..671ce5cbc 100644 --- a/src/ZeldaWindWaker/f_op_actor.ts +++ b/src/ZeldaWindWaker/f_op_actor.ts @@ -192,9 +192,9 @@ export function fopAcM_searchFromName(globals: dGlobals, procName: string, param for (let i = 0; i < globals.frameworkGlobals.lnQueue.length; i++) { const act = globals.frameworkGlobals.lnQueue[i] as fopAc_ac_c; - if (act.profName == objName.pcName - && objName.subtype == act.subtype - && (paramMask == 0 || param == (act.parameters & paramMask)) + if (act.profName === objName.pcName + && objName.subtype === act.subtype + && (paramMask === 0 || param === (act.parameters & paramMask)) ) return act; } diff --git a/src/ZeldaWindWaker/framework.ts b/src/ZeldaWindWaker/framework.ts index cc5776915..79dbf6342 100644 --- a/src/ZeldaWindWaker/framework.ts +++ b/src/ZeldaWindWaker/framework.ts @@ -310,7 +310,7 @@ export class base_process_class { this.parameters = profile.getUint32(0x18); // The game stores these separately, and frequently accesses both. Lets see if they ever differ. - assert(profName == this.processName); + assert(profName === this.processName); } // In the original game, construction is inside "create". Here, we split it into construction and "load". diff --git a/src/byml.ts b/src/byml.ts index 6d7c14ea2..a33e54eac 100644 --- a/src/byml.ts +++ b/src/byml.ts @@ -180,7 +180,7 @@ function parseComplexNode(context: ParseContext, buffer: ArrayBufferSlice, offs: case NodeType.PathTable: return parsePathTable(context, buffer, offs); case NodeType.BinaryData: - if (numValues == 0x00FFFFFF) { + if (numValues === 0x00FFFFFF) { const numValues2 = view.getUint32(offs + 0x04, context.littleEndian); return buffer.subarray(offs + 0x08, numValues + numValues2); } else { @@ -253,7 +253,7 @@ export function parse(buffer: ArrayBufferSlice, fileType: FileType = FileType assert(magics.includes(magic)); const view = buffer.createDataView(); - const littleEndian = magic.slice(0, 2) == 'YB'; + const littleEndian = magic.slice(0, 2) === 'YB'; const endianness: Endianness = littleEndian ? Endianness.LITTLE_ENDIAN : Endianness.BIG_ENDIAN; const context: ParseContext = new ParseContext(fileType, endianness); @@ -585,9 +585,9 @@ function gatherStrings(v: Node, keyStrings: Set, valueStrings: Set(v: T, fileType: FileType = FileType.CRG1, ma magic = magics[magics.length - 1]; assert(magic.length === 0x04); - const littleEndian = magic.slice(0, 2) == 'YB'; + const littleEndian = magic.slice(0, 2) === 'YB'; const endianness: Endianness = littleEndian ? Endianness.LITTLE_ENDIAN : Endianness.BIG_ENDIAN; const keyStringSet = new Set(['']); diff --git a/src/endian.ts b/src/endian.ts index 5e3297c27..63d3cad0e 100644 --- a/src/endian.ts +++ b/src/endian.ts @@ -6,7 +6,7 @@ export const enum Endianness { const test: Uint16Array = new Uint16Array([0xFEFF]); const testView: DataView = new DataView(test.buffer); -const systemEndianness: Endianness = (testView.getUint8(0) == 0xFF) ? Endianness.LITTLE_ENDIAN : Endianness.BIG_ENDIAN; +const systemEndianness: Endianness = (testView.getUint8(0) === 0xFF) ? Endianness.LITTLE_ENDIAN : Endianness.BIG_ENDIAN; export function getSystemEndianness(): Endianness { return systemEndianness; diff --git a/src/gfx/platform/GfxPlatformObjUtil.ts b/src/gfx/platform/GfxPlatformObjUtil.ts index 7d8961240..f869e157f 100644 --- a/src/gfx/platform/GfxPlatformObjUtil.ts +++ b/src/gfx/platform/GfxPlatformObjUtil.ts @@ -115,7 +115,7 @@ export function gfxBindingsDescriptorEquals(a: Readonly, return true; } function gfxChannelBlendStateEquals(a: Readonly, b: Readonly): boolean { - return a.blendMode == b.blendMode && a.blendSrcFactor === b.blendSrcFactor && a.blendDstFactor === b.blendDstFactor; + return a.blendMode === b.blendMode && a.blendSrcFactor === b.blendSrcFactor && a.blendDstFactor === b.blendDstFactor; } function gfxAttachmentStateEquals(a: Readonly, b: Readonly): boolean { if (!gfxChannelBlendStateEquals(a.rgbBlendState, b.rgbBlendState)) return false; diff --git a/src/gfx/platform/GfxPlatformWebGL2.ts b/src/gfx/platform/GfxPlatformWebGL2.ts index 255e56111..9f5f3bc6c 100644 --- a/src/gfx/platform/GfxPlatformWebGL2.ts +++ b/src/gfx/platform/GfxPlatformWebGL2.ts @@ -328,8 +328,8 @@ function findall(haystack: string, needle: RegExp): RegExpExecArray[] { function isBlendStateNone(blendState: GfxChannelBlendState): boolean { return ( - blendState.blendMode == GfxBlendMode.Add && - blendState.blendSrcFactor == GfxBlendFactor.One && + blendState.blendMode === GfxBlendMode.Add && + blendState.blendSrcFactor === GfxBlendFactor.One && blendState.blendDstFactor === GfxBlendFactor.Zero ); } diff --git a/src/gfx/render/GfxRenderInstManager.ts b/src/gfx/render/GfxRenderInstManager.ts index d7ddc6929..a480f3874 100644 --- a/src/gfx/render/GfxRenderInstManager.ts +++ b/src/gfx/render/GfxRenderInstManager.ts @@ -480,7 +480,7 @@ export class GfxRenderInst { if (sampleCount === -1) sampleCount = depthStencilAttachmentDescriptor.sampleCount; else - assert(sampleCount == depthStencilAttachmentDescriptor.sampleCount); + assert(sampleCount === depthStencilAttachmentDescriptor.sampleCount); } assert(sampleCount > 0); diff --git a/src/j3d/mkdd_scenes.ts b/src/j3d/mkdd_scenes.ts index 1d676da4b..3faad7d33 100644 --- a/src/j3d/mkdd_scenes.ts +++ b/src/j3d/mkdd_scenes.ts @@ -133,7 +133,7 @@ interface BOL { function parseBOL(buffer: ArrayBufferSlice): BOL { const view = buffer.createDataView(); - assert(readString(buffer, 0x00, 0x04) == '0015'); + assert(readString(buffer, 0x00, 0x04) === '0015'); const objectTableCount = view.getUint16(0x1E); const objectTableOffs = view.getUint32(0x54); @@ -252,7 +252,7 @@ class MKDDSceneDesc implements Viewer.SceneDesc { const btk = BTK.parse(btkFileData); for (const materialInstance of courseModelInstance.materialInstances) { - if (btk.uvAnimationEntries.findIndex((x) => x.materialName == materialInstance.name) != -1) { + if (btk.uvAnimationEntries.findIndex((x) => x.materialName === materialInstance.name) !== -1) { bindTTK1MaterialInstance(materialInstance, courseModelInstance.animationController, btk); } } @@ -525,10 +525,8 @@ class MKDDSceneDesc implements Viewer.SceneDesc { spawnObject(obj, 'objects/wa_search1.bmd', ['objects/wa_search1.bck']); break; case 0x1195: - if (obj.settings[2] == 0) - { + if (obj.settings[2] === 0) spawnObject(obj, 'objects/cannon1.bmd'); - } break; case 0x1196: break; diff --git a/src/nns_g3d/NNS_G3D.ts b/src/nns_g3d/NNS_G3D.ts index 40a8999f4..62e856c94 100644 --- a/src/nns_g3d/NNS_G3D.ts +++ b/src/nns_g3d/NNS_G3D.ts @@ -26,7 +26,7 @@ interface ResDictEntry { export function parseResDictGeneric(buffer: ArrayBufferSlice, tableOffs: number, parseT: (view: DataView, entryTableIdx: number) => T): ResDictEntry[] { const view = buffer.createDataView(); // Revision - assert(view.getUint8(tableOffs + 0x00) == 0x00); + assert(view.getUint8(tableOffs + 0x00) === 0x00); const numEntries = view.getUint8(tableOffs + 0x01); const size = view.getUint16(tableOffs + 0x02, true); const entryOffs = tableOffs + view.getUint16(tableOffs + 0x06, true); @@ -872,7 +872,7 @@ export interface TEX0 { export function parseTex0Block(buffer: ArrayBufferSlice): TEX0 { const view = buffer.createDataView(); - assert(readString(buffer, 0x00, 0x04) == 'TEX0'); + assert(readString(buffer, 0x00, 0x04) === 'TEX0'); const size = view.getUint32(0x04, true); const textureSize = view.getUint16(0x0C, true); diff --git a/src/nns_g3d/Scenes_PokemonHGSS.ts b/src/nns_g3d/Scenes_PokemonHGSS.ts index 205e17ce7..ce6de3b79 100644 --- a/src/nns_g3d/Scenes_PokemonHGSS.ts +++ b/src/nns_g3d/Scenes_PokemonHGSS.ts @@ -96,8 +96,8 @@ class PokemonHGSSSceneDesc implements Viewer.SceneDesc { const mapMatrixData = assertExists(modelCache.getFileData(`map_matrix/${matrixIndex}.bin`)).createDataView(); const width = mapMatrixData.getUint8(0x00); const height = mapMatrixData.getUint8(0x01); - const hasHeightLayer = mapMatrixData.getUint8(0x02) == 1; - const hasHeaderLayer = mapMatrixData.getUint8(0x03) == 1; + const hasHeightLayer = mapMatrixData.getUint8(0x02) === 1; + const hasHeaderLayer = mapMatrixData.getUint8(0x03) === 1; //Read header or file layer and set default height, if the header layer is included this is header, if its not its file let currentMatrixOffset = 0x05 + mapMatrixData.getUint8(0x04); diff --git a/src/nns_g3d/Scenes_PokemonPlatinum.ts b/src/nns_g3d/Scenes_PokemonPlatinum.ts index 53cb89b46..f4f7bd459 100644 --- a/src/nns_g3d/Scenes_PokemonPlatinum.ts +++ b/src/nns_g3d/Scenes_PokemonPlatinum.ts @@ -425,8 +425,8 @@ class PokemonPlatinumSceneDesc implements Viewer.SceneDesc { const mapMatrixData = assertExists(modelCache.getFileData(`map_matrix/${matrixIndex}.bin`)).createDataView(); const width = mapMatrixData.getUint8(0x00); const height = mapMatrixData.getUint8(0x01); - const hasHeightLayer = mapMatrixData.getUint8(0x02) == 1; - const hasHeaderLayer = mapMatrixData.getUint8(0x03) == 1; + const hasHeightLayer = mapMatrixData.getUint8(0x02) === 1; + const hasHeaderLayer = mapMatrixData.getUint8(0x03) === 1; //Read header or file layer and set default height, if the header layer is included this is header, if its not its file let currentMatrixOffset = 0x05 + mapMatrixData.getUint8(0x04); diff --git a/src/nns_g3d/nsmbds_scenes.ts b/src/nns_g3d/nsmbds_scenes.ts index e608be7c9..7a04c93b0 100644 --- a/src/nns_g3d/nsmbds_scenes.ts +++ b/src/nns_g3d/nsmbds_scenes.ts @@ -197,19 +197,19 @@ class NewSuperMarioBrosDSSceneDesc implements Viewer.SceneDesc { for (let i = 0; i < objects.length; i++) { const element = objects[i]; - if (element.type == WorldMapObjType.ROUTE_POINT) { + if (element.type === WorldMapObjType.ROUTE_POINT) { const obj = this.createRendererFromData(cache, mapPointObjData!, element.position); obj.bindPAT0(device, assertExists(mapPointObjData!.btp).pat0[3]); renderer.objectRenderers.push(obj); - } else if (element.type == WorldMapObjType.START_POINT) { + } else if (element.type === WorldMapObjType.START_POINT) { const obj = this.createRendererFromData(cache, mapPointObjData!, element.position); obj.bindPAT0(device, assertExists(mapPointObjData!.btp).pat0[2]); renderer.objectRenderers.push(obj); - } else if (element.type == WorldMapObjType.TOWER) { + } else if (element.type === WorldMapObjType.TOWER) { renderer.objectRenderers.push(this.createRendererFromData(cache, towerObjData!, element.position)); - } else if (element.type == WorldMapObjType.CASTLE) { + } else if (element.type === WorldMapObjType.CASTLE) { renderer.objectRenderers.push(this.createRendererFromData(cache, castleObjData!, element.position)); - } else if (element.type == WorldMapObjType.BIG_CASTLE) { + } else if (element.type === WorldMapObjType.BIG_CASTLE) { renderer.objectRenderers.push(this.createRendererFromData(cache, bigCastleObjData!, element.position)); } } diff --git a/src/psychonauts/plb.ts b/src/psychonauts/plb.ts index 7f67c4977..1844123ee 100644 --- a/src/psychonauts/plb.ts +++ b/src/psychonauts/plb.ts @@ -212,7 +212,7 @@ function readEMeshFrag(stream: DataStream, version: number): EMeshFrag { if (!!(materialFlags & MaterialFlags.Lightmap)) { const lightmap0TextureID = stream.readUint32(); const lightmap1TextureID = stream.readUint32(); - if (lightmap1TextureID != 0xFFFFFFFF) { + if (lightmap1TextureID !== 0xFFFFFFFF) { const switchLightName = stream.readStringStream_4b(); } @@ -254,7 +254,7 @@ function readEMeshFrag(stream: DataStream, version: number): EMeshFrag { const streamUVCount = stream.readUint32(); let streamUV: ArrayBufferSlice | null = null; let uvCoordScale: number = 0; - if (streamUVCount != 0) { + if (streamUVCount !== 0) { uvCoordScale = stream.readFloat32(); streamUV = stream.readSlice(0x04 * streamUVCount * iVertCount); } diff --git a/src/psychonauts/ppf.ts b/src/psychonauts/ppf.ts index c636dba89..06c3a5f47 100644 --- a/src/psychonauts/ppf.ts +++ b/src/psychonauts/ppf.ts @@ -213,7 +213,7 @@ function EGameTextureManager_ReadPackFile(stream: DataStream): PPAK_Texture[] { marker = stream.readUint16(); } - assert(marker != 0xFFFF); + assert(marker !== 0xFFFF); const textureCount = marker; EGameTextureManager_ReadPackFileTextures(stream, textures, textureCount); return textures; diff --git a/src/rres/render.ts b/src/rres/render.ts index 438d6a791..e50ff8aaa 100644 --- a/src/rres/render.ts +++ b/src/rres/render.ts @@ -789,7 +789,7 @@ export class MDL0ModelInstance { let depth = -1; if (modelVisibility !== IntersectionState.Outside) { const rootJoint = mdl0.nodes[0]; - if (rootJoint.bbox != null) { + if (rootJoint.bbox !== null) { bboxScratch.transform(rootJoint.bbox, this.modelMatrix); depth = Math.max(computeViewSpaceDepthFromWorldSpaceAABB(viewerInput.camera.viewMatrix, bboxScratch), 0); } else { diff --git a/src/ui.ts b/src/ui.ts index b6521aceb..9b2259df4 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -1065,7 +1065,7 @@ class SceneSelect extends Panel { if (!explicitlyInvisible) { // If header matches, then we are explicitly visible. - if (!visible == lastGroupHeaderVisible) + if (!visible === lastGroupHeaderVisible) visible = true; // If name matches, then we are explicitly visible. diff --git a/src/zelview/f3dzex.ts b/src/zelview/f3dzex.ts index 7bfb5d450..034c043c9 100644 --- a/src/zelview/f3dzex.ts +++ b/src/zelview/f3dzex.ts @@ -264,7 +264,7 @@ export class DrawCall { public indexCount: number = 0; public usesTexture1(): boolean { - return getCycleTypeFromOtherModeH(this.DP_OtherModeH) == OtherModeH_CycleType.G_CYC_2CYCLE && + return getCycleTypeFromOtherModeH(this.DP_OtherModeH) === OtherModeH_CycleType.G_CYC_2CYCLE && RDP.combineParamsUsesT1(this.DP_Combine); } } @@ -537,7 +537,7 @@ export class RSPState { private _usesTexture1() { const combineParams = RDP.decodeCombineParams(this.DP_CombineH, this.DP_CombineL); - return getCycleTypeFromOtherModeH(this.DP_OtherModeH) == OtherModeH_CycleType.G_CYC_2CYCLE && + return getCycleTypeFromOtherModeH(this.DP_OtherModeH) === OtherModeH_CycleType.G_CYC_2CYCLE && RDP.combineParamsUsesT1(combineParams); } @@ -746,7 +746,7 @@ export class RSPState { const view = lkup.buffer.createDataView(); // TODO: copy correctly; perform interleaving (maybe unnecessary?) // In color-indexed mode, textures are stored in the second half of TMEM (FIXME: really?) - const tmemAddr = this.DP_TextureImageState.fmt == ImageFormat.G_IM_FMT_CI ? 0x800 : (tile.tmem * 8); + const tmemAddr = this.DP_TextureImageState.fmt === ImageFormat.G_IM_FMT_CI ? 0x800 : (tile.tmem * 8); const numBytes = ((getSizBitsPerPixel(this.DP_TextureImageState.siz) * (texels + 1) + 7) / 8)|0; for (let i = 0; i < numBytes; i++) { this.tmem[tmemAddr + i] = view.getUint8(lkup.offs + i);