diff options
author | David Corrales | 2007-07-12 17:58:15 +0000 |
---|---|---|
committer | David Corrales | 2007-07-12 17:58:15 +0000 |
commit | 720c974fafaca16b6e86f28ffc14c8c3aa574e15 (patch) | |
tree | d2d1ad9231fdc85099e12234ea14e5e50a89d8be /engines/agos/saveload.cpp | |
parent | c1961f1f76e91595624a2e49e48b0fab5f412f27 (diff) | |
download | scummvm-rg350-720c974fafaca16b6e86f28ffc14c8c3aa574e15.tar.gz scummvm-rg350-720c974fafaca16b6e86f28ffc14c8c3aa574e15.tar.bz2 scummvm-rg350-720c974fafaca16b6e86f28ffc14c8c3aa574e15.zip |
Changed SaveFileManager::listSavegames() function to be engine agnostic. It now returns a list will the full paths of existing files that match a given regex.
Additionally, modified the 5 engines which use the default manager (Agos, Queen, Saga, Scumm and Touche) to parse the filename list and mark the available saves bool array correctly.
svn-id: r28046
Diffstat (limited to 'engines/agos/saveload.cpp')
-rw-r--r-- | engines/agos/saveload.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/engines/agos/saveload.cpp b/engines/agos/saveload.cpp index 32b767073a..61c640d7c5 100644 --- a/engines/agos/saveload.cpp +++ b/engines/agos/saveload.cpp @@ -38,13 +38,29 @@ namespace AGOS { int AGOSEngine::countSaveGames() { Common::InSaveFile *f; + Common::StringList filenames; uint i = 1; + char slot[3]; + int slotNum; bool marks[256]; char *prefix = genSaveName(998); - prefix[strlen(prefix)-3] = '\0'; - _saveFileMan->listSavefiles(prefix, marks, 256); - + prefix[strlen(prefix)-3] = '*'; + prefix[strlen(prefix)-2] = '\0'; + memset(marks, false, 256 * sizeof(bool)); //assume no savegames for this title + filenames = _saveFileMan->listSavefiles(prefix); + + for(Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); file++){ + //Obtain the last 3 digits of the filename, since they correspond to the save slot + slot[0] = file->c_str()[file->size()-3]; + slot[1] = file->c_str()[file->size()-2]; + slot[2] = file->c_str()[file->size()-1]; + + slotNum = atoi(slot); + if(slotNum >= 0 && slotNum < 256) + marks[slotNum] = true; //mark this slot as valid + } + while (i < 256) { if (marks[i] && (f = _saveFileMan->openForLoading(genSaveName(i)))) { @@ -53,6 +69,7 @@ int AGOSEngine::countSaveGames() { } else break; } + return i; } |