~ubuntu-branches/debian/jessie/scummvm/jessie

« back to all changes in this revision

Viewing changes to base/main.cpp

  • Committer: Package Import Robot
  • Author(s): Moritz Muehlenhoff
  • Date: 2011-11-05 10:29:43 UTC
  • mto: This revision was merged to the branch mainline in revision 25.
  • Revision ID: package-import@ubuntu.com-20111105102943-zfm3dhlvy5b01u7v
Tags: upstream-1.4.0
ImportĀ upstreamĀ versionĀ 1.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * along with this program; if not, write to the Free Software
19
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
20
 *
21
 
 * $URL$
22
 
 * $Id$
23
 
 *
24
21
 */
25
22
 
26
23
/*! \mainpage %ScummVM Source Reference
31
28
 * of almost all the classes, methods and variables, and how they interact.
32
29
 */
33
30
 
 
31
// FIXME: Avoid using printf
 
32
#define FORBIDDEN_SYMBOL_EXCEPTION_printf
 
33
 
34
34
#include "engines/engine.h"
35
35
#include "engines/metaengine.h"
36
36
#include "base/commandLine.h"
103
103
 
104
104
        // Query the plugins and find one that will handle the specified gameid
105
105
        printf("User picked target '%s' (gameid '%s')...\n", ConfMan.getActiveDomainName().c_str(), gameid.c_str());
106
 
        printf("%s", "  Looking for a plugin supporting this gameid... ");
 
106
        printf("  Looking for a plugin supporting this gameid... ");
107
107
 
108
108
        GameDescriptor game = EngineMan.findGame(gameid, &plugin);
109
109
 
111
111
                printf("failed\n");
112
112
                warning("%s is an invalid gameid. Use the --list-games option to list supported gameid", gameid.c_str());
113
113
        } else {
114
 
                printf("%s\n", plugin->getName());
115
 
 
116
 
                // FIXME: Do we really need this one?
117
 
                printf("  Starting '%s'\n", game.description().c_str());
 
114
                printf("%s\n  Starting '%s'\n", plugin->getName(), game.description().c_str());
118
115
        }
119
116
 
120
117
        return plugin;
186
183
        }
187
184
 
188
185
        // If a second extrapath is specified on the app domain level, add that as well.
 
186
        // However, since the default hasKey() and get() check the app domain level,
 
187
        // verify that it's not already there before adding it. The search manager will
 
188
        // check for that too, so this check is mostly to avoid a warning message.
189
189
        if (ConfMan.hasKey("extrapath", Common::ConfigManager::kApplicationDomain)) {
190
 
                dir = Common::FSNode(ConfMan.get("extrapath", Common::ConfigManager::kApplicationDomain));
191
 
                SearchMan.addDirectory(dir.getPath(), dir);
 
190
                Common::String extraPath = ConfMan.get("extrapath", Common::ConfigManager::kApplicationDomain);
 
191
                if (!SearchMan.hasArchive(extraPath)) {
 
192
                        dir = Common::FSNode(extraPath);
 
193
                        SearchMan.addDirectory(dir.getPath(), dir);
 
194
                }
192
195
        }
193
196
 
194
197
        // On creation the engine should have set up all debug levels so we can use
333
336
 
334
337
        PluginManager::instance().init();
335
338
        PluginManager::instance().loadAllPlugins(); // load plugins for cached plugin manager
336
 
        
 
339
 
337
340
        // If we received an invalid music parameter via command line we check this here.
338
341
        // We can't check this before loading the music plugins.
339
342
        // On the other hand we cannot load the plugins before we know the file paths (in case of external plugins).
349
352
        Common::Error res;
350
353
 
351
354
        // TODO: deal with settings that require plugins to be loaded
352
 
        res = Base::processSettings(command, settings);
353
 
        if (res.getCode() != Common::kArgumentNotProcessed) {
 
355
        if (Base::processSettings(command, settings, res)) {
354
356
                if (res.getCode() != Common::kNoError)
355
357
                        warning("%s", res.getDesc().c_str());
356
358
                return res.getCode();
386
388
        system.getAudioCDManager();
387
389
        MusicManager::instance();
388
390
        Common::DebugManager::instance();
389
 
        
 
391
 
390
392
        // Init the event manager. As the virtual keyboard is loaded here, it must
391
393
        // take place after the backend is initiated and the screen has been setup
392
394
        system.getEventManager()->init();
420
422
                        // Try to run the game
421
423
                        Common::Error result = runGame(plugin, system, specialDebug);
422
424
 
 
425
                        // Flush Event recorder file. The recorder does not get reinitialized for next game
 
426
                        // which is intentional. Only single game per session is allowed.
 
427
                        g_eventRec.deinit();
 
428
 
423
429
                #if defined(UNCACHED_PLUGINS) && defined(DYNAMIC_MODULES)
424
430
                        // do our best to prevent fragmentation by unloading as soon as we can
425
431
                        PluginManager::instance().unloadPluginsExcept(PLUGIN_TYPE_ENGINE, NULL, false);
426
432
                        // reallocate the config manager to get rid of any fragmentation
427
433
                        ConfMan.defragment();
428
 
                #endif  
429
 
                        
 
434
                #endif
 
435
 
430
436
                        // Did an error occur ?
431
 
                        if (result.getCode() != Common::kNoError) {
 
437
                        if (result.getCode() != Common::kNoError && result.getCode() != Common::kUserCanceled) {
432
438
                                // Shows an informative error dialog if starting the selected game failed.
433
439
                                GUI::displayErrorDialog(result, _("Error running game:"));
434
440
                        }