Skip to content

Commit

Permalink
fix: error loading erroneous states
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Aug 4, 2024
1 parent 3facbae commit bb2986e
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions frontends/web/ts/gb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,14 +728,23 @@ export class GameboyEmulator extends EmulatorLogic implements Emulator {
}

buildState(index: number, data: Uint8Array): SaveState {
const state = StateManager.read_bos_auto_wa(data);
return {
index: index,
timestamp: Number(state.timestamp_wa()),
agent: state.agent_wa(),
model: state.model_wa(),
thumbnail: state.has_image_wa() ? state.image_eager_wa() : undefined
};
try {
const state = StateManager.read_bos_auto_wa(data);
return {
index: index,
timestamp: Number(state.timestamp_wa()),
agent: state.agent_wa(),
model: state.model_wa(),
thumbnail: state.has_image_wa()
? state.image_eager_wa()
: undefined
};
} catch (err) {
return {
index: index,
error: err
};
}
}

pauseVideo() {
Expand Down

0 comments on commit bb2986e

Please sign in to comment.