From dd35e72a7eefa922eba68dd28e8a18cbb98c0b16 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Wed, 27 Jun 2012 19:58:20 +0200 Subject: GOB: Return proper errors in GobEngine::run() --- engines/gob/gob.cpp | 29 +++++++++++++++-------------- engines/gob/gob.h | 6 +++--- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index 3d8a18ed38..3202b5e23d 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -274,15 +274,15 @@ void GobEngine::setTrueColor(bool trueColor) { } Common::Error GobEngine::run() { - if (!initGameParts()) { - GUIErrorMessage("GobEngine::init(): Unknown version of game engine"); - return Common::kUnknownError; - } + Common::Error err; - if (!initGraphics()) { - GUIErrorMessage("GobEngine::init(): Failed to set up graphics"); - return Common::kUnknownError; - } + err = initGameParts(); + if (err.getCode() != Common::kNoError) + return err; + + err = initGraphics(); + if (err.getCode() != Common::kNoError) + return err; // On some systems it's not safe to run CD audio games from the CD. if (isCD()) @@ -392,7 +392,7 @@ void GobEngine::pauseGame() { pauseEngineIntern(false); } -bool GobEngine::initGameParts() { +Common::Error GobEngine::initGameParts() { _resourceSizeWorkaround = false; // just detect some devices some of which will be always there if the music is not disabled @@ -605,9 +605,10 @@ bool GobEngine::initGameParts() { _scenery = new Scenery_v2(this); _saveLoad = new SaveLoad_v2(this, _targetName.c_str()); break; + default: deinitGameParts(); - return false; + return Common::kUnsupportedGameidError; } // Setup mixer @@ -615,7 +616,7 @@ bool GobEngine::initGameParts() { _inter->setupOpcodes(); - return true; + return Common::kNoError; } void GobEngine::deinitGameParts() { @@ -637,10 +638,10 @@ void GobEngine::deinitGameParts() { delete _dataIO; _dataIO = 0; } -bool GobEngine::initGraphics() { +Common::Error GobEngine::initGraphics() { if (is800x600()) { warning("GobEngine::initGraphics(): 800x600 games currently unsupported"); - return false; + return Common::kUnsupportedGameidError; } else if (is640x480()) { _width = 640; _height = 480; @@ -664,7 +665,7 @@ bool GobEngine::initGraphics() { _global->_primarySurfDesc = SurfacePtr(new Surface(_width, _height, _pixelFormat.bytesPerPixel)); - return true; + return Common::kNoError; } } // End of namespace Gob diff --git a/engines/gob/gob.h b/engines/gob/gob.h index 52f3ba8f2d..d3d2bf1576 100644 --- a/engines/gob/gob.h +++ b/engines/gob/gob.h @@ -176,10 +176,10 @@ private: virtual void pauseEngineIntern(bool pause); virtual void syncSoundSettings(); - bool initGameParts(); - void deinitGameParts(); + Common::Error initGameParts(); + Common::Error initGraphics(); - bool initGraphics(); + void deinitGameParts(); public: static const Common::Language _gobToScummVMLang[]; -- cgit v1.2.3