aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/gameDetector.cpp49
-rw-r--r--common/gameDetector.h1
-rw-r--r--gui/launcher.cpp94
3 files changed, 50 insertions, 94 deletions
diff --git a/common/gameDetector.cpp b/common/gameDetector.cpp
index ee8b98bf7d..3e49768486 100644
--- a/common/gameDetector.cpp
+++ b/common/gameDetector.cpp
@@ -159,13 +159,6 @@ static const struct MusicDriver music_drivers[] = {
};
-// This contains a pointer to a list of all supported games.
-// FIXME: Get rid of version_settings. The only reaons we still have it is
-// that launcher.cpp uses it. So let's convert launcher.cpp to use the new
-// Plugin API instead!
-const TargetSettings *version_settings = NULL;
-
-
GameDetector::GameDetector() {
_fullScreen = false;
_aspectRatio = false;
@@ -213,36 +206,6 @@ GameDetector::GameDetector() {
_gfx_mode = GFX_NORMAL;
#endif
_default_gfx_mode = true;
-
- if (version_settings == NULL) {
- assert(g_pluginManager);
- const PluginList &_plugins = g_pluginManager->getPlugins();
- int i;
- int count = 0;
-
- // Gather & combine the target lists from the modules
- for (i = 0; i < _plugins.size(); i++) {
- count += _plugins[i]->countTargets();
- }
-
- TargetSettings *v = (TargetSettings *)calloc(count + 1, sizeof(TargetSettings));
- version_settings = v;
-
- for (i = 0; i < _plugins.size(); i++) {
- count = _plugins[i]->countTargets();
- memcpy(v, _plugins[i]->getTargets(), count * sizeof(TargetSettings));
- v += count;
- }
- }
-}
-
-GameDetector::~GameDetector() {
-#ifdef __PALM_OS__
- // This is a previously allocated chunck (line 224)
- // so we need to free it to prevent memory leak
- TargetSettings *v = (TargetSettings *)version_settings;
- free(v);
-#endif
}
void GameDetector::updateconfig() {
@@ -316,15 +279,15 @@ void GameDetector::updateconfig() {
}
void GameDetector::list_games() {
- const PluginList &_plugins = g_pluginManager->getPlugins();
+ const PluginList &plugins = g_pluginManager->getPlugins();
const TargetSettings *v;
const char *config;
printf("Game Full Title Config\n"
"---------------- ------------------------------------------------------ -------\n");
- for (int i = 0; i < _plugins.size(); i++) {
- v = _plugins[i]->getTargets();
+ for (int i = 0; i < plugins.size(); i++) {
+ v = plugins[i]->getTargets();
while (v->targetName && v->description) {
config = (g_config->has_domain(v->targetName)) ? "Yes" : "";
printf("%-17s%-56s%s\n", v->targetName, v->description, config);
@@ -337,10 +300,10 @@ const TargetSettings *GameDetector::findTarget(const char *targetName) const {
// Find the TargetSettings for this target
assert(targetName);
const TargetSettings *target;
- const PluginList &_plugins = g_pluginManager->getPlugins();
+ const PluginList &plugins = g_pluginManager->getPlugins();
- for (int i = 0; i < _plugins.size(); i++) {
- target = _plugins[i]->findTarget(targetName);
+ for (int i = 0; i < plugins.size(); i++) {
+ target = plugins[i]->findTarget(targetName);
if (target)
return target;
}
diff --git a/common/gameDetector.h b/common/gameDetector.h
index ae06966c74..1443a9ceb4 100644
--- a/common/gameDetector.h
+++ b/common/gameDetector.h
@@ -134,7 +134,6 @@ public:
public:
GameDetector();
- ~GameDetector();
void parseCommandLine(int argc, char **argv);
int detectMain();
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 982d81c747..65a8341c47 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -32,6 +32,7 @@
#include "common/config-file.h"
#include "common/engine.h"
#include "common/gameDetector.h"
+#include "common/plugins.h"
enum {
kStartCmd = 'STRT',
@@ -214,14 +215,8 @@ void LauncherDialog::close() {
Dialog::close();
}
-// FIXME: EVIL HACK! remove use of version_settings by introducing
-// proper APIs for accessing/searching them
-extern const TargetSettings *version_settings;
-
-
void LauncherDialog::updateListing() {
int i;
- const TargetSettings *v = version_settings;
ScummVM::StringList l;
// Retrieve a list of all games defined in the config file
@@ -234,14 +229,9 @@ void LauncherDialog::updateListing() {
if (name.isEmpty())
name = domains[i];
if (description.isEmpty()) {
- v = version_settings;
- while (v->targetName) {
- if (!scumm_stricmp(v->targetName, name.c_str())) {
- description = v->description;
- break;
- }
- v++;
- }
+ const TargetSettings *v = _detector.findTarget(name.c_str());
+ if (v && v->description)
+ description = v->description;
}
if (!name.isEmpty() && !description.isEmpty()) {
@@ -270,47 +260,51 @@ GameList findGame(FilesystemNode *dir) {
char detectName[128];
char detectName2[128];
char detectName3[128];
- int i;
// Iterate over all known games and for each check if it might be
// the game in the presented directory.
- const TargetSettings *v = version_settings;
- while (v->targetName && v->description) {
-
- // Determine the 'detectname' for this game, that is, the name of a
- // file that *must* be presented if the directory contains the data
- // for this game. For example, FOA requires atlantis.000
- if (v->detectname) {
- strcpy(detectName, v->detectname);
- strcpy(detectName2, v->detectname);
- strcat(detectName2, ".");
- detectName3[0] = '\0';
- } else {
- strcpy(detectName, v->targetName);
- strcpy(detectName2, v->targetName);
- strcpy(detectName3, v->targetName);
- strcat(detectName, ".000");
- if (v->version >= 7) {
- strcat(detectName2, ".la0");
- } else
- strcat(detectName2, ".sm0");
- strcat(detectName3, ".he0");
- }
-
- // Iterate over all files in the given directory
- for (i = 0; i < size; i++) {
- const char *targetName = (*files)[i].displayName().c_str();
-
- if ((0 == scumm_stricmp(detectName, targetName)) ||
- (0 == scumm_stricmp(detectName2, targetName)) ||
- (0 == scumm_stricmp(detectName3, targetName))) {
- // Match found, add to list of candidates, then abort inner loop.
- list.push_back(v);
- break;
+ assert(g_pluginManager);
+ const PluginList &plugins = g_pluginManager->getPlugins();
+ int p;
+ for (p = 0; p < plugins.size(); p++) {
+ const TargetSettings *v = plugins[p]->getTargets();
+ while (v->targetName && v->description) {
+
+ // Determine the 'detectname' for this game, that is, the name of a
+ // file that *must* be presented if the directory contains the data
+ // for this game. For example, FOA requires atlantis.000
+ if (v->detectname) {
+ strcpy(detectName, v->detectname);
+ strcpy(detectName2, v->detectname);
+ strcat(detectName2, ".");
+ detectName3[0] = '\0';
+ } else {
+ strcpy(detectName, v->targetName);
+ strcpy(detectName2, v->targetName);
+ strcpy(detectName3, v->targetName);
+ strcat(detectName, ".000");
+ if (v->version >= 7) {
+ strcat(detectName2, ".la0");
+ } else
+ strcat(detectName2, ".sm0");
+ strcat(detectName3, ".he0");
}
+
+ // Iterate over all files in the given directory
+ for (int i = 0; i < size; i++) {
+ const char *targetName = (*files)[i].displayName().c_str();
+
+ if ((0 == scumm_stricmp(detectName, targetName)) ||
+ (0 == scumm_stricmp(detectName2, targetName)) ||
+ (0 == scumm_stricmp(detectName3, targetName))) {
+ // Match found, add to list of candidates, then abort inner loop.
+ list.push_back(v);
+ break;
+ }
+ }
+
+ v++;
}
-
- v++;
}
return list;