aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--base/plugins.cpp14
-rw-r--r--engines/advancedDetector.cpp2
-rw-r--r--engines/game.cpp14
-rw-r--r--engines/game.h4
-rw-r--r--engines/obsolete.cpp6
-rw-r--r--engines/sky/detection.cpp2
-rw-r--r--engines/sword1/detection.cpp2
-rw-r--r--engines/sword2/sword2.cpp4
8 files changed, 30 insertions, 18 deletions
diff --git a/base/plugins.cpp b/base/plugins.cpp
index 40a4d77053..023f2f3bb3 100644
--- a/base/plugins.cpp
+++ b/base/plugins.cpp
@@ -459,11 +459,9 @@ DECLARE_SINGLETON(EngineManager);
* and only if we can't find it there, we loop through the plugins.
**/
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);
+ PlainGameDescriptor result = findGameInLoadedPlugins(gameName, plugin);
if (result.gameId) {
return result;
}
@@ -497,7 +495,6 @@ PlainGameDescriptor EngineManager::findGame(const Common::String &gameName, cons
PlainGameDescriptor EngineManager::findGameInLoadedPlugins(const Common::String &gameName, const Plugin **plugin) const {
// Find the GameDescriptor for this target
const PluginList &plugins = getPlugins();
- PlainGameDescriptor result;
if (plugin)
*plugin = 0;
@@ -505,14 +502,15 @@ PlainGameDescriptor EngineManager::findGameInLoadedPlugins(const Common::String
PluginList::const_iterator iter;
for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
- result = (*iter)->get<MetaEngine>().findGame(gameName.c_str());
- if (result.gameId) {
+ PlainGameDescriptor pgd = (*iter)->get<MetaEngine>().findGame(gameName.c_str());
+ if (pgd.gameId) {
if (plugin)
*plugin = *iter;
- return result;
+ return pgd;
}
}
- return result;
+
+ return PlainGameDescriptor::empty();
}
DetectionResults EngineManager::detectGames(const Common::FSList &fslist) const {
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index c7b5c18892..3167dd9581 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -589,7 +589,7 @@ PlainGameDescriptor AdvancedMetaEngine::findGame(const char *gameId) const {
return *g;
// No match found
- return PlainGameDescriptor();
+ return PlainGameDescriptor::empty();
}
AdvancedMetaEngine::AdvancedMetaEngine(const void *descs, uint descItemSize, const PlainGameDescriptor *gameIds, const ADExtraGuiOptionsMap *extraGuiOptions)
diff --git a/engines/game.cpp b/engines/game.cpp
index 3823000bce..ee14acf7c8 100644
--- a/engines/game.cpp
+++ b/engines/game.cpp
@@ -35,6 +35,20 @@ const PlainGameDescriptor *findPlainGameDescriptor(const char *gameid, const Pla
return 0;
}
+PlainGameDescriptor PlainGameDescriptor::empty() {
+ PlainGameDescriptor pgd;
+ pgd.gameId = nullptr;
+ pgd.description = nullptr;
+ return pgd;
+}
+
+PlainGameDescriptor PlainGameDescriptor::of(const char *gameId, const char *description) {
+ PlainGameDescriptor pgd;
+ pgd.gameId = gameId;
+ pgd.description = description;
+ return pgd;
+}
+
DetectedGame::DetectedGame() :
engineName(nullptr),
hasUnknownFiles(false),
diff --git a/engines/game.h b/engines/game.h
index 660a94ad6c..14f9962ce6 100644
--- a/engines/game.h
+++ b/engines/game.h
@@ -39,8 +39,8 @@ struct PlainGameDescriptor {
const char *gameId;
const char *description;
- PlainGameDescriptor() : gameId(nullptr), description(nullptr) {}
- PlainGameDescriptor(const char *id, const char *desc) : gameId(id), description(desc) {}
+ static PlainGameDescriptor empty();
+ static PlainGameDescriptor of(const char *gameId, const char *description);
};
/**
diff --git a/engines/obsolete.cpp b/engines/obsolete.cpp
index 48809df712..ea96cff42e 100644
--- a/engines/obsolete.cpp
+++ b/engines/obsolete.cpp
@@ -73,16 +73,16 @@ PlainGameDescriptor findGameID(
if (0 == scumm_stricmp(gameid, o->from)) {
g = findPlainGameDescriptor(o->to, gameids);
if (g && g->description)
- return PlainGameDescriptor(gameid, g->description);
+ return PlainGameDescriptor::of(gameid, g->description);
else
- return PlainGameDescriptor(gameid, "Obsolete game ID");
+ return PlainGameDescriptor::of(gameid, "Obsolete game ID");
}
o++;
}
}
// No match found
- return PlainGameDescriptor();
+ return PlainGameDescriptor::empty();
}
} // End of namespace Engines
diff --git a/engines/sky/detection.cpp b/engines/sky/detection.cpp
index 6beaf02fdc..642e4d31a7 100644
--- a/engines/sky/detection.cpp
+++ b/engines/sky/detection.cpp
@@ -138,7 +138,7 @@ const ExtraGuiOptions SkyMetaEngine::getExtraGuiOptions(const Common::String &ta
PlainGameDescriptor SkyMetaEngine::findGame(const char *gameid) const {
if (0 == scumm_stricmp(gameid, skySetting.gameId))
return skySetting;
- return PlainGameDescriptor();
+ return PlainGameDescriptor::empty();
}
DetectedGames SkyMetaEngine::detectGames(const Common::FSList &fslist) const {
diff --git a/engines/sword1/detection.cpp b/engines/sword1/detection.cpp
index 6504806423..52394cec41 100644
--- a/engines/sword1/detection.cpp
+++ b/engines/sword1/detection.cpp
@@ -140,7 +140,7 @@ PlainGameDescriptor SwordMetaEngine::findGame(const char *gameId) const {
return sword1PSXSettings;
if (0 == scumm_stricmp(gameId, sword1PSXDemoSettings.gameId))
return sword1PSXDemoSettings;
- return PlainGameDescriptor();
+ return PlainGameDescriptor::empty();
}
void Sword1CheckDirectory(const Common::FSList &fslist, bool *filesFound, bool recursion = false) {
diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp
index 0ec0e3f726..4d8399e630 100644
--- a/engines/sword2/sword2.cpp
+++ b/engines/sword2/sword2.cpp
@@ -123,7 +123,7 @@ PlainGameList Sword2MetaEngine::getSupportedGames() const {
const Sword2::GameSettings *g = Sword2::sword2_settings;
PlainGameList games;
while (g->gameid) {
- games.push_back(PlainGameDescriptor(g->gameid, g->description));
+ games.push_back(PlainGameDescriptor::of(g->gameid, g->description));
g++;
}
return games;
@@ -142,7 +142,7 @@ PlainGameDescriptor Sword2MetaEngine::findGame(const char *gameid) const {
break;
g++;
}
- return PlainGameDescriptor(g->gameid, g->description);
+ return PlainGameDescriptor::of(g->gameid, g->description);
}
bool isFullGame(const Common::FSList &fslist) {