[Scummvm-cvs-logs] SF.net SVN: scummvm:[33351] scummvm/branches/gsoc2008-rtl/engines/agi/ detection.cpp

cpage88 at users.sourceforge.net cpage88 at users.sourceforge.net
Mon Jul 28 06:50:27 CEST 2008


Revision: 33351
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33351&view=rev
Author:   cpage88
Date:     2008-07-28 04:50:27 +0000 (Mon, 28 Jul 2008)

Log Message:
-----------
Added --list-saves support for AGI

Modified Paths:
--------------
    scummvm/branches/gsoc2008-rtl/engines/agi/detection.cpp

Modified: scummvm/branches/gsoc2008-rtl/engines/agi/detection.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/agi/detection.cpp	2008-07-28 02:56:17 UTC (rev 33350)
+++ scummvm/branches/gsoc2008-rtl/engines/agi/detection.cpp	2008-07-28 04:50:27 UTC (rev 33351)
@@ -2123,7 +2123,7 @@
 	}
 
 	virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
-
+	virtual SaveStateList listSaves(const char *target) const;
 	const Common::ADGameDescription *fallbackDetect(const FSList *fslist) const;
 };
 
@@ -2147,6 +2147,37 @@
 	return res;
 }
 
+SaveStateList AgiMetaEngine::listSaves(const char *target) const {
+	const uint32 AGIflag = MKID_BE('AGI:');
+	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+	Common::StringList filenames;
+	char saveDesc[260];
+	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) {
+				uint32 type = in->readUint32BE();
+				if (type == AGIflag)
+					in->read(saveDesc, 31);
+				saveList.push_back(SaveStateDescriptor(slotNum, Common::String(saveDesc), *file));
+				delete in;
+			}
+		}
+	}
+
+	return saveList;
+}
+
 const Common::ADGameDescription *AgiMetaEngine::fallbackDetect(const FSList *fslist) const {
 	typedef Common::HashMap<Common::String, int32> IntMap;
 	IntMap allFiles;


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