aboutsummaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorTony Puccinelli2010-08-11 00:54:34 +0000
committerTony Puccinelli2010-08-11 00:54:34 +0000
commit6543062e5701e8011a4b12abffa8afca56f30b3f (patch)
tree2a317b820d5a7feeb903aaeec3c1f37847d21ee5 /base
parent682807f0e916b189c69b60765418ee1ccc327cbf (diff)
parentfffec23a02cc88ed8daba0a3b50007b7e220c075 (diff)
downloadscummvm-rg350-6543062e5701e8011a4b12abffa8afca56f30b3f.tar.gz
scummvm-rg350-6543062e5701e8011a4b12abffa8afca56f30b3f.tar.bz2
scummvm-rg350-6543062e5701e8011a4b12abffa8afca56f30b3f.zip
manually merged base, graphics, common, sound, and gui as I am quite skilled at somehow messing up svn merge :-)
svn-id: r51963
Diffstat (limited to 'base')
-rw-r--r--base/commandLine.cpp35
-rw-r--r--base/commandLine.h2
-rw-r--r--base/main.cpp16
3 files changed, 31 insertions, 22 deletions
diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index e36ddfca54..2f4e78fd80 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -598,7 +598,9 @@ static void listTargets() {
}
/** 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();
@@ -623,13 +625,14 @@ static void listSaves(const char *target) {
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);
@@ -639,6 +642,9 @@ static void listSaves(const char *target) {
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
@@ -647,6 +653,8 @@ static void listSaves(const char *target) {
// Revert to the old active domain
ConfMan.setActiveDomain(oldDomain);
+
+ return result;
}
/** Lists all usable themes */
@@ -859,7 +867,7 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
#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
@@ -868,34 +876,33 @@ bool processSettings(Common::String &command, Common::StringMap &settings) {
// 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
@@ -967,7 +974,7 @@ bool processSettings(Common::String &command, Common::StringMap &settings) {
ConfMan.set(key, value, Common::ConfigManager::kTransientDomain);
}
- return true;
+ return Common::kArgumentNotProcessed;
}
} // End of namespace Base
diff --git a/base/commandLine.h b/base/commandLine.h
index 8801ed17d8..c7e8d8b0d0 100644
--- a/base/commandLine.h
+++ b/base/commandLine.h
@@ -33,7 +33,7 @@ namespace Base {
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
diff --git a/base/main.cpp b/base/main.cpp
index 08d59aafab..8564d64c26 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -109,9 +109,9 @@ static const EnginePlugin *detectPlugin() {
#if defined(NEW_PLUGIN_DESIGN_FIRST_REFINEMENT) && defined(DYNAMIC_MODULES)
GameDescriptor game = EngineMan.findGameOnePlugAtATime(gameid, &plugin);
#else
- GameDescriptor game = EngineMan.findGame(gameid, &plugin);
+ GameDescriptor game = EngineMan.findGame(gameid, &plugin);
#endif
-
+
if (plugin == 0) {
printf("failed\n");
warning("%s is an invalid gameid. Use the --list-games option to list supported gameid", gameid.c_str());
@@ -347,8 +347,8 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
#if defined(NEW_PLUGIN_DESIGN_FIRST_REFINEMENT) && defined(DYNAMIC_MODULES) //note: I'm going to refactor this name later :P
// Don't load the plugins initially in this case.
#else
- // Load the plugins.
- PluginManager::instance().loadPlugins();
+ // Load the plugins.
+ PluginManager::instance().loadPlugins();
#endif
// If we received an invalid music parameter via command line we check this here.
@@ -363,8 +363,10 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
// 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.
@@ -390,7 +392,7 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
// Unless a game was specified, show the launcher dialog
if (0 == ConfMan.getActiveDomain())
launcherDialog();
-
+
// FIXME: We're now looping the launcher. This, of course, doesn't
// work as well as it should. In theory everything should be destroyed
// cleanly, so this is now enabled to encourage people to fix bits :)