fixed listSaves ordering

svn-id: r35191
This commit is contained in:
Gregory Montoir 2008-11-30 12:23:24 +00:00
parent 2730a6dddc
commit 8d59712192
2 changed files with 14 additions and 7 deletions

View File

@ -125,26 +125,32 @@ public:
virtual SaveStateList listSaves(const char *target) const {
Common::String pattern = Tucker::generateGameStateFileName(target, 0, true);
Common::StringList filenames = g_system->getSavefileManager()->listSavefiles(pattern.c_str());
sort(filenames.begin(), filenames.end());
bool slotsTable[Tucker::kLastSaveSlot + 1];
memset(slotsTable, 0, sizeof(slotsTable));
SaveStateList saveList;
for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
int slot;
const char *ext = strrchr(file->c_str(), '.');
if (ext && (slot = atoi(ext + 1)) >= 0) {
if (ext && (slot = atoi(ext + 1)) >= 0 && slot <= Tucker::kLastSaveSlot) {
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(file->c_str());
if (in) {
char description[64];
snprintf(description, sizeof(description), "savegm.%02d", slot);
saveList.push_back(SaveStateDescriptor(slot, description));
slotsTable[slot] = true;
delete in;
}
}
}
for (int slot = 0; slot <= Tucker::kLastSaveSlot; ++slot) {
if (slotsTable[slot]) {
char description[64];
snprintf(description, sizeof(description), "savegm.%02d", slot);
saveList.push_back(SaveStateDescriptor(slot, description));
}
}
return saveList;
}
virtual int getMaximumSaveSlot() const {
return 99;
return Tucker::kLastSaveSlot;
}
virtual void removeSaveState(const char *target, int slot) const {

View File

@ -176,7 +176,8 @@ enum {
kFadePaletteStep = 5,
kStartupLocation = 1,
kDefaultCharSpeechSoundCounter = 1,
kMaxSoundVolume = 127
kMaxSoundVolume = 127,
kLastSaveSlot = 99
};
enum Verb {