COMMON: Cleanup names/handling of some error codes
This commit is contained in:
parent
1037ed2470
commit
3a574199b0
4 changed files with 31 additions and 26 deletions
|
@ -641,29 +641,30 @@ static Common::Error listSaves(const char *target) {
|
||||||
GameDescriptor game = EngineMan.findGame(gameid, &plugin);
|
GameDescriptor game = EngineMan.findGame(gameid, &plugin);
|
||||||
|
|
||||||
if (!plugin) {
|
if (!plugin) {
|
||||||
warning("Could not find any plugin to handle target '%s' (gameid '%s')", target, gameid.c_str());
|
return Common::Error(Common::kEnginePluginNotFound,
|
||||||
return Common::kPluginNotFound;
|
Common::String::format("target '%s', gameid '%s", target, gameid.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(*plugin)->hasFeature(MetaEngine::kSupportsListSaves)) {
|
if (!(*plugin)->hasFeature(MetaEngine::kSupportsListSaves)) {
|
||||||
// TODO: Include more info about the target (desc, engine name, ...) ???
|
// 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());
|
return Common::Error(Common::kEnginePluginNotSupportSaves,
|
||||||
result = Common::kPluginNotSupportSaves;
|
Common::String::format("target '%s', gameid '%s", target, gameid.c_str()));
|
||||||
} else {
|
} else {
|
||||||
// Query the plugin for a list of savegames
|
// Query the plugin for a list of savegames
|
||||||
SaveStateList saveList = (*plugin)->listSaves(target);
|
SaveStateList saveList = (*plugin)->listSaves(target);
|
||||||
|
|
||||||
// TODO: Include more info about the target (desc, engine name, ...) ???
|
if (saveList.size() > 0) {
|
||||||
printf("Saves for target '%s' (gameid '%s'):\n", target, gameid.c_str());
|
// TODO: Include more info about the target (desc, engine name, ...) ???
|
||||||
printf(" Slot Description \n"
|
printf("Save states for target '%s' (gameid '%s'):\n", target, gameid.c_str());
|
||||||
" ---- ------------------------------------------------------\n");
|
printf(" Slot Description \n"
|
||||||
|
" ---- ------------------------------------------------------\n");
|
||||||
|
|
||||||
if (saveList.size() == 0)
|
for (SaveStateList::const_iterator x = saveList.begin(); x != saveList.end(); ++x) {
|
||||||
result = Common::kNoSavesError;
|
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
|
||||||
for (SaveStateList::const_iterator x = saveList.begin(); x != saveList.end(); ++x) {
|
}
|
||||||
printf(" %-4s %s\n", x->save_slot().c_str(), x->description().c_str());
|
} else {
|
||||||
// TODO: Could also iterate over the full hashmap, printing all key-value pairs
|
printf("There are no save states for target '%s' (gameid '%s'):\n", target, gameid.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,13 +111,12 @@ static const EnginePlugin *detectPlugin() {
|
||||||
if (plugin == 0) {
|
if (plugin == 0) {
|
||||||
printf("failed\n");
|
printf("failed\n");
|
||||||
warning("%s is an invalid gameid. Use the --list-games option to list supported gameid", gameid.c_str());
|
warning("%s is an invalid gameid. Use the --list-games option to list supported gameid", gameid.c_str());
|
||||||
return 0;
|
|
||||||
} else {
|
} else {
|
||||||
printf("%s\n", plugin->getName());
|
printf("%s\n", plugin->getName());
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Do we really need this one?
|
// FIXME: Do we really need this one?
|
||||||
printf(" Starting '%s'\n", game.description().c_str());
|
printf(" Starting '%s'\n", game.description().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
@ -352,8 +351,10 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
|
||||||
|
|
||||||
// TODO: deal with settings that require plugins to be loaded
|
// TODO: deal with settings that require plugins to be loaded
|
||||||
res = Base::processSettings(command, settings);
|
res = Base::processSettings(command, settings);
|
||||||
if (res.getCode() != Common::kArgumentNotProcessed)
|
if (res.getCode() != Common::kArgumentNotProcessed) {
|
||||||
|
warning("%s", res.getDesc().c_str());
|
||||||
return res.getCode();
|
return res.getCode();
|
||||||
|
}
|
||||||
|
|
||||||
// Init the backend. Must take place after all config data (including
|
// Init the backend. Must take place after all config data (including
|
||||||
// the command line params) was read.
|
// the command line params) was read.
|
||||||
|
|
|
@ -66,11 +66,15 @@ static String errorToString(ErrorCode errorCode) {
|
||||||
case kWritingFailed:
|
case kWritingFailed:
|
||||||
return _s("Writing data failed");
|
return _s("Writing data failed");
|
||||||
|
|
||||||
case kUnknownError:
|
case kEnginePluginNotFound:
|
||||||
case kPluginNotFound:
|
return _s("Could not find suitable engine plugin");
|
||||||
case kPluginNotSupportSaves:
|
case kEnginePluginNotSupportSaves:
|
||||||
case kNoSavesError:
|
return _s("Engine plugin does not support save states");
|
||||||
|
|
||||||
case kArgumentNotProcessed:
|
case kArgumentNotProcessed:
|
||||||
|
return _s("Command line argument not processed");
|
||||||
|
|
||||||
|
case kUnknownError:
|
||||||
default:
|
default:
|
||||||
return _s("Unknown error");
|
return _s("Unknown error");
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,9 +63,8 @@ enum ErrorCode {
|
||||||
kWritingFailed, ///< Failure to write data -- disk full?
|
kWritingFailed, ///< Failure to write data -- disk full?
|
||||||
|
|
||||||
// The following are used by --list-saves
|
// The following are used by --list-saves
|
||||||
kPluginNotFound, ///< Failed to find plugin to handle target
|
kEnginePluginNotFound, ///< Failed to find plugin to handle target
|
||||||
kPluginNotSupportSaves, ///< Failed if plugin does not support saves
|
kEnginePluginNotSupportSaves, ///< Failed if plugin does not support listing save states
|
||||||
kNoSavesError, ///< There are no saves to show
|
|
||||||
|
|
||||||
kArgumentNotProcessed, ///< Used in command line parsing
|
kArgumentNotProcessed, ///< Used in command line parsing
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue