[Scummvm-cvs-logs] SF.net SVN: scummvm:[33396] scummvm/branches/gsoc2008-rtl/engines/sword2/ sword2.cpp
cpage88 at users.sourceforge.net
cpage88 at users.sourceforge.net
Tue Jul 29 07:05:04 CEST 2008
Revision: 33396
http://scummvm.svn.sourceforge.net/scummvm/?rev=33396&view=rev
Author: cpage88
Date: 2008-07-29 05:05:04 +0000 (Tue, 29 Jul 2008)
Log Message:
-----------
Added --list-saves support for SWORD2
Modified Paths:
--------------
scummvm/branches/gsoc2008-rtl/engines/sword2/sword2.cpp
Modified: scummvm/branches/gsoc2008-rtl/engines/sword2/sword2.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/sword2/sword2.cpp 2008-07-29 04:51:23 UTC (rev 33395)
+++ scummvm/branches/gsoc2008-rtl/engines/sword2/sword2.cpp 2008-07-29 05:05:04 UTC (rev 33396)
@@ -33,6 +33,7 @@
#include "common/file.h"
#include "common/fs.h"
#include "common/events.h"
+#include "common/savefile.h"
#include "common/system.h"
#include "engines/metaengine.h"
@@ -82,6 +83,7 @@
virtual GameList getSupportedGames() const;
virtual GameDescriptor findGame(const char *gameid) const;
virtual GameList detectGames(const FSList &fslist) const;
+ virtual SaveStateList listSaves(const char *target) const;
virtual PluginError createInstance(OSystem *syst, Engine **engine) const;
};
@@ -156,6 +158,35 @@
return detectedGames;
}
+SaveStateList Sword2MetaEngine::listSaves(const char *target) const {
+ Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+ Common::StringList filenames;
+ char saveDesc[SAVE_DESCRIPTION_LEN];
+ Common::String pattern = target;
+ pattern += ".???";
+
+ filenames = saveFileMan->listSavefiles(pattern.c_str());
+ 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) {
+ // Obtain the last 3 digits of the filename, since they correspond to the save slot
+ int slotNum = atoi(file->c_str() + file->size() - 3);
+
+ if (slotNum >= 0 && slotNum <= 999) {
+ Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+ if (in) {
+ in->readUint32LE();
+ in->read(saveDesc, SAVE_DESCRIPTION_LEN);
+ saveList.push_back(SaveStateDescriptor(slotNum, Common::String(saveDesc), *file));
+ delete in;
+ }
+ }
+ }
+
+ return saveList;
+}
+
PluginError Sword2MetaEngine::createInstance(OSystem *syst, Engine **engine) const {
assert(syst);
assert(engine);
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