diff --git a/src/Common/JSYSTEM/JStudio.ts b/src/Common/JSYSTEM/JStudio.ts index 5d078504e..b495cfffa 100644 --- a/src/Common/JSYSTEM/JStudio.ts +++ b/src/Common/JSYSTEM/JStudio.ts @@ -574,8 +574,7 @@ class TActorAdaptor extends TAdaptor { if (reverse) { frame = maxFrame - frame; } if (maxFrame > 0.0) { - const func = FVB.TFunctionValue.toFunction_outside(outsideType); - frame = func(frame, maxFrame); + frame = FVB.TFunctionValue.calcFunction_outside(outsideType, frame, maxFrame); } return frame; } @@ -1135,12 +1134,12 @@ namespace FVB { public setIdNo(idNo: number) { this.idNo = idNo; } - public static toFunction_outside(type: EExtrapolateType): (frame: number, maxFrame: number) => number { + public static calcFunction_outside(type: EExtrapolateType, frame: number, maxFrame: number) { switch (type) { - case EExtrapolateType.Raw: return (f, m) => f; - case EExtrapolateType.Repeat: return (f, m) => { f = f % m; return f < 0 ? f + m : f; } - case EExtrapolateType.Turn: return (f, m) => { f %= (2 * m); if (f < 0) f += m; return f > m ? 2 * m - f : f }; - case EExtrapolateType.Clamp: return (f, m) => clamp(f, 0.0, m); + case EExtrapolateType.Raw: return frame; + case EExtrapolateType.Repeat: frame = frame % maxFrame; return frame < 0 ? frame + maxFrame : frame; + case EExtrapolateType.Turn: frame %= (2 * maxFrame); if (frame < 0) frame += maxFrame; return frame > maxFrame ? 2 * maxFrame - frame : frame; + case EExtrapolateType.Clamp: return clamp(frame, 0.0, maxFrame); } } } @@ -1391,8 +1390,8 @@ namespace FVB { private extrapolate(progress: number) { let t = progress t -= this.begin; - if( t < 0.0 ) { t = FVB.TFunctionValue.toFunction_outside(this.underflow)(t, this.diff); } - else if( t >= this.diff) { t = FVB.TFunctionValue.toFunction_outside(this.overflow)(t, this.diff); } + if (t < 0.0) { t = FVB.TFunctionValue.calcFunction_outside(this.underflow, t, this.diff); } + else if (t >= this.diff) { t = FVB.TFunctionValue.calcFunction_outside(this.overflow, t, this.diff); } t += this.begin; return t; } @@ -1920,7 +1919,6 @@ export class TControl { } public forward(frameCount: number): boolean { - ; let andStatus = 0xFF; let orStatus = 0; @@ -1969,7 +1967,7 @@ export class TControl { } public createMessageObject(blockObj: TBlockObject): STBObject | null { - if( blockObj.type == 'JMSG' ) { + if (blockObj.type == 'JMSG') { const adaptor = new TMessageAdaptor(this.msgControl); const obj = new TMessageObject(this, blockObj, adaptor); diff --git a/src/ZeldaWindWaker/Main.ts b/src/ZeldaWindWaker/Main.ts index 161281d56..0d62895cc 100644 --- a/src/ZeldaWindWaker/Main.ts +++ b/src/ZeldaWindWaker/Main.ts @@ -328,7 +328,6 @@ export class dCamera_c { if (!this.frozen) { // Update the "player position" from the camera. - // TODO: Move this out of here vec3.copy(globals.playerPosition, this.cameraPos); } } diff --git a/src/ZeldaWindWaker/d_a.ts b/src/ZeldaWindWaker/d_a.ts index c797dbc11..957157a63 100644 --- a/src/ZeldaWindWaker/d_a.ts +++ b/src/ZeldaWindWaker/d_a.ts @@ -4766,11 +4766,12 @@ class d_a_npc_ls1 extends fopNpc_npc_c { { anmIdx: 0, nextPrmIdx: 1, morf: 8.0, playSpeed: 1.0, loopMode: 2, }, { anmIdx: 5, nextPrmIdx: 1, morf: 8.0, playSpeed: 1.0, loopMode: 2, }, { anmIdx: 10, nextPrmIdx: 2, morf: 8.0, playSpeed: 1.0, loopMode: 2, }, - { anmIdx: 5, nextPrmIdx: 1, morf: 8.0, playSpeed: 1.0, loopMode: 2, }]; + { anmIdx: 5, nextPrmIdx: 1, morf: 8.0, playSpeed: 1.0, loopMode: 2, } + ]; public override subload(globals: dGlobals): cPhs__Status { const success = this.decideType(this.parameters); - if (!success) { return cPhs__Status.Error; } + if (!success) { return cPhs__Status.Stop; } let status = dComIfG_resLoad(globals, this.arcName); if (status !== cPhs__Status.Complete) diff --git a/src/ZeldaWindWaker/d_demo.ts b/src/ZeldaWindWaker/d_demo.ts index 8631add85..f842c9ad8 100644 --- a/src/ZeldaWindWaker/d_demo.ts +++ b/src/ZeldaWindWaker/d_demo.ts @@ -230,7 +230,7 @@ export class dDemo_actor_c extends TActor { case 4: btpId = this.stbData.getInt32(1); break; case 5: btpId = this.stbData.getInt32(2); break; case 6: btpId = this.stbData.getInt32(2); break; - default: + default: return null; } } @@ -242,7 +242,7 @@ export class dDemo_actor_c extends TActor { if ((btpId & 0x10000) != 0) { arcName = globals.roomCtrl.demoArcName!; } - + const btp = globals.resCtrl.getObjectIDRes(ResType.Btp, arcName, btpId); this.textAnimFrameMax = this.stbData.getInt16(6); return btp; @@ -254,29 +254,29 @@ export class dDemo_actor_c extends TActor { } public getBtkData(globals: dGlobals, arcName: string): TTK1 | null { - if (!(this.flags & EDemoActorFlags.HasData)) { - return null; - } - - let btkId; - switch(this.stbDataId) { - case 2: btkId = this.stbData.getInt16(4); break; - case 5: btkId = this.stbData.getInt32(6); break; - case 6: btkId = this.stbData.getInt32(6); break; - default: - return null; - } - - if (btkId == this.btkId) { + if (!(this.flags & EDemoActorFlags.HasData)) { + return null; + } + + let btkId; + switch(this.stbDataId) { + case 2: btkId = this.stbData.getInt16(4); break; + case 5: btkId = this.stbData.getInt32(6); break; + case 6: btkId = this.stbData.getInt32(6); break; + default: return null; - } - - this.btkId = btkId; - if ((btkId & 0x10000) != 0) { - arcName = globals.roomCtrl.demoArcName!; - } - - return globals.resCtrl.getObjectIDRes(ResType.Btk, arcName, btkId); + } + + if (btkId == this.btkId) { + return null; + } + + this.btkId = btkId; + if ((btkId & 0x10000) != 0) { + arcName = globals.roomCtrl.demoArcName!; + } + + return globals.resCtrl.getObjectIDRes(ResType.Btk, arcName, btkId); } public override JSGGetName() { return this.name; } @@ -323,7 +323,7 @@ export class dDemo_actor_c extends TActor { public override JSGSetShape(id: number): void { this.shapeId = id; - this.flags |= EDemoActorFlags.HasShape + this.flags |= EDemoActorFlags.HasShape; } public override JSGSetAnimation(id: number): void { @@ -489,7 +489,7 @@ export class dDemo_manager_c { } /** - * Called by Actor update functions to update their data from the demo version of the actor. + * Called by Actor update functions to update their data from the demo version of the actor. */ export function dDemo_setDemoData(globals: dGlobals, dtFrames: number, actor: fopAc_ac_c, flagMask: number, morf: mDoExt_McaMorf | null = null, arcName: string | null = null) { diff --git a/src/main.ts b/src/main.ts index 9b449e664..b7a03641e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -690,7 +690,7 @@ class Main { private _loadTimeState(sceneDescId: string): void { const timeStateKey = `TimeState/${sceneDescId}`; - const timeStateStr = this.saveManager.loadState(timeStateKey); + const timeStateStr = this.saveManager.loadStateFromLocation(timeStateKey, SaveStateLocation.SessionStorage); if (!timeStateStr) return;