[Scummvm-cvs-logs] SF.net SVN: scummvm:[33398] scummvm/branches/gsoc2008-rtl/engines/touche

cpage88 at users.sourceforge.net cpage88 at users.sourceforge.net
Tue Jul 29 08:04:16 CEST 2008


Revision: 33398
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33398&view=rev
Author:   cpage88
Date:     2008-07-29 06:04:16 +0000 (Tue, 29 Jul 2008)

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

Modified Paths:
--------------
    scummvm/branches/gsoc2008-rtl/engines/touche/detection.cpp
    scummvm/branches/gsoc2008-rtl/engines/touche/saveload.cpp
    scummvm/branches/gsoc2008-rtl/engines/touche/touche.h

Modified: scummvm/branches/gsoc2008-rtl/engines/touche/detection.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/touche/detection.cpp	2008-07-29 05:58:36 UTC (rev 33397)
+++ scummvm/branches/gsoc2008-rtl/engines/touche/detection.cpp	2008-07-29 06:04:16 UTC (rev 33398)
@@ -25,6 +25,7 @@
 
 #include "common/config-manager.h"
 #include "common/advancedDetector.h"
+#include "common/savefile.h"
 
 #include "base/plugins.h"
 
@@ -136,6 +137,7 @@
 	}
 
 	virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
+	virtual SaveStateList listSaves(const char *target) const;
 };
 
 bool ToucheMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
@@ -146,6 +148,57 @@
 	return gd != 0;
 }
 
+SaveStateList ToucheMetaEngine::listSaves(const char *target) const {
+	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+	Common::StringList filenames;
+	char saveDesc[Touche::kGameStateDescriptionLen];
+	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 digit of the filename, since they correspond to the save slot
+		int slotNum = atoi(file->c_str() + file->size() - 1);
+	
+		if (slotNum >= 0 && slotNum <= 9) {
+			Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+			if (in) {
+				in->readUint16LE();
+				in->readUint16LE();
+				in->read(saveDesc, Touche::kGameStateDescriptionLen);
+				saveList.push_back(SaveStateDescriptor(slotNum, Common::String(saveDesc), *file));
+				delete in;
+			}
+		}
+	}
+	
+	pattern += "?";
+
+	filenames = saveFileMan->listSavefiles(pattern.c_str());
+	sort(filenames.begin(), filenames.end());	// Sort (hopefully ensuring we are sorted numerically..)
+
+	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);
+	
+		if (slotNum >= 10 && slotNum <= 99) {
+			Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+			if (in) {
+				in->readUint16LE();
+				in->readUint16LE();
+				in->read(saveDesc, Touche::kGameStateDescriptionLen);
+				saveList.push_back(SaveStateDescriptor(slotNum, Common::String(saveDesc), *file));
+				delete in;
+			}
+		}
+	}
+
+	return saveList;
+}
+
 #if PLUGIN_ENABLED_DYNAMIC(TOUCHE)
 	REGISTER_PLUGIN_DYNAMIC(TOUCHE, PLUGIN_TYPE_ENGINE, ToucheMetaEngine);
 #else

Modified: scummvm/branches/gsoc2008-rtl/engines/touche/saveload.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/touche/saveload.cpp	2008-07-29 05:58:36 UTC (rev 33397)
+++ scummvm/branches/gsoc2008-rtl/engines/touche/saveload.cpp	2008-07-29 06:04:16 UTC (rev 33398)
@@ -31,11 +31,6 @@
 
 namespace Touche {
 
-enum {
-	kCurrentGameStateVersion = 6,
-	kGameStateDescriptionLen = 32
-};
-
 static void saveOrLoad(Common::WriteStream &stream, uint16 &i) {
 	stream.writeUint16LE(i);
 }

Modified: scummvm/branches/gsoc2008-rtl/engines/touche/touche.h
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/touche/touche.h	2008-07-29 05:58:36 UTC (rev 33397)
+++ scummvm/branches/gsoc2008-rtl/engines/touche/touche.h	2008-07-29 06:04:16 UTC (rev 33398)
@@ -328,7 +328,9 @@
 	kCursorHeight = 42,
 	kTextHeight = 16,
 	kMaxProgramDataSize = 61440,
-	kMaxSaveStates = 100
+	kMaxSaveStates = 100,
+	kGameStateDescriptionLen = 32,	// Need these two values defined here
+	kCurrentGameStateVersion = 6	// for --list-saves support
 };
 
 class MidiPlayer;


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