diff options
author | Max Horn | 2005-01-01 18:53:47 +0000 |
---|---|---|
committer | Max Horn | 2005-01-01 18:53:47 +0000 |
commit | f52be9df681358564991e0988bf70160970104ad (patch) | |
tree | d7de4493e5f6e7c0b229014707a915d0b42d07e3 | |
parent | 03d4a6fa47e73ddbddc6bc096f6cef14ea7d7441 (diff) | |
download | scummvm-rg350-f52be9df681358564991e0988bf70160970104ad.tar.gz scummvm-rg350-f52be9df681358564991e0988bf70160970104ad.tar.bz2 scummvm-rg350-f52be9df681358564991e0988bf70160970104ad.zip |
Changed OSystem::instance() to return a reference, not a pointer (it now matches the Singleton interface)
svn-id: r16402
-rw-r--r-- | base/main.cpp | 34 | ||||
-rw-r--r-- | common/system.cpp | 4 | ||||
-rw-r--r-- | common/system.h | 4 | ||||
-rw-r--r-- | gui/newgui.cpp | 2 | ||||
-rw-r--r-- | queen/journal.cpp | 2 | ||||
-rw-r--r-- | sound/mixer.cpp | 2 |
6 files changed, 25 insertions, 23 deletions
diff --git a/base/main.cpp b/base/main.cpp index 3203d59775..1fbaa96ff7 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -187,19 +187,19 @@ static void do_memory_test(void) { int gDebugLevel = 0; -static bool launcherDialog(GameDetector &detector, OSystem *system) { +static bool launcherDialog(GameDetector &detector, OSystem &system) { - system->beginGFXTransaction(); + system.beginGFXTransaction(); // Set the user specified graphics mode (if any). - system->setGraphicsMode(ConfMan.get("gfx_mode").c_str()); + system.setGraphicsMode(ConfMan.get("gfx_mode").c_str()); // GUI is (currently) always running at 320x200 - system->initSize(320, 200); - system->endGFXTransaction(); + system.initSize(320, 200); + system.endGFXTransaction(); // Clear the main screen - system->clearScreen(); + system.clearScreen(); // FIXME - mouse cursors are currently always set via 8 bit data. // Thus for now we need to setup a dummy palette. On the long run, we might @@ -226,7 +226,7 @@ static bool launcherDialog(GameDetector &detector, OSystem *system) { 255, 255, 255, 0, }; - system->setPalette(dummy_palette, 0, 16); + system.setPalette(dummy_palette, 0, 16); #if defined(_WIN32_WCE) CELauncherDialog dlg(detector); @@ -238,7 +238,7 @@ static bool launcherDialog(GameDetector &detector, OSystem *system) { return (dlg.runModal() != -1); } -static int runGame(GameDetector &detector, OSystem *system) { +static int runGame(GameDetector &detector, OSystem &system) { // Set the window caption to the game name Common::String caption(ConfMan.get("description", detector._targetName)); @@ -247,11 +247,11 @@ static int runGame(GameDetector &detector, OSystem *system) { if (caption.isEmpty()) caption = detector._targetName; if (!caption.isEmpty()) { - system->setWindowCaption(caption.c_str()); + system.setWindowCaption(caption.c_str()); } // Create the game engine - Engine *engine = detector.createEngine(system); + Engine *engine = detector.createEngine(&system); assert(engine); // Add extrapath (if any) to the directory search list @@ -275,7 +275,7 @@ static int runGame(GameDetector &detector, OSystem *system) { delete engine; // Stop all sound processing now (this prevents some race conditions later on) - system->clearSoundCallback(); + system.clearSoundCallback(); return result; } @@ -372,13 +372,13 @@ extern "C" int scummvm_main(GameDetector &detector, int argc, char *argv[]) { // Ensure the system object exists (it may have already been created // at an earlier point, though!) - OSystem *system = OSystem::instance(); + OSystem &system = OSystem::instance(); // Create the timer services - g_timer = new Timer(system); + g_timer = new Timer(&system); // Set initial window caption - system->setWindowCaption(gScummVMFullVersion); + system.setWindowCaption(gScummVMFullVersion); // Unless a game was specified, show the launcher dialog if (detector._targetName.isEmpty()) @@ -413,8 +413,10 @@ extern "C" int scummvm_main(GameDetector &detector, int argc, char *argv[]) { // ...and quit (the return 0 should never be reached) delete g_timer; - system->quit(); - delete system; + system.quit(); + + error("If you are seeing this, your OSystem backend is not working properly"); + return 0; } // allegro needs this for some reason... diff --git a/common/system.cpp b/common/system.cpp index fbd9e0a7cd..9c465a14fb 100644 --- a/common/system.cpp +++ b/common/system.cpp @@ -58,10 +58,10 @@ static OSystem *createSystem() { #endif } -OSystem *OSystem::instance() { +OSystem &OSystem::instance() { if (!s_system) s_system = createSystem(); - return s_system; + return *s_system; } diff --git a/common/system.h b/common/system.h index b1d33e34b8..2a3b0fafc1 100644 --- a/common/system.h +++ b/common/system.h @@ -47,7 +47,7 @@ public: * not a real class (and thus it isn't based on our Singleton template). * @return the pointer to the (singleton) OSystem instance */ - static OSystem *instance(); + static OSystem &instance(); public: @@ -687,7 +687,7 @@ public: }; /** The global OSystem instance. Inited in main(). */ -#define g_system (OSystem::instance()) +#define g_system (&OSystem::instance()) namespace Common { diff --git a/gui/newgui.cpp b/gui/newgui.cpp index 961b8545d7..023c248108 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -57,7 +57,7 @@ enum { NewGui::NewGui() : _needRedraw(false), _stateIsSaved(false), _cursorAnimateCounter(0), _cursorAnimateTimer(0) { - _system = OSystem::instance(); + _system = &OSystem::instance(); // Clear the cursor memset(_cursor, 0xFF, sizeof(_cursor)); diff --git a/queen/journal.cpp b/queen/journal.cpp index df6240aba1..f5a3f87616 100644 --- a/queen/journal.cpp +++ b/queen/journal.cpp @@ -47,7 +47,7 @@ void Journal::use() { _prevJoeY = joe->y; _panelMode = PM_NORMAL; - _system = OSystem::instance(); + _system = &OSystem::instance(); _panelTextCount = 0; memset(_panelTextY, 0, sizeof(_panelTextY)); diff --git a/sound/mixer.cpp b/sound/mixer.cpp index 5358be7274..a981e32cda 100644 --- a/sound/mixer.cpp +++ b/sound/mixer.cpp @@ -99,7 +99,7 @@ public: SoundMixer::SoundMixer() { - _syst = OSystem::instance(); + _syst = &OSystem::instance(); _mutex = _syst->createMutex(); _premixChannel = 0; |