Skip to content

Commit cf5e974

Browse files
committed
Don't serialize demo pause state and frame number when not playing a demo
1 parent 1ee35fc commit cf5e974

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/ZeldaWindWaker/Main.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,15 +631,16 @@ export class WindWakerRenderer implements Viewer.SceneGfx {
631631

632632
public serializeSaveState(dst: ArrayBuffer, offs: number): number {
633633
const view = new DataView(dst);
634-
view.setUint8(offs++, this.isPaused ? 1 : 0);
635-
view.setUint16(offs, this.globals.scnPlay.demo.getFrame());
634+
const isDemo = this.globals.scnPlay.demo.getMode() == EDemoMode.Playing;
635+
view.setUint8(offs++, (isDemo && this.isPaused) ? 1 : 0);
636+
view.setUint16(offs, isDemo ? this.globals.scnPlay.demo.getFrame() : 0);
636637
return offs + 2;
637638
}
638639

639640
public deserializeSaveState(src: ArrayBuffer, offs: number, byteLength: number): number {
640641
const view = new DataView(src);
641642
this.isPaused = !!view.getUint8(offs++);
642-
this.globals.scnPlay.demo.setFrame(view.getUint16(offs));
643+
this.globals.scnPlay.demo.setFrame(view.getUint16(offs)); // @TODO: This won't work when loading without re-creating the scene
643644
this.togglePlayPause(!this.isPaused);
644645
return offs + 2;
645646
}

0 commit comments

Comments
 (0)