Skip to content

Commit

Permalink
Fix a couple of small autosave bugs. Fixes #42
Browse files Browse the repository at this point in the history
  • Loading branch information
curiousdannii committed Feb 21, 2017
1 parent 998d1a0 commit ce36e36
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/zvm.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ api = {
{
this.glk_event.push_field( this.glk_blocking_call );
}
Glk.update();
}
Glk.update()
}
catch ( e )
{
Expand Down Expand Up @@ -201,8 +201,8 @@ api = {
{
this.glk_event.push_field( this.glk_blocking_call );
}
Glk.update();
}
Glk.update()
}
catch ( e )
{
Expand Down
2 changes: 1 addition & 1 deletion src/zvm/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ module.exports = {
}
}
}
this.set_window( 0 );
this.set_window( this.io.currentwin )
},

erase_line: function( value )
Expand Down
27 changes: 16 additions & 11 deletions src/zvm/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,24 +193,29 @@ module.exports = {
this.xorshift_seed = snapshot.xorshift_seed
},

do_autosave: function()
do_autosave: function( save )
{
if ( !this.options.Dialog )
{
throw new Error( 'A reference to Dialog is required' )
}
const snapshot = {
glk: this.Glk.save_allstate(),
io: cloneDeep( this.io ),
ram: this.save_file( this.pc ),
read_data: cloneDeep( this.read_data ),
xorshift_seed: this.xorshift_seed,

let snapshot = null
if ( ( save || 0 ) >= 0 )
{
snapshot = {
glk: this.Glk.save_allstate(),
io: cloneDeep( this.io ),
ram: this.save_file( this.pc ),
read_data: cloneDeep( this.read_data ),
xorshift_seed: this.xorshift_seed,
}
delete snapshot.io.streams[2].str
delete snapshot.io.streams[2].str
delete snapshot.read_data.buffer
}
delete snapshot.io.streams[2].str
delete snapshot.io.streams[2].str
delete snapshot.read_data.buffer

this.options.Dialog.autosave_write( this.get_signature(), snapshot )
this.options.Dialog.autosave_write( this.signature, snapshot )
},

encode_text: function( zscii, length, from, target )
Expand Down

0 comments on commit ce36e36

Please sign in to comment.