fix invalid target crash for build using loadable modules

svn-id: r10325
This commit is contained in:
Max Horn 2003-09-20 00:37:09 +00:00
parent 7840039156
commit 3afbb22ad7
4 changed files with 20 additions and 12 deletions

View File

@ -664,15 +664,15 @@ const ScummVM::String& GameDetector::getGameName() {
return _gameText; return _gameText;
} }
int GameDetector::detectMain() { bool GameDetector::detectMain() {
if (_gameFileName.isEmpty()) { if (_gameFileName.isEmpty()) {
warning("No game was specified..."); warning("No game was specified...");
return (-1); return false;
} }
if (!detectGame()) { if (!detectGame()) {
warning("Game detection failed. Using default settings"); warning("%s is an invalid target. Use the -z parameter to list targets", _gameFileName.c_str());
_gameText = "Please choose a game"; return false;
} }
/* Use the adlib sound driver if auto mode is selected, /* Use the adlib sound driver if auto mode is selected,
@ -713,7 +713,7 @@ int GameDetector::detectMain() {
#endif #endif
} }
return (0); return true;
} }
OSystem *GameDetector::createSystem() { OSystem *GameDetector::createSystem() {

View File

@ -113,7 +113,7 @@ public:
GameDetector(); GameDetector();
void parseCommandLine(int argc, char **argv); void parseCommandLine(int argc, char **argv);
int detectMain(); bool detectMain();
void setGame(const String &name); void setGame(const String &name);
const String& getGameName(void); const String& getGameName(void);

View File

@ -249,7 +249,7 @@ int main(int argc, char *argv[]) {
launcherDialog(detector, system); launcherDialog(detector, system);
// Verify the given game name // Verify the given game name
if (!detector.detectMain()) { if (detector.detectMain()) {
// Set the window caption to the game name // Set the window caption to the game name
prop.caption = g_config->get("description", detector._gameFileName); prop.caption = g_config->get("description", detector._gameFileName);
if (prop.caption == NULL) if (prop.caption == NULL)
@ -265,11 +265,7 @@ int main(int argc, char *argv[]) {
// Create the game engine // Create the game engine
Engine *engine = detector.createEngine(system); Engine *engine = detector.createEngine(system);
assert(engine);
// print a message if gameid is invalid
if (engine == NULL)
error("%s is an invalid target. Use the -z parameter to list targets",
detector._gameFileName.c_str());
// Run the game engine // Run the game engine
engine->go(); engine->go();

View File

@ -243,6 +243,18 @@ void PluginManager::loadPlugins() {
#else #else
// Load dynamic plugins // Load dynamic plugins
// TODO... this is right now just a nasty hack. // TODO... this is right now just a nasty hack.
// This should search one or multiple directories for all plugins it can
// find (to this end, we maybe should use a special prefix/suffix; e.g.
// instead of libscumm.so, use scumm.engine or scumm.plugin etc.).
//
// The list of directories to search could be e.g.:
// User specified (via config file), ".", "./plugins", "$(prefix)/lib".
//
// We also need to add code which ensures what we are looking at is
// a) a ScummVM engine and b) matches the version of the executable.
// Hence one more symbol should be exported by plugins which returns
// the "ABI" version the plugin was built for, and we can compare that
// to the ABI version of the executable.
#ifndef DISABLE_SCUMM #ifndef DISABLE_SCUMM
tryLoadPlugin(new DynamicPlugin("scumm/libscumm.so")); tryLoadPlugin(new DynamicPlugin("scumm/libscumm.so"));
#endif #endif