[Scummvm-devel] Engines initialization

Eugene Sandulenko sev at scummvm.org
Sun Nov 14 20:21:23 CET 2004


Hi all,

I just commited a discussed a while ago change to scumm engine. Next
thing which is going to be implemented is possibility to change global
extrapath in GUI.

Why this is done? Some things in a particular engine initialization
process may require access to files. We have that nice list of default
directories, which are added sequentally. Such subsystems as SCUMM
FM-TOWNS Kanji ROM renderer or MT-32 emulator do benefit from it, as
their data could be shared among more than one game. Putting these to
extrapath saves space and eases maintenance.

But most of our engines do not make it possible, moreover some things
they do in their engine constructor may fail, and there is no way to
return status flag from a constructor.

So we should make it consistent, and I call for all engine
maintainers to help me with this.

Required changes are trivial, but you better know how code you wrote
works.

Basically your engine initialization should look like this:

MyEngine::MyEngine(GameDetector *detector, OSystem *syst) {
    File::addDefaultDirectory("weirdplace");

    // optional
    _simplevar = 0;
    _moresimplevar = 0;
}

void MyEngine::go() {
     do_stuff();

    _system->initSize(_screenWidth, _screenHeight);
    _midiDriver = GameDetector::detectMusicDriver(midi);

    whatever();

    mainLoop();
}

Note, that constructor adds any default directories you need and
doesn't touch other OSystem subsystems like graphics, sound or file
opening.

Present implementation of go() method returns void, but it would be
possible to catch any errors there and return them to caller in
base/main.cpp, so user could be gracefully returned to the
launcher. With constructor it cannot be done directly as it always
return object instance.

Engines which fo heavy stuff in their constructors:

  kyra
  simon
  sword2

Engines which call initSize in their constructors:

  queen
  sky

Engines which do not set up default directories in their constructors:

  queen
  sky
  sword1


If you don't have time/desire to fix your engine, notify me here or on
IRC and I will do it in the meantime.


Eugene




More information about the Scummvm-devel mailing list