aboutsummaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/engine.cpp2
-rw-r--r--base/gameDetector.cpp28
-rw-r--r--base/gameDetector.h12
-rw-r--r--base/main.cpp11
4 files changed, 19 insertions, 34 deletions
diff --git a/base/engine.cpp b/base/engine.cpp
index a3767d1bf4..f64b1ec68c 100644
--- a/base/engine.cpp
+++ b/base/engine.cpp
@@ -39,7 +39,7 @@ Engine *g_engine = 0;
Engine::Engine(OSystem *syst)
: _system(syst), _gameDataPath(ConfMan.get("path")) {
g_engine = this;
- _mixer = GameDetector::createMixer();
+ _mixer = new Audio::Mixer();
_timer = Common::g_timer;
diff --git a/base/gameDetector.cpp b/base/gameDetector.cpp
index eec3d69276..ad529ce4be 100644
--- a/base/gameDetector.cpp
+++ b/base/gameDetector.cpp
@@ -248,8 +248,6 @@ GameDetector::GameDetector() {
ConfMan.registerDefault("savepath", savePath); // this should be enough...
#endif
#endif // #ifdef DEFAULT_SAVE_PATH
-
- _plugin = 0;
}
GameDescriptor GameDetector::findGame(const String &gameName, const Plugin **plugin) {
@@ -257,6 +255,9 @@ GameDescriptor GameDetector::findGame(const String &gameName, const Plugin **plu
const PluginList &plugins = PluginManager::instance().getPlugins();
GameDescriptor result;
+ if (plugin)
+ plugin = 0;
+
PluginList::const_iterator iter = plugins.begin();
for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
result = (*iter)->findGame(gameName.c_str());
@@ -590,19 +591,21 @@ void GameDetector::setTarget(const String &target) {
//ConfMan.set("gameid", _gameid, Common::ConfigManager::kTransientDomain);
}
-bool GameDetector::detectMain() {
+const Plugin *GameDetector::detectMain() {
+ const Plugin *plugin = 0;
+
if (_targetName.empty()) {
warning("No game was specified...");
- return false;
+ return 0;
}
printf("Looking for %s\n", _gameid.c_str());
- GameDescriptor game = findGame(_gameid, &_plugin);
+ GameDescriptor game = findGame(_gameid, &plugin);
- if (game.gameid.size() == 0) {
+ if (plugin == 0) {
printf("Failed game detection\n");
warning("%s is an invalid target. Use the --list-targets option to list targets", _targetName.c_str());
- return false;
+ return 0;
}
printf("Trying to start game '%s'\n", game.description.c_str());
@@ -620,14 +623,5 @@ bool GameDetector::detectMain() {
ConfMan.set("path", gameDataPath, Common::ConfigManager::kTransientDomain);
}
- return true;
-}
-
-Engine *GameDetector::createEngine(OSystem *sys) {
- assert(_plugin);
- return _plugin->createInstance(this, sys);
-}
-
-Audio::Mixer *GameDetector::createMixer() {
- return new Audio::Mixer();
+ return plugin;
}
diff --git a/base/gameDetector.h b/base/gameDetector.h
index 876035cead..14ff9e071a 100644
--- a/base/gameDetector.h
+++ b/base/gameDetector.h
@@ -27,13 +27,9 @@
#include "common/str.h"
#include "common/config-manager.h"
-class Engine;
class GameDetector;
class OSystem;
class Plugin;
-namespace Audio {
- class Mixer;
-}
struct PlainGameDescriptor {
const char *gameid;
@@ -71,18 +67,12 @@ public:
static Common::String parseCommandLine(Common::StringMap &settings, int argc, char **argv);
void processSettings(Common::String &target, Common::StringMap &settings);
- bool detectMain();
+ const Plugin *detectMain();
String _targetName;
String _gameid;
- const Plugin *_plugin; // TODO: This should be protected
-
public:
- Engine *createEngine(OSystem *system);
-
- static Audio::Mixer *createMixer();
-
static GameDescriptor findGame(const String &gameName, const Plugin **plugin = NULL);
//protected:
diff --git a/base/main.cpp b/base/main.cpp
index 10df58327a..be4502875b 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -157,7 +157,7 @@ static bool launcherDialog(GameDetector &detector, OSystem &system) {
return (dlg.runModal() != -1);
}
-static int runGame(GameDetector &detector, OSystem &system, const Common::String &edebuglevels) {
+static int runGame(const Plugin *plugin, GameDetector &detector, OSystem &system, const Common::String &edebuglevels) {
// We add it here, so MD5-based detection will be able to
// read mixed case files
if (ConfMan.hasKey("path"))
@@ -166,7 +166,7 @@ static int runGame(GameDetector &detector, OSystem &system, const Common::String
Common::File::addDefaultDirectory(".");
// Create the game engine
- Engine *engine = detector.createEngine(&system);
+ Engine *engine = plugin->createInstance(&detector, &system);
if (!engine) {
// TODO: Show an error dialog or so?
//GUI::MessageDialog alert("ScummVM could not find any game in the specified directory!");
@@ -329,12 +329,13 @@ extern "C" int scummvm_main(int argc, char *argv[]) {
// cleanly, so this is now enabled to encourage people to fix bits :)
while (running) {
// Verify the given game name is a valid supported game
- if (detector.detectMain()) {
+ const Plugin *plugin = detector.detectMain();
+ if (plugin) {
// Unload all plugins not needed for this game,
// to save memory
- PluginManager::instance().unloadPluginsExcept(detector._plugin);
+ PluginManager::instance().unloadPluginsExcept(plugin);
- int result = runGame(detector, system, specialDebug);
+ int result = runGame(plugin, detector, system, specialDebug);
if (result == 0)
break;