diff options
-rw-r--r-- | engines/tucker/detection.cpp | 18 | ||||
-rw-r--r-- | engines/tucker/tucker.h | 3 |
2 files changed, 14 insertions, 7 deletions
diff --git a/engines/tucker/detection.cpp b/engines/tucker/detection.cpp index 8263b6eb91..cfbac613f5 100644 --- a/engines/tucker/detection.cpp +++ b/engines/tucker/detection.cpp @@ -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 { diff --git a/engines/tucker/tucker.h b/engines/tucker/tucker.h index b26e8b20b4..5d9ad6b007 100644 --- a/engines/tucker/tucker.h +++ b/engines/tucker/tucker.h @@ -176,7 +176,8 @@ enum { kFadePaletteStep = 5, kStartupLocation = 1, kDefaultCharSpeechSoundCounter = 1, - kMaxSoundVolume = 127 + kMaxSoundVolume = 127, + kLastSaveSlot = 99 }; enum Verb { |