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?
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
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.
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."
GetSaveSlotDescription is totally the way to go. I use it myself and it works beautifully.