diff options
author | Matthew Hoops | 2013-02-04 12:34:06 -0500 |
---|---|---|
committer | Matthew Hoops | 2013-02-04 12:34:06 -0500 |
commit | 49ebbfd9dca6630ad38629bbb3a736d18d63a471 (patch) | |
tree | 8503ca603e4980be07a7c8a7089d0774f31214ae | |
parent | 84bea855b4e0ead3ae680f35bb10885c6b70206e (diff) | |
download | scummvm-rg350-49ebbfd9dca6630ad38629bbb3a736d18d63a471.tar.gz scummvm-rg350-49ebbfd9dca6630ad38629bbb3a736d18d63a471.tar.bz2 scummvm-rg350-49ebbfd9dca6630ad38629bbb3a736d18d63a471.zip |
PEGASUS: Sort save file names alphabetically
-rw-r--r-- | engines/pegasus/detection.cpp | 10 | ||||
-rw-r--r-- | engines/pegasus/pegasus.cpp | 10 | ||||
-rw-r--r-- | engines/pegasus/pegasus.h | 2 |
3 files changed, 15 insertions, 7 deletions
diff --git a/engines/pegasus/detection.cpp b/engines/pegasus/detection.cpp index 908005b665..ba631148d5 100644 --- a/engines/pegasus/detection.cpp +++ b/engines/pegasus/detection.cpp @@ -119,12 +119,12 @@ SaveStateList PegasusMetaEngine::listSaves(const char *target) const { // The original had no pattern, so the user must rename theirs // Note that we ignore the target because saves are compatible between // all versions - Common::StringArray filenames = g_system->getSavefileManager()->listSavefiles("pegasus-*.sav"); + Common::StringArray fileNames = Pegasus::PegasusEngine::listSaveFiles(); SaveStateList saveList; - for (uint32 i = 0; i < filenames.size(); i++) { + for (uint32 i = 0; i < fileNames.size(); i++) { // Isolate the description from the file name - Common::String desc = filenames[i].c_str() + 8; + Common::String desc = fileNames[i].c_str() + 8; for (int j = 0; j < 4; j++) desc.deleteLastChar(); @@ -136,8 +136,8 @@ SaveStateList PegasusMetaEngine::listSaves(const char *target) const { void PegasusMetaEngine::removeSaveState(const char *target, int slot) const { // See listSaves() for info on the pattern - Common::StringArray filenames = g_system->getSavefileManager()->listSavefiles("pegasus-*.sav"); - g_system->getSavefileManager()->removeSavefile(filenames[slot].c_str()); + Common::StringArray fileNames = Pegasus::PegasusEngine::listSaveFiles(); + g_system->getSavefileManager()->removeSavefile(fileNames[slot].c_str()); } bool PegasusMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp index 98f0553783..89acac1440 100644 --- a/engines/pegasus/pegasus.cpp +++ b/engines/pegasus/pegasus.cpp @@ -639,9 +639,15 @@ void PegasusEngine::writeContinueStream(Common::WriteStream *stream) { delete[] data; } +Common::StringArray PegasusEngine::listSaveFiles() { + Common::StringArray fileNames = g_system->getSavefileManager()->listSavefiles("pegasus-*.sav"); + Common::sort(fileNames.begin(), fileNames.end()); + return fileNames; +} + Common::Error PegasusEngine::loadGameState(int slot) { - Common::StringArray filenames = _saveFileMan->listSavefiles("pegasus-*.sav"); - Common::InSaveFile *loadFile = _saveFileMan->openForLoading(filenames[slot]); + Common::StringArray fileNames = listSaveFiles(); + Common::InSaveFile *loadFile = _saveFileMan->openForLoading(fileNames[slot]); if (!loadFile) return Common::kUnknownError; diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h index a8f2e1ffca..246414a9d0 100644 --- a/engines/pegasus/pegasus.h +++ b/engines/pegasus/pegasus.h @@ -30,6 +30,7 @@ #include "common/macresman.h" #include "common/rect.h" #include "common/scummsys.h" +#include "common/str-array.h" #include "common/system.h" #include "common/util.h" @@ -195,6 +196,7 @@ public: bool saveRequested() const { return _saveRequested; } void requestLoad() { _loadRequested = true; } bool loadRequested() const { return _loadRequested; } + static Common::StringArray listSaveFiles(); protected: Common::Error run(); |