[Scummvm-cvs-logs] SF.net SVN: scummvm: [30987] scummvm/trunk/engines
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Wed Feb 27 17:07:38 CET 2008
Revision: 30987
http://scummvm.svn.sourceforge.net/scummvm/?rev=30987&view=rev
Author: fingolfin
Date: 2008-02-27 08:07:38 -0800 (Wed, 27 Feb 2008)
Log Message:
-----------
Add support for --list-saves to the sky engine
Modified Paths:
--------------
scummvm/trunk/engines/scumm/detection.cpp
scummvm/trunk/engines/sky/control.cpp
scummvm/trunk/engines/sky/sky.cpp
Modified: scummvm/trunk/engines/scumm/detection.cpp
===================================================================
--- scummvm/trunk/engines/scumm/detection.cpp 2008-02-27 15:44:39 UTC (rev 30986)
+++ scummvm/trunk/engines/scumm/detection.cpp 2008-02-27 16:07:38 UTC (rev 30987)
@@ -947,7 +947,7 @@
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);
Modified: scummvm/trunk/engines/sky/control.cpp
===================================================================
--- scummvm/trunk/engines/sky/control.cpp 2008-02-27 15:44:39 UTC (rev 30986)
+++ scummvm/trunk/engines/sky/control.cpp 2008-02-27 16:07:38 UTC (rev 30987)
@@ -1054,9 +1054,9 @@
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 @@
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;
Modified: scummvm/trunk/engines/sky/sky.cpp
===================================================================
--- scummvm/trunk/engines/sky/sky.cpp 2008-02-27 15:44:39 UTC (rev 30986)
+++ scummvm/trunk/engines/sky/sky.cpp 2008-02-27 16:07:38 UTC (rev 30987)
@@ -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 @@
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 @@
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 {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list