aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2008-02-27 16:07:38 +0000
committerMax Horn2008-02-27 16:07:38 +0000
commitd31ca4982e52af4a92db77de10c016983ec88269 (patch)
treed83d3148d5841c9d786b3f9ea6d522c9efc55303 /engines
parentd4e9661809a663b894cbcb2ef932165e239df2fb (diff)
downloadscummvm-rg350-d31ca4982e52af4a92db77de10c016983ec88269.tar.gz
scummvm-rg350-d31ca4982e52af4a92db77de10c016983ec88269.tar.bz2
scummvm-rg350-d31ca4982e52af4a92db77de10c016983ec88269.zip
Add support for --list-saves to the sky engine
svn-id: r30987
Diffstat (limited to 'engines')
-rw-r--r--engines/scumm/detection.cpp2
-rw-r--r--engines/sky/control.cpp8
-rw-r--r--engines/sky/sky.cpp53
3 files changed, 58 insertions, 5 deletions
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index cfd0303302..4f10b9a1c3 100644
--- a/engines/scumm/detection.cpp
+++ b/engines/scumm/detection.cpp
@@ -947,7 +947,7 @@ SaveStateList ScummMetaEngine::listSaves(const char *target) const {
sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
SaveStateList saveList;
- for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); file++){
+ for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); file++) {
// Obtain the last 2 digits of the filename, since they correspond to the save slot
int slotNum = atoi(file->c_str() + file->size() - 2);
diff --git a/engines/sky/control.cpp b/engines/sky/control.cpp
index dc36c27df7..53169402e1 100644
--- a/engines/sky/control.cpp
+++ b/engines/sky/control.cpp
@@ -1054,9 +1054,9 @@ void Control::showSprites(dataFileHeader **nameSprites, bool allowSave) {
delete drawResource;
}
-void Control::loadDescriptions(Common::StringList &list) {
+void Control::loadDescriptions(Common::StringList &savenames) {
- list.resize(MAX_SAVE_GAMES);
+ savenames.resize(MAX_SAVE_GAMES);
Common::InSaveFile *inf;
inf = _saveFileMan->openForLoading("SKY-VM.SAV");
@@ -1065,8 +1065,8 @@ void Control::loadDescriptions(Common::StringList &list) {
char *tmpPtr = tmpBuf;
inf->read(tmpBuf, MAX_SAVE_GAMES * MAX_TEXT_LEN);
for (int i = 0; i < MAX_SAVE_GAMES; ++i) {
- list[i] = tmpPtr;
- tmpPtr += list[i].size() + 1;
+ savenames[i] = tmpPtr;
+ tmpPtr += savenames[i].size() + 1;
}
delete inf;
delete[] tmpBuf;
diff --git a/engines/sky/sky.cpp b/engines/sky/sky.cpp
index 9c0f3de9e6..ae1abc677d 100644
--- a/engines/sky/sky.cpp
+++ b/engines/sky/sky.cpp
@@ -31,6 +31,7 @@
#include "common/file.h"
#include "common/fs.h"
#include "common/events.h"
+#include "common/savefile.h"
#include "common/system.h"
#include "common/timer.h"
@@ -114,6 +115,8 @@ public:
virtual GameList detectGames(const FSList &fslist) const;
virtual PluginError createInstance(OSystem *syst, Engine **engine) const;
+
+ virtual SaveStateList listSaves(const char *target) const;
};
const char *SkyMetaEngine::getName() const {
@@ -194,6 +197,56 @@ PluginError SkyMetaEngine::createInstance(OSystem *syst, Engine **engine) const
return kNoError;
}
+SaveStateList SkyMetaEngine::listSaves(const char *target) const {
+ Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+ SaveStateList saveList;
+
+ // Load the descriptions
+ Common::StringList savenames;
+ savenames.resize(MAX_SAVE_GAMES+1);
+
+ Common::InSaveFile *inf;
+ inf = saveFileMan->openForLoading("SKY-VM.SAV");
+ if (inf != NULL) {
+ char *tmpBuf = new char[MAX_SAVE_GAMES * MAX_TEXT_LEN];
+ char *tmpPtr = tmpBuf;
+ inf->read(tmpBuf, MAX_SAVE_GAMES * MAX_TEXT_LEN);
+ for (int i = 0; i < MAX_SAVE_GAMES; ++i) {
+ savenames[i] = tmpPtr;
+ tmpPtr += savenames[i].size() + 1;
+ }
+ delete inf;
+ delete[] tmpBuf;
+ }
+
+ // Find all saves
+ Common::StringList filenames;
+ filenames = saveFileMan->listSavefiles("SKY-VM.???");
+ sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
+
+ // Slot 0 is the autosave, if it exists.
+ // TODO: Check for the existence of the autosave -- but this require us
+ // to know which SKY variant we are looking at.
+ saveList.insert_at(0, SaveStateDescriptor(0, "*AUTOSAVE*", ""));
+
+ // Prepare the list of savestates by looping over all matching savefiles
+ for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); file++) {
+ // Extract the extension
+ Common::String ext = file->c_str() + file->size() - 3;
+ ext.toUppercase();
+ if (isdigit(ext[0]) && isdigit(ext[1]) && isdigit(ext[2])){
+ int slotNum = atoi(ext.c_str());
+ Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+ if (in) {
+ saveList.push_back(SaveStateDescriptor(slotNum+1, savenames[slotNum], *file));
+ delete in;
+ }
+ }
+ }
+
+ return saveList;
+}
+
REGISTER_PLUGIN(SKY, PLUGIN_TYPE_ENGINE, SkyMetaEngine);
namespace Sky {