I need to identify the source of some inconsistent restore behaviour. Odds are the source is going to be related to my custom save code (originally by Erik Temple)
So, normally in an I7 game, if you save a game and restore it, there’s no look by default upon the restore. I checked that.
In my project I’m using custom quicksave/quickrestore code that saves a file to a slot without using a dialogue.
What I’ve noticed when using this code:
-
In the IDE or Gargoyle, a look occurs after the restore. It seems to happen ‘automatically’ - I don’t have a rule asking for a look.
-
In Quixe, the look doesn’t happen automatically.
This would normally not be a big deal except the CYOA engine is wrapped around the skeleton of LOOK.
Obviously, if I add a post-restore look myself, I end up with 2 looks in IDE/Gargoyle, and just the one I need in Quixe.
I’m going to paste the I6 and the hooks here in case someone can see something to target re: why this is happening:
[rant][code]Part - Quicksaving
A save slot is a kind of thing. slot 1 is a save slot.
A save slot has an external file called the savedata.
The binary file of slot 1 is called “slot1”. The savedata of slot 1 is the file of slot 1.
An external file can be a save file.
the file of slot 1 is a save file.
Restoring from a saved game is an activity.
Failing to restore from a saved game is an activity.
Automatically saving the game is an activity.
Failing to automatically save the game is an activity.
For restoring from a saved game (this is the restoring from a saved game rule):
say “[bold type][bracket]Game restored - play on.[close bracket][default type][paragraph break]”;
For failing to restore from a saved game (this is the failing to restore from a saved game rule):
say “[bold type][bracket]Sorry, your game could not be restored for some reason.[close bracket][default type]” (A);
For automatically saving the game (this is the automatically saving the game rule):
say text of save the game rule response (B);
For failing to automatically save the game (this is the failing to automatically save the game rule):
say “[bold type][bracket]Sorry, your game could not be saved for some reason.[close bracket][default type]” (A);
To load_savedata (filename - save file external file):
(- FileIO_LoadSavedGame({filename}); -).
To write_savedata to (filename - save file external file): [see note above on read routine]
(- FileIO_WriteSavedGame({filename}); -).
To set (filename - external file) as a save file:
(- FileIO_SetSaveFile( {filename} ); -).
To decide if (filename - external file) exists: [This phrase can be used on both save game files AND regular table files]
if filename is a save file:
set filename as a save file;
decide on whether or not filename exists part b;
To decide if (filename - external file) exists part b:
(- (FileIO_Exists({filename}, false)) -).
Include (-
[ FileIO_LoadSavedGame extf struc fref res;
if ((extf < 1) || (extf > NO_EXTERNAL_FILES))
return FileIO_Error(extf, “tried to access a non-file”);
struc = TableOfExternalFiles–>extf;
fref = glk_fileref_create_by_name(fileusage_SavedGame + fileusage_BinaryMode, Glulx_ChangeAnyToCString(struc–>AUXF_FILENAME), 0);
if (fref == 0) jump RFailed;
gg_savestr = glk_stream_open_file(fref, $02, GG_SAVESTR_ROCK);
glk_fileref_destroy(fref);
if (gg_savestr == 0) jump RFailed;
@restore gg_savestr res;
glk_stream_close(gg_savestr, 0);
gg_savestr = 0;
rtrue;
.RFailed;
CarryOutActivity( (+ failing to restore from a saved game +) );
];
[ FileIO_WriteSavedGame extf struc fref res;
if (actor ~= player) rfalse;
if ((extf < 1) || (extf > NO_EXTERNAL_FILES))
return FileIO_Error(extf, "tried to access a non-file");
struc = TableOfExternalFiles-->extf;
fref = glk_fileref_create_by_name(fileusage_SavedGame + fileusage_BinaryMode, Glulx_ChangeAnyToCString(struc-->AUXF_FILENAME), 0);
if (fref == 0) jump SFailed;
gg_savestr = glk_stream_open_file(fref, $01, GG_SAVESTR_ROCK);
glk_fileref_destroy(fref);
if (gg_savestr == 0) jump SFailed;
@save gg_savestr res;
if (res == -1) {
! The player actually just typed "restore". We have to recover all the Glk objects;
! the values in our global variables are all wrong.
GGRecoverObjects();
glk_stream_close(gg_savestr, 0); ! stream_close
gg_savestr = 0;
CarryOutActivity( (+ restoring from a saved game +) );
rtrue;
}
glk_stream_close(gg_savestr, 0); ! stream_close
gg_savestr = 0;
if (res == 0) CarryOutActivity( (+ automatically saving the game +) ); rtrue;
.SFailed;
CarryOutActivity( (+ failing to automatically save the game +) );
];
[ FileIO_SetSaveFile extf struc;
if ((extf < 1) || (extf > NO_EXTERNAL_FILES))
return FileIO_Error(extf, “tried to access a non-file”);
struc = TableOfExternalFiles–>extf;
struc–>AUXF_BINARY = struc–>AUXF_BINARY | 2;
];
-).
[We will also alter the built in if (external file) exists phrase so that we don’t confuse matters with two similar phrases.]
Include (-
[ FileIO_Exists extf fref struc rv usage;
if ((extf < 1) || (extf > NO_EXTERNAL_FILES)) rfalse;
struc = TableOfExternalFiles–>extf;
if ((struc == 0) || (struc–>AUXF_MAGIC ~= AUXF_MAGIC_VALUE)) rfalse;
if ( struc–>AUXF_BINARY )
{
usage = fileusage_BinaryMode;
} else {
usage = fileusage_TextMode;
}
if ( struc–>AUXF_BINARY & 2 == 2 )
{
usage = usage + fileusage_SavedGame;
} else {
usage = usage + fileusage_Data;
}
fref = glk_fileref_create_by_name( usage, Glulx_ChangeAnyToCString(struc–>AUXF_FILENAME), 0 );
rv = glk_fileref_does_file_exist(fref);
glk_fileref_destroy(fref);
return rv;
];
-) instead of “Existence” in “FileIO.i6t”.[/code][/rant]
Then the line to reload a game is ‘load_savedata savedata of slot 1;’
-Wade