From 720c974fafaca16b6e86f28ffc14c8c3aa574e15 Mon Sep 17 00:00:00 2001 From: David Corrales Date: Thu, 12 Jul 2007 17:58:15 +0000 Subject: 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 --- engines/agos/saveload.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'engines/agos/saveload.cpp') 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; } -- cgit v1.2.3