diff options
-rw-r--r-- | backends/sdl/graphics.cpp | 1 | ||||
-rw-r--r-- | backends/sdl/sdl-common.h | 4 | ||||
-rw-r--r-- | backends/sdl/sdl.cpp | 7 | ||||
-rw-r--r-- | base/main.cpp | 10 | ||||
-rw-r--r-- | common/system.h | 6 |
5 files changed, 22 insertions, 6 deletions
diff --git a/backends/sdl/graphics.cpp b/backends/sdl/graphics.cpp index 11b4e21fb2..0f000befdc 100644 --- a/backends/sdl/graphics.cpp +++ b/backends/sdl/graphics.cpp @@ -301,6 +301,7 @@ void OSystem_SDL::initSize(uint w, uint h, int overlayScale) { } void OSystem_SDL::loadGFXMode() { + assert(_inited); _forceFull = true; _modeFlags |= DF_UPDATE_EXPAND_1_PIXEL; diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h index fa8959f001..2d3337e0d5 100644 --- a/backends/sdl/sdl-common.h +++ b/backends/sdl/sdl-common.h @@ -69,6 +69,8 @@ public: OSystem_SDL(); virtual ~OSystem_SDL(); + virtual void initBackend(); + void beginGFXTransaction(void); void endGFXTransaction(void); @@ -188,7 +190,7 @@ public: #endif protected: - void initIntern(); + bool _inited; #ifdef USE_OSD SDL_Surface *_osdSurface; diff --git a/backends/sdl/sdl.cpp b/backends/sdl/sdl.cpp index ef40f2bd5f..69b767dd0d 100644 --- a/backends/sdl/sdl.cpp +++ b/backends/sdl/sdl.cpp @@ -35,7 +35,8 @@ OSystem *OSystem_SDL_create() { return new OSystem_SDL(); } -void OSystem_SDL::initIntern() { +void OSystem_SDL::initBackend() { + assert(!_inited); int joystick_num = ConfMan.getInt("joystick_num"); uint32 sdlFlags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER; @@ -89,6 +90,8 @@ void OSystem_SDL::initIntern() { printf("Using joystick: %s\n", SDL_JoystickName(0)); _joystick = SDL_JoystickOpen(joystick_num); } + + _inited = true; } OSystem_SDL::OSystem_SDL() @@ -120,7 +123,7 @@ OSystem_SDL::OSystem_SDL() memset(&_km, 0, sizeof(_km)); memset(&_mouseCurState, 0, sizeof(_mouseCurState)); - initIntern(); + _inited = false; } OSystem_SDL::~OSystem_SDL() { diff --git a/base/main.cpp b/base/main.cpp index 11ea937701..1b9e9495ee 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -368,6 +368,10 @@ extern "C" int main(int argc, char *argv[]) { // Load the plugins PluginManager::instance().loadPlugins(); + // Ensure the system object exists (it may have already been created + // at an earlier point, though!) + OSystem &system = OSystem::instance(); + // Parse the command line information #ifndef _WIN32_WCE GameDetector detector; @@ -378,9 +382,9 @@ extern "C" int main(int argc, char *argv[]) { ArgsFree(argv); #endif - // Ensure the system object exists (it may have already been created - // at an earlier point, though!) - OSystem &system = OSystem::instance(); + // Init the backend. Must take place after all config data (including + // the command line params) was read. + system.initBackend(); // Create the timer services g_timer = new Timer(&system); diff --git a/common/system.h b/common/system.h index e3651e803e..94d7bd3e84 100644 --- a/common/system.h +++ b/common/system.h @@ -47,6 +47,12 @@ protected: public: + /** + * The following method is called once, from main.cpp, after all + * config data (including command line params etc.) are fully loaded. + */ + virtual void initBackend() { } + /** @name Feature flags */ //@{ |