Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: InCreator on Tue 14/06/2005 12:38:58

Title: checking savegame
Post by: InCreator on Tue 14/06/2005 12:38:58
Is there a way to check if a game is saved into a slot?

I want my game to auto-save in (not selectable) slot when user quits and the game can be played on from "continue" selection from main menu. But I want "continue" option to be disabled when game is not played at all yet. How to check it?
Title: Re: checking savegame
Post by: Eigen on Tue 14/06/2005 14:24:02
Perhaps you could create an empty file, so when autosaves saves the game, this file is created.   And in main menu, continue button will only be shown when this file exists.



-Eigen
Title: Re: checking savegame
Post by: Gilbert on Wed 15/06/2005 02:28:08
The save game files are named:
AGSSAVE.001
AGSSAVE.002
...
Just check if any of them exists, then you may assume the game had been saved, I think normally you won't use more then 20 save games so you can do something like (without counting that auto-save file, #999):

int saveexists=0;
int coutn=1;
string tempstr;
while ((coutn<=20)||(saveexists==0)){
  StrFormat(tempstr,"AGSSAVE.%03d", coutn);
  saveexists=FileOpen (tempstr, FILE_READ); //handle nonzero if exists
  if (saveexists) FileClose(saveexists);
}

if (saveexists) {
  //do whatever  thing you like
} else {
  //something else
}

Note: this is V2.62 code, if you use V2.7+, you may need to modify it, maybe using more variables, since the Open function returns a pointer rather than just an integer now.
Title: Re: checking savegame
Post by: strazer on Wed 15/06/2005 14:12:00
How about using GetSaveSlotDescription?

"GetSaveSlotDescription (int slot, string buffer)

"Gets the text description of save game slot SLOT into the provided BUFFER. If the slot number provided does not exist this function returns 0, if successful it returns 1."
Title: Re: checking savegame
Post by: Kinoko on Wed 15/06/2005 14:52:36
GetSaveSlotDescription is totally the way to go. I use it myself and it works beautifully.