ENGINES: Change MetaEngine::findGame to return a plain game descriptor

This commit is contained in:
Bastien Bouclet 2018-05-06 12:57:08 +02:00
parent cf1ebf2951
commit 8fb149e3c7
22 changed files with 77 additions and 70 deletions

View file

@ -714,10 +714,10 @@ static void listTargets() {
// FIXME: At this point, we should check for a "gameid" override
// to find the proper desc. In fact, the platform probably should
// be taken into account, too.
Common::String gameid(name);
GameDescriptor g = EngineMan.findGame(gameid);
if (g.description().size() > 0)
description = g.description();
const Common::String &gameid = name;
PlainGameDescriptor g = EngineMan.findGame(gameid);
if (g.description)
description = g.description;
}
targets.push_back(Common::String::format("%-20s %s", name.c_str(), description.c_str()));
@ -770,7 +770,7 @@ static Common::Error listSaves(const Common::String &target) {
// Find the plugin that will handle the specified gameid
const Plugin *plugin = nullptr;
GameDescriptor game = EngineMan.findGame(gameid, &plugin);
EngineMan.findGame(gameid, &plugin);
if (!plugin) {
// If the target was specified, treat this as an error, and otherwise skip it.
@ -1276,8 +1276,8 @@ bool processSettings(Common::String &command, Common::StringMap &settings, Commo
// domain (i.e. a target) matching this argument, or alternatively
// whether there is a gameid matching that name.
if (!command.empty()) {
GameDescriptor gd = EngineMan.findGame(command);
if (ConfMan.hasGameDomain(command) || !gd.gameid().empty()) {
PlainGameDescriptor gd = EngineMan.findGame(command);
if (ConfMan.hasGameDomain(command) || gd.gameId) {
bool idCameFromCommandLine = false;
// WORKAROUND: Fix for bug #1719463: "DETECTOR: Launching

View file

@ -128,13 +128,13 @@ static const Plugin *detectPlugin() {
printf("User picked target '%s' (gameid '%s')...\n", ConfMan.getActiveDomainName().c_str(), gameid.c_str());
printf(" Looking for a plugin supporting this gameid... ");
GameDescriptor game = EngineMan.findGame(gameid, &plugin);
PlainGameDescriptor game = EngineMan.findGame(gameid, &plugin);
if (plugin == 0) {
printf("failed\n");
warning("%s is an invalid gameid. Use the --list-games option to list supported gameid", gameid.c_str());
} else {
printf("%s\n Starting '%s'\n", plugin->getName(), game.description().c_str());
printf("%s\n Starting '%s'\n", plugin->getName(), game.description);
}
return plugin;
@ -210,7 +210,10 @@ static Common::Error runGame(const Plugin *plugin, OSystem &system, const Common
Common::String caption(ConfMan.get("description"));
if (caption.empty()) {
caption = EngineMan.findGame(ConfMan.get("gameid")).description();
PlainGameDescriptor game = EngineMan.findGame(ConfMan.get("gameid"));
if (game.description) {
caption = game.description;
}
}
if (caption.empty())
caption = ConfMan.getActiveDomainName(); // Use the domain (=target) name

View file

@ -458,13 +458,13 @@ DECLARE_SINGLETON(EngineManager);
* For the uncached version, we first try to find the plugin using the gameId
* and only if we can't find it there, we loop through the plugins.
**/
GameDescriptor EngineManager::findGame(const Common::String &gameName, const Plugin **plugin) const {
GameDescriptor result;
PlainGameDescriptor EngineManager::findGame(const Common::String &gameName, const Plugin **plugin) const {
PlainGameDescriptor result;
// First look for the game using the plugins in memory. This is critical
// for calls coming from inside games
result = findGameInLoadedPlugins(gameName, plugin);
if (!result.gameid().empty()) {
if (result.gameId) {
return result;
}
@ -472,7 +472,7 @@ GameDescriptor EngineManager::findGame(const Common::String &gameName, const Plu
// by plugin
if (PluginMan.loadPluginFromGameId(gameName)) {
result = findGameInLoadedPlugins(gameName, plugin);
if (!result.gameid().empty()) {
if (result.gameId) {
return result;
}
}
@ -481,7 +481,7 @@ GameDescriptor EngineManager::findGame(const Common::String &gameName, const Plu
PluginMan.loadFirstPlugin();
do {
result = findGameInLoadedPlugins(gameName, plugin);
if (!result.gameid().empty()) {
if (result.gameId) {
// Update with new plugin file name
PluginMan.updateConfigWithFileName(gameName);
break;
@ -494,10 +494,10 @@ GameDescriptor EngineManager::findGame(const Common::String &gameName, const Plu
/**
* Find the game within the plugins loaded in memory
**/
GameDescriptor EngineManager::findGameInLoadedPlugins(const Common::String &gameName, const Plugin **plugin) const {
PlainGameDescriptor EngineManager::findGameInLoadedPlugins(const Common::String &gameName, const Plugin **plugin) const {
// Find the GameDescriptor for this target
const PluginList &plugins = getPlugins();
GameDescriptor result;
PlainGameDescriptor result;
if (plugin)
*plugin = 0;
@ -506,7 +506,7 @@ GameDescriptor EngineManager::findGameInLoadedPlugins(const Common::String &game
for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
result = (*iter)->get<MetaEngine>().findGame(gameName.c_str());
if (!result.gameid().empty()) {
if (result.gameId) {
if (plugin)
*plugin = *iter;
return result;