Skip to content

Commit

Permalink
Don't serialize demo pause state and frame number when not playing a …
Browse files Browse the repository at this point in the history
…demo
  • Loading branch information
themikelester committed Nov 22, 2024
1 parent 1ee35fc commit cf5e974
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/ZeldaWindWaker/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,15 +631,16 @@ export class WindWakerRenderer implements Viewer.SceneGfx {

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

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

0 comments on commit cf5e974

Please sign in to comment.