[Scummvm-cvs-logs] SF.net SVN: scummvm:[49132] scummvm/trunk

sev at users.sourceforge.net sev at users.sourceforge.net
Fri May 21 20:25:02 CEST 2010


Revision: 49132
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49132&view=rev
Author:   sev
Date:     2010-05-21 18:25:01 +0000 (Fri, 21 May 2010)

Log Message:
-----------
Implement FR #2988017: exit status with --list-saves always 0

Modified Paths:
--------------
    scummvm/trunk/base/commandLine.cpp
    scummvm/trunk/base/commandLine.h
    scummvm/trunk/base/main.cpp
    scummvm/trunk/common/error.h

Modified: scummvm/trunk/base/commandLine.cpp
===================================================================
--- scummvm/trunk/base/commandLine.cpp	2010-05-21 18:22:11 UTC (rev 49131)
+++ scummvm/trunk/base/commandLine.cpp	2010-05-21 18:25:01 UTC (rev 49132)
@@ -602,7 +602,9 @@
 }
 
 /** List all saves states for the given target. */
-static void listSaves(const char *target) {
+static Common::Error listSaves(const char *target) {
+	Common::Error result = Common::kNoError;
+
 	// FIXME HACK
 	g_system->initBackend();
 
@@ -627,13 +629,14 @@
 	GameDescriptor game = EngineMan.findGame(gameid, &plugin);
 
 	if (!plugin) {
-		error("Could not find any plugin to handle target '%s' (gameid '%s')", target, gameid.c_str());
-		return;
+		warning("Could not find any plugin to handle target '%s' (gameid '%s')", target, gameid.c_str());
+		return Common::kPluginNotFound;
 	}
 
 	if (!(*plugin)->hasFeature(MetaEngine::kSupportsListSaves)) {
 		// TODO: Include more info about the target (desc, engine name, ...) ???
 		printf("ScummVM does not support listing save states for target '%s' (gameid '%s') .\n", target, gameid.c_str());
+		result = Common::kPluginNotSupportSaves;
 	} else {
 		// Query the plugin for a list of savegames
 		SaveStateList saveList = (*plugin)->listSaves(target);
@@ -643,6 +646,9 @@
 		printf("  Slot Description                                           \n"
 		       "  ---- ------------------------------------------------------\n");
 
+		if (saveList.size() == 0)
+			result = Common::kNoSavesError;
+
 		for (SaveStateList::const_iterator x = saveList.begin(); x != saveList.end(); ++x) {
 			printf("  %-4s %s\n", x->save_slot().c_str(), x->description().c_str());
 			// TODO: Could also iterate over the full hashmap, printing all key-value pairs
@@ -651,6 +657,8 @@
 
 	// Revert to the old active domain
 	ConfMan.setActiveDomain(oldDomain);
+
+	return result;
 }
 
 /** Lists all usable themes */
@@ -863,7 +871,7 @@
 #endif // DISABLE_COMMAND_LINE
 
 
-bool processSettings(Common::String &command, Common::StringMap &settings) {
+Common::Error processSettings(Common::String &command, Common::StringMap &settings) {
 
 #ifndef DISABLE_COMMAND_LINE
 
@@ -872,34 +880,33 @@
 	// have been loaded.
 	if (command == "list-targets") {
 		listTargets();
-		return false;
+		return Common::kNoError;
 	} else if (command == "list-games") {
 		listGames();
-		return false;
+		return Common::kNoError;
 	} else if (command == "list-saves") {
-		listSaves(settings["list-saves"].c_str());
-		return false;
+		return listSaves(settings["list-saves"].c_str());
 	} else if (command == "list-themes") {
 		listThemes();
-		return false;
+		return Common::kNoError;
 	} else if (command == "version") {
 		printf("%s\n", gScummVMFullVersion);
 		printf("Features compiled in: %s\n", gScummVMFeatures);
-		return false;
+		return Common::kNoError;
 	} else if (command == "help") {
 		printf(HELP_STRING, s_appName);
-		return false;
+		return Common::kNoError;
 	}
 #ifdef DETECTOR_TESTING_HACK
 	else if (command == "test-detector") {
 		runDetectorTest();
-		return false;
+		return Common::kNoError;
 	}
 #endif
 #ifdef UPGRADE_ALL_TARGETS_HACK
 	else if (command == "upgrade-targets") {
 		upgradeTargets();
-		return false;
+		return Common::kNoError;
 	}
 #endif
 
@@ -971,7 +978,7 @@
 		ConfMan.set(key, value, Common::ConfigManager::kTransientDomain);
 	}
 
-	return true;
+	return Common::kArgumentNotProcessed;
 }
 
 } // End of namespace Base

Modified: scummvm/trunk/base/commandLine.h
===================================================================
--- scummvm/trunk/base/commandLine.h	2010-05-21 18:22:11 UTC (rev 49131)
+++ scummvm/trunk/base/commandLine.h	2010-05-21 18:25:01 UTC (rev 49132)
@@ -33,7 +33,7 @@
 
 void registerDefaults();
 Common::String parseCommandLine(Common::StringMap &settings, int argc, const char * const *argv);
-bool processSettings(Common::String &command, Common::StringMap &settings);
+Common::Error processSettings(Common::String &command, Common::StringMap &settings);
 
 } // End of namespace Base
 

Modified: scummvm/trunk/base/main.cpp
===================================================================
--- scummvm/trunk/base/main.cpp	2010-05-21 18:22:11 UTC (rev 49131)
+++ scummvm/trunk/base/main.cpp	2010-05-21 18:25:01 UTC (rev 49132)
@@ -340,9 +340,11 @@
 
 	// Process the remaining command line settings. Must be done after the
 	// config file and the plugins have been loaded.
-	if (!Base::processSettings(command, settings))
-		return 0;
+	Common::Error res;
 
+	if ((res = Base::processSettings(command, settings)) != Common::kArgumentNotProcessed)
+		return res;
+
 	// Init the backend. Must take place after all config data (including
 	// the command line params) was read.
 	system.initBackend();

Modified: scummvm/trunk/common/error.h
===================================================================
--- scummvm/trunk/common/error.h	2010-05-21 18:22:11 UTC (rev 49131)
+++ scummvm/trunk/common/error.h	2010-05-21 18:25:01 UTC (rev 49132)
@@ -59,10 +59,16 @@
 	kPathNotDirectory,			///< The specified path does not point to a directory
 	kPathNotFile,				///< The specified path does not point to a file
 
-	kCreatingFileFailed,
-	kReadingFailed,				///< Failed creating a (savestate) file
+	kCreatingFileFailed,		///< Failed creating a (savestate) file
+	kReadingFailed,				///< Failed to read a file (permission denied?)
 	kWritingFailed,				///< Failure to write data -- disk full?
 
+	// The following are used by --list-saves
+	kPluginNotFound,			///< Failed to find plugin to handle tager
+	kPluginNotSupportSaves,		///< Failed if plugin does not support saves
+	kNoSavesError,				///< There are no saves to show
+
+	kArgumentNotProcessed,		///< Used in command line parsing
 	kUnknownError				///< Catch-all error, used if no other error code matches
 };
 


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