Removed GameDetector::createMixer(), GameDetector::createEngine(), GameDetector::_plugin

svn-id: r21913
This commit is contained in:
Max Horn 2006-04-15 16:37:48 +00:00
parent e3737b9f47
commit fa085439b9
4 changed files with 19 additions and 34 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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:

View File

@ -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;