From 40136f25909bd8773cac0f08740a36037395e9a7 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 6 Nov 2008 17:05:54 +0000 Subject: Switched various Engine APIs to use Common::Error svn-id: r34916 --- engines/agi/agi.cpp | 8 ++++---- engines/agi/agi.h | 4 ++-- engines/agi/preagi.cpp | 4 ++-- engines/agi/preagi.h | 2 +- engines/agos/agos.cpp | 8 ++++---- engines/agos/agos.h | 4 ++-- engines/cine/cine.cpp | 8 ++++---- engines/cine/cine.h | 4 ++-- engines/cruise/cruise.cpp | 8 ++++---- engines/cruise/cruise.h | 6 ++++-- engines/drascula/drascula.cpp | 10 +++++----- engines/drascula/drascula.h | 6 +++--- engines/engine.cpp | 8 ++++---- engines/engine.h | 21 +++++++++------------ engines/gob/gob.cpp | 10 +++++----- engines/gob/gob.h | 4 ++-- engines/igor/igor.cpp | 8 ++++---- engines/igor/igor.h | 8 ++++---- engines/igor/saveload.cpp | 8 ++++---- engines/kyra/kyra_hof.cpp | 10 +++++----- engines/kyra/kyra_hof.h | 4 ++-- engines/kyra/kyra_lok.cpp | 10 +++++----- engines/kyra/kyra_lok.h | 4 ++-- engines/kyra/kyra_mr.cpp | 8 ++++---- engines/kyra/kyra_mr.h | 4 ++-- engines/kyra/kyra_v1.cpp | 4 ++-- engines/kyra/kyra_v1.h | 4 ++-- engines/kyra/lol.cpp | 8 ++++---- engines/kyra/lol.h | 4 ++-- engines/kyra/saveload.cpp | 6 +++--- engines/lure/lure.cpp | 16 ++++++++-------- engines/lure/lure.h | 4 ++-- engines/m4/m4.cpp | 16 ++++++++-------- engines/m4/m4.h | 10 ++++++---- engines/made/made.cpp | 8 ++++---- engines/made/made.h | 5 +++-- engines/parallaction/parallaction.cpp | 4 ++-- engines/parallaction/parallaction.h | 10 +++++----- engines/parallaction/parallaction_br.cpp | 8 ++++---- engines/parallaction/parallaction_ns.cpp | 8 ++++---- engines/queen/queen.cpp | 24 ++++++++++++++++-------- engines/queen/queen.h | 8 ++++---- engines/saga/detection.cpp | 4 ++-- engines/saga/saga.cpp | 12 ++++++------ engines/saga/saga.h | 6 +++--- engines/scumm/detection.cpp | 11 +++++------ engines/scumm/he/intern_he.h | 4 ++-- engines/scumm/saveload.cpp | 8 ++++---- engines/scumm/scumm.cpp | 16 ++++++++-------- engines/scumm/scumm.h | 8 ++++---- engines/sky/sky.cpp | 8 ++++---- engines/sky/sky.h | 4 ++-- engines/sword1/sword1.cpp | 8 ++++---- engines/sword1/sword1.h | 4 ++-- engines/sword2/sword2.cpp | 14 +++++++------- engines/sword2/sword2.h | 4 ++-- engines/tinsel/tinsel.cpp | 8 ++++---- engines/tinsel/tinsel.h | 5 +++-- engines/touche/menu.cpp | 4 ++-- engines/touche/saveload.cpp | 8 ++++---- engines/touche/touche.cpp | 8 ++++---- engines/touche/touche.h | 8 ++++---- 62 files changed, 244 insertions(+), 234 deletions(-) (limited to 'engines') diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index 3c1ec5efde..15af27b587 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -779,7 +779,7 @@ AgiEngine::~AgiEngine() { free(_predictiveDictText); } -int AgiBase::init() { +Common::Error AgiBase::init() { // Initialize backend _system->beginGFXTransaction(); @@ -791,10 +791,10 @@ int AgiBase::init() { _gfx->gfxSetPalette(); - return 0; + return Common::kNoError; } -int AgiEngine::go() { +Common::Error AgiEngine::go() { CursorMan.showMouse(true); report(" \nAGI engine %s is ready.\n", gScummVMVersion); @@ -808,7 +808,7 @@ int AgiEngine::go() { runGame(); - return 0; + return Common::kNoError; } void AgiEngine::syncSoundSettings() { diff --git a/engines/agi/agi.h b/engines/agi/agi.h index a1edcb2ad0..2e4710744b 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -696,7 +696,7 @@ struct StringData { class AgiBase : public ::Engine { protected: // Engine API - virtual int init(); + virtual Common::Error init(); virtual bool hasFeature(EngineFeature f) const; virtual void initialize() = 0; @@ -745,7 +745,7 @@ class AgiEngine : public AgiBase { protected: // Engine APIs - virtual int go(); + virtual Common::Error go(); virtual void syncSoundSettings(); void initialize(); diff --git a/engines/agi/preagi.cpp b/engines/agi/preagi.cpp index 666d1b1b11..a3045a31cc 100644 --- a/engines/agi/preagi.cpp +++ b/engines/agi/preagi.cpp @@ -189,7 +189,7 @@ PreAgiEngine::~PreAgiEngine() { } -int PreAgiEngine::go() { +Common::Error PreAgiEngine::go() { setflag(fSoundOn, true); // enable sound /* @@ -227,7 +227,7 @@ FIXME (Fingolfin asks): Why are Mickey, Winnie and Troll standalone classes error("Unknown preagi engine"); break; } - return 0; + return Common::kNoError; } } // End of namespace Agi diff --git a/engines/agi/preagi.h b/engines/agi/preagi.h index 73288de93c..10a46aa6ec 100644 --- a/engines/agi/preagi.h +++ b/engines/agi/preagi.h @@ -37,7 +37,7 @@ class PreAgiEngine : public AgiBase { int _gameId; protected: - int go(); + Common::Error go(); void initialize(); public: diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp index 3968646e63..e7669941b3 100644 --- a/engines/agos/agos.cpp +++ b/engines/agos/agos.cpp @@ -528,7 +528,7 @@ AGOSEngine::AGOSEngine(OSystem *syst) syst->getEventManager()->registerRandomSource(_rnd, "agos"); } -int AGOSEngine::init() { +Common::Error AGOSEngine::init() { if (getGameId() == GID_DIMP) { _screenWidth = 496; _screenHeight = 400; @@ -663,7 +663,7 @@ int AGOSEngine::init() { if (gDebugLevel == 5) _startVgaScript = true; - return 0; + return Common::kNoError; } static const uint16 initialVideoWindows_Simon[20] = { @@ -958,7 +958,7 @@ void AGOSEngine::pause() { } } -int AGOSEngine::go() { +Common::Error AGOSEngine::go() { loadGamePcFile(); addTimeEvent(0, 1); @@ -1023,7 +1023,7 @@ int AGOSEngine::go() { delay(100); } - return 0; + return Common::kNoError; } diff --git a/engines/agos/agos.h b/engines/agos/agos.h index 4d1349b942..ada24fc032 100644 --- a/engines/agos/agos.h +++ b/engines/agos/agos.h @@ -164,8 +164,8 @@ class AGOSEngine : public Engine { friend class MoviePlayer; // Engine APIs - virtual int init(); - virtual int go(); + virtual Common::Error init(); + virtual Common::Error go(); virtual GUI::Debugger *getDebugger(); virtual bool hasFeature(EngineFeature f) const; virtual void syncSoundSettings(); diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp index d12ba61480..51f778610a 100644 --- a/engines/cine/cine.cpp +++ b/engines/cine/cine.cpp @@ -74,7 +74,7 @@ CineEngine::~CineEngine() { Common::clearAllSpecialDebugLevels(); } -int CineEngine::init() { +Common::Error CineEngine::init() { // Initialize backend _system->beginGFXTransaction(); initCommonGFX(false); @@ -91,10 +91,10 @@ int CineEngine::init() { initialize(); - return 0; + return Common::kNoError; } -int CineEngine::go() { +Common::Error CineEngine::go() { CursorMan.showMouse(true); mainLoop(1); @@ -102,7 +102,7 @@ int CineEngine::go() { delete[] collisionPage; delete g_sound; - return 0; + return Common::kNoError; } int CineEngine::getTimerDelay() const { diff --git a/engines/cine/cine.h b/engines/cine/cine.h index ef643a115e..933f692ec2 100644 --- a/engines/cine/cine.h +++ b/engines/cine/cine.h @@ -71,8 +71,8 @@ class CineEngine : public Engine { protected: // Engine APIs - virtual int init(); - virtual int go(); + virtual Common::Error init(); + virtual Common::Error go(); virtual bool hasFeature(EngineFeature f) const; void shutdown(); diff --git a/engines/cruise/cruise.cpp b/engines/cruise/cruise.cpp index f9487165e1..c84f4d7361 100644 --- a/engines/cruise/cruise.cpp +++ b/engines/cruise/cruise.cpp @@ -70,7 +70,7 @@ CruiseEngine::~CruiseEngine() { #endif } -int CruiseEngine::init() { +Common::Error CruiseEngine::init() { // Initialize backend _system->beginGFXTransaction(); initCommonGFX(false); @@ -79,16 +79,16 @@ int CruiseEngine::init() { initialize(); - return 0; + return Common::kNoError; } -int CruiseEngine::go() { +Common::Error CruiseEngine::go() { Cruise::changeCursor(Cruise::CURSOR_NORMAL); CursorMan.showMouse(true); Cruise::mainLoop(); - return 0; + return Common::kNoError; } void CruiseEngine::initialize() { diff --git a/engines/cruise/cruise.h b/engines/cruise/cruise.h index 4a6bcff498..ad5b1100cb 100644 --- a/engines/cruise/cruise.h +++ b/engines/cruise/cruise.h @@ -44,8 +44,10 @@ struct CRUISEGameDescription; class CruiseEngine:public Engine { protected: - int init(); - int go(); + // Engine APIs + virtual Common::Error init(); + virtual Common::Error go(); + void shutdown(); bool initGame(); diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index fce4fa73c6..8bd51123b5 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -104,7 +104,7 @@ DrasculaEngine::~DrasculaEngine() { freeTexts(_textd1); } -int DrasculaEngine::init() { +Common::Error DrasculaEngine::init() { // Initialize backend _system->beginGFXTransaction(); initCommonGFX(false); @@ -170,15 +170,15 @@ int DrasculaEngine::init() { *textName = 0; if (!loadDrasculaDat()) - return 1; + return Common::kUnknownError; setupRoomsTable(); loadArchives(); - return 0; + return Common::kNoError; } -int DrasculaEngine::go() { +Common::Error DrasculaEngine::go() { currentChapter = 1; // values from 1 to 6 will start each part of game loadedDifferentChapter = 0; @@ -274,7 +274,7 @@ int DrasculaEngine::go() { currentChapter++; } - return 0; + return Common::kNoError; } void DrasculaEngine::endChapter() { diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index 4a00d35d10..a03e5c16da 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -275,9 +275,9 @@ class DrasculaEngine : public ::Engine { Common::KeyState _keyPressed; protected: - int init(); - int go(); -// void shutdown(); + // Engine APIs + virtual Common::Error init(); + virtual Common::Error go(); public: DrasculaEngine(OSystem *syst, const DrasculaGameDescription *gameDesc); diff --git a/engines/engine.cpp b/engines/engine.cpp index 52b4cc4ad3..fc13adf9c7 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -255,9 +255,9 @@ void Engine::syncSoundSettings() { _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, soundVolumeSpeech); } -int Engine::loadGameState(int slot) { +Common::Error Engine::loadGameState(int slot) { // Do nothing by default - return 0; + return Common::kNoError; } bool Engine::canLoadGameStateCurrently() { @@ -265,9 +265,9 @@ bool Engine::canLoadGameStateCurrently() { return false; } -int Engine::saveGameState(int slot, const char *desc) { +Common::Error Engine::saveGameState(int slot, const char *desc) { // Do nothing by default - return 0; + return Common::kNoError; } bool Engine::canSaveGameStateCurrently() { diff --git a/engines/engine.h b/engines/engine.h index 2a631e069f..5444293a36 100644 --- a/engines/engine.h +++ b/engines/engine.h @@ -26,6 +26,7 @@ #define ENGINES_ENGINE_H #include "common/scummsys.h" +#include "common/error.h" #include "common/fs.h" #include "common/str.h" @@ -127,17 +128,17 @@ public: /** * Init the engine. - * @return 0 for success, else an error code. + * @return returns kNoError on success, else an error code. */ - virtual int init() = 0; + virtual Common::Error init() = 0; /** * Start the main engine loop. * The return value is not yet used, but could indicate whether the user * wants to return to the launch or to fully quit ScummVM. - * @return 0 for success, else an error code. + * @return returns kNoError on success, else an error code. */ - virtual int go() = 0; + virtual Common::Error go() = 0; /** * Prepare an error string, which is printed by the error() function. @@ -168,11 +169,9 @@ public: /** * Load a game state. * @param slot the slot from which a savestate should be loaded - * @return returns 0 on success, anything else indicates failure - * - * @todo define proper error values + * @return returns kNoError on success, else an error code. */ - virtual int loadGameState(int slot); + virtual Common::Error loadGameState(int slot); /** * Indicates whether a game state can be loaded. @@ -183,11 +182,9 @@ public: * Save a game state. * @param slot the slot into which the savestate should be stored * @param desc a description for the savestate, entered by the user - * @return returns 0 on success, anything else indicates failure - * - * @todo define proper error values + * @return returns kNoError on success, else an error code. */ - virtual int saveGameState(int slot, const char *desc); + virtual Common::Error saveGameState(int slot, const char *desc); /** * Indicates whether a game state can be saved. diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index e1543e9277..de369c5528 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -110,10 +110,10 @@ GobEngine::~GobEngine() { delete[] _startTot0; } -int GobEngine::go() { +Common::Error GobEngine::go() { _init->initGame(0); - return 0; + return Common::kNoError; } const char *GobEngine::getLangDesc(int16 language) const { @@ -177,10 +177,10 @@ bool GobEngine::hasAdlib() const { return (_features & kFeaturesAdlib) != 0; } -int GobEngine::init() { +Common::Error GobEngine::init() { if (!initGameParts()) { GUIErrorMessage("GobEngine::init(): Unknown version of game engine"); - return -1; + return Common::kUnknownError; } _video->setSize(is640()); @@ -259,7 +259,7 @@ int GobEngine::init() { // 640x480. g_system->setFeatureState(OSystem::kFeatureAutoComputeDirtyRects, true); - return 0; + return Common::kNoError; } void GobEngine::pauseEngineIntern(bool pause) { diff --git a/engines/gob/gob.h b/engines/gob/gob.h index 599d7085fb..69f4a20632 100644 --- a/engines/gob/gob.h +++ b/engines/gob/gob.h @@ -191,8 +191,8 @@ private: uint32 _pauseStart; // Engine APIs - virtual int init(); - virtual int go(); + virtual Common::Error init(); + virtual Common::Error go(); virtual bool hasFeature(EngineFeature f) const; virtual void pauseEngineIntern(bool pause); diff --git a/engines/igor/igor.cpp b/engines/igor/igor.cpp index 4d4fb97762..d68aeb7c3e 100644 --- a/engines/igor/igor.cpp +++ b/engines/igor/igor.cpp @@ -88,14 +88,14 @@ IgorEngine::~IgorEngine() { delete _midiPlayer; } -int IgorEngine::init() { +Common::Error IgorEngine::init() { _system->beginGFXTransaction(); initCommonGFX(false); _system->initSize(320, 200); _system->endGFXTransaction(); _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); - return 0; + return Common::kNoError; } void IgorEngine::restart() { @@ -169,7 +169,7 @@ void IgorEngine::restart() { _gameTicks = 0; } -int IgorEngine::go() { +Common::Error IgorEngine::go() { restart(); setupDefaultPalette(); _currentPart = ConfMan.getInt("boot_param"); @@ -192,7 +192,7 @@ int IgorEngine::go() { PART_MAIN(); _ovlFile.close(); _sndFile.close(); - return 0; + return Common::kNoError; } void IgorEngine::readTableFile() { diff --git a/engines/igor/igor.h b/engines/igor/igor.h index 418a7ad6b4..4ded9d1eb3 100644 --- a/engines/igor/igor.h +++ b/engines/igor/igor.h @@ -312,8 +312,8 @@ public: IgorEngine(OSystem *system, const DetectedGameVersion *dgv); virtual ~IgorEngine(); - virtual int init(); - virtual int go(); + virtual Common::Error init(); + virtual Common::Error go(); void handleOptionsMenu_paintSave(); bool handleOptionsMenu_handleKeyDownSave(int key); @@ -427,8 +427,8 @@ protected: void dialogueReplyToQuestion(int x, int y, int r, int g, int b, int reply = 0); void saveOrLoadGameState(TypeSerializer &typeSerializer); - int loadGameState(int slot); - int saveGameState(int slot); + Common::Error loadGameState(int slot); + Common::Error saveGameState(int slot); void generateGameStateFileName(int num, char *dst, int len) const; MidiPlayer *_midiPlayer; diff --git a/engines/igor/saveload.cpp b/engines/igor/saveload.cpp index a87ecc0ba5..cbae77a343 100644 --- a/engines/igor/saveload.cpp +++ b/engines/igor/saveload.cpp @@ -156,7 +156,7 @@ void IgorEngine::saveOrLoadGameState(TypeSerializer &typeSerializer) { } } -int IgorEngine::loadGameState(int slot) { +Common::Error IgorEngine::loadGameState(int slot) { char name[64]; generateGameStateFileName(slot, name, 63); Common::InSaveFile *isf = _saveFileMan->openForLoading(name); @@ -176,10 +176,10 @@ int IgorEngine::loadGameState(int slot) { debug(0, "Loaded state, current part %d", _currentPart); } - return 0; // TODO: return success/failure + return Common::kNoError; // TODO: return success/failure } -int IgorEngine::saveGameState(int slot) { +Common::Error IgorEngine::saveGameState(int slot) { char name[64]; generateGameStateFileName(slot, name, 63); Common::OutSaveFile *osf = _saveFileMan->openForSaving(name); @@ -190,7 +190,7 @@ int IgorEngine::saveGameState(int slot) { delete osf; } - return 0; // TODO: return success/failure + return Common::kNoError; // TODO: return success/failure } void IgorEngine::generateGameStateFileName(int num, char *dst, int len) const { diff --git a/engines/kyra/kyra_hof.cpp b/engines/kyra/kyra_hof.cpp index a0213c0be3..bc5a59b7a9 100644 --- a/engines/kyra/kyra_hof.cpp +++ b/engines/kyra/kyra_hof.cpp @@ -219,7 +219,7 @@ void KyraEngine_HoF::pauseEngineIntern(bool pause) { } } -int KyraEngine_HoF::init() { +Common::Error KyraEngine_HoF::init() { _screen = new Screen_HoF(this, _system); assert(_screen); _screen->setResolution(); @@ -261,7 +261,7 @@ int KyraEngine_HoF::init() { // No mouse display in demo if (_flags.isDemo && !_flags.isTalkie) - return 0; + return Common::kNoError; _res->exists("PWGMOUSE.SHP", true); uint8 *shapes = _res->fileData("PWGMOUSE.SHP", 0); @@ -273,10 +273,10 @@ int KyraEngine_HoF::init() { delete[] shapes; _screen->setMouseCursor(0, 0, getShapePtr(0)); - return 0; + return Common::kNoError; } -int KyraEngine_HoF::go() { +Common::Error KyraEngine_HoF::go() { if (_gameToLoad == -1) { if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98) seq_showStarcraftLogo(); @@ -326,7 +326,7 @@ int KyraEngine_HoF::go() { seq_playSequences(kSequenceFunters, kSequenceFrash); } - return 0; + return Common::kNoError; } void KyraEngine_HoF::startup() { diff --git a/engines/kyra/kyra_hof.h b/engines/kyra/kyra_hof.h index dc4161f0c1..62039cb80a 100644 --- a/engines/kyra/kyra_hof.h +++ b/engines/kyra/kyra_hof.h @@ -292,8 +292,8 @@ protected: void seq_init(); void seq_uninit(); - int init(); - int go(); + Common::Error init(); + Common::Error go(); Screen_HoF *_screen; TextDisplayer_HoF *_text; diff --git a/engines/kyra/kyra_lok.cpp b/engines/kyra/kyra_lok.cpp index e8db3467fc..e995c74fd2 100644 --- a/engines/kyra/kyra_lok.cpp +++ b/engines/kyra/kyra_lok.cpp @@ -155,7 +155,7 @@ KyraEngine_LoK::~KyraEngine_LoK() { delete[] _sceneAnimTable[i]; } -int KyraEngine_LoK::init() { +Common::Error KyraEngine_LoK::init() { _screen = new Screen_LoK(this, _system); assert(_screen); _screen->setResolution(); @@ -284,10 +284,10 @@ int KyraEngine_LoK::init() { _lastMusicCommand = 0; - return 0; + return Common::kNoError; } -int KyraEngine_LoK::go() { +Common::Error KyraEngine_LoK::go() { if (_res->getFileSize("6.FNT")) _screen->loadFont(Screen::FID_6_FNT, "6.FNT"); _screen->loadFont(Screen::FID_8_FNT, "8FAT.FNT"); @@ -304,7 +304,7 @@ int KyraEngine_LoK::go() { setGameFlag(0xEF); seq_intro(); if (shouldQuit()) - return 0; + return Common::kNoError; if (_skipIntroFlag && _abortIntroFlag) resetGameFlag(0xEF); } @@ -312,7 +312,7 @@ int KyraEngine_LoK::go() { resetGameFlag(0xEF); mainLoop(); } - return 0; + return Common::kNoError; } diff --git a/engines/kyra/kyra_lok.h b/engines/kyra/kyra_lok.h index e6fc0dc774..c345dd4df8 100644 --- a/engines/kyra/kyra_lok.h +++ b/engines/kyra/kyra_lok.h @@ -144,8 +144,8 @@ public: const uint8 * const*palTable2() { return &_specialPalettes[29]; } protected: - virtual int go(); - virtual int init(); + virtual Common::Error go(); + virtual Common::Error init(); public: // sequences diff --git a/engines/kyra/kyra_mr.cpp b/engines/kyra/kyra_mr.cpp index 7dea56a5fa..c461bfa494 100644 --- a/engines/kyra/kyra_mr.cpp +++ b/engines/kyra/kyra_mr.cpp @@ -202,7 +202,7 @@ KyraEngine_MR::~KyraEngine_MR() { delete _album.rightPage.wsa; } -int KyraEngine_MR::init() { +Common::Error KyraEngine_MR::init() { _screen = new Screen_MR(this, _system); assert(_screen); _screen->setResolution(); @@ -233,10 +233,10 @@ int KyraEngine_MR::init() { _res->loadFileToBuf("PALETTE.COL", _screen->getPalette(0), 768); _screen->setScreenPalette(_screen->getPalette(0)); - return 0; + return Common::kNoError; } -int KyraEngine_MR::go() { +Common::Error KyraEngine_MR::go() { bool running = true; preinit(); _screen->hideMouse(); @@ -324,7 +324,7 @@ int KyraEngine_MR::go() { if (_showOutro) playVQA("CREDITS"); - return 0; + return Common::kNoError; } void KyraEngine_MR::initMainMenu() { diff --git a/engines/kyra/kyra_mr.h b/engines/kyra/kyra_mr.h index a6fb9af20c..0bf5e663b4 100644 --- a/engines/kyra/kyra_mr.h +++ b/engines/kyra/kyra_mr.h @@ -62,7 +62,7 @@ public: int language() const { return _lang; } bool heliumMode() const { return _configHelium; } - int go(); + Common::Error go(); void playVQA(const char *name); @@ -84,7 +84,7 @@ private: Screen_MR *_screen; SoundDigital *_soundDigital; - int init(); + Common::Error init(); void preinit(); void startup(); diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp index 0d398f6c64..11a303c27a 100644 --- a/engines/kyra/kyra_v1.cpp +++ b/engines/kyra/kyra_v1.cpp @@ -92,7 +92,7 @@ void KyraEngine_v1::pauseEngineIntern(bool pause) { _timer->pause(pause); } -int KyraEngine_v1::init() { +Common::Error KyraEngine_v1::init() { registerDefaultSettings(); // Setup mixer @@ -186,7 +186,7 @@ int KyraEngine_v1::init() { // Prevent autosave on game startup _lastAutosave = _system->getMillis(); - return 0; + return Common::kNoError; } KyraEngine_v1::~KyraEngine_v1() { diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h index 81eea7420c..f85ddade50 100644 --- a/engines/kyra/kyra_v1.h +++ b/engines/kyra/kyra_v1.h @@ -168,7 +168,7 @@ public: protected: // Engine APIs - virtual int init(); + virtual Common::Error init(); virtual ::GUI::Debugger *getDebugger(); virtual bool hasFeature(EngineFeature f) const; virtual void pauseEngineIntern(bool pause); @@ -304,7 +304,7 @@ protected: static kReadSaveHeaderError readSaveHeader(Common::SeekableReadStream *file, bool loadThumbnail, SaveHeader &header); - int loadGameState(int slot); + Common::Error loadGameState(int slot); virtual void loadGame(const char *fileName) = 0; virtual void saveGame(const char *fileName, const char *saveName, const Graphics::Surface *thumbnail) = 0; diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp index 91c9b65d1e..0b1a63ecf6 100644 --- a/engines/kyra/lol.cpp +++ b/engines/kyra/lol.cpp @@ -74,7 +74,7 @@ Screen *LoLEngine::screen() { return _screen; } -int LoLEngine::init() { +Common::Error LoLEngine::init() { _screen = new Screen_LoL(this, _system); assert(_screen); _screen->setResolution(); @@ -90,10 +90,10 @@ int LoLEngine::init() { if (!_sound->init()) error("Couldn't init sound"); - return 0; + return Common::kNoError; } -int LoLEngine::go() { +Common::Error LoLEngine::go() { setupPrologueData(true); showIntro(); _sound->playTrack(6); @@ -102,7 +102,7 @@ int LoLEngine::go() { _screen->fadeToBlack(); setupPrologueData(false); - return 0; + return Common::kNoError; } #pragma mark - Input diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h index 71d184f062..3ece9b28a4 100644 --- a/engines/kyra/lol.h +++ b/engines/kyra/lol.h @@ -47,8 +47,8 @@ private: Screen_LoL *_screen; TIMInterpreter *_tim; - int init(); - int go(); + Common::Error init(); + Common::Error go(); // input void updateInput(); diff --git a/engines/kyra/saveload.cpp b/engines/kyra/saveload.cpp index e85346a9ba..5f94c1321d 100644 --- a/engines/kyra/saveload.cpp +++ b/engines/kyra/saveload.cpp @@ -244,14 +244,14 @@ bool KyraEngine_v1::saveFileLoadable(int slot) { return false; } -int KyraEngine_v1::loadGameState(int slot) { +Common::Error KyraEngine_v1::loadGameState(int slot) { if (!_isSaveAllowed) - return -1; + return Common::kUnknownError; // FIXME const char *filename = getSavegameFilename(slot); loadGame(filename); - return 0; + return Common::kNoError; } void KyraEngine_v1::checkAutosave() { diff --git a/engines/lure/lure.cpp b/engines/lure/lure.cpp index 32eb0dbe21..282aa9801d 100644 --- a/engines/lure/lure.cpp +++ b/engines/lure/lure.cpp @@ -48,7 +48,7 @@ LureEngine::LureEngine(OSystem *system, const LureGameDescription *gameDesc): En Common::addSpecialDebugLevel(kLureDebugStrings, "strings", "Strings debugging"); } -int LureEngine::init() { +Common::Error LureEngine::init() { int_engine = this; _initialised = false; @@ -62,7 +62,7 @@ int LureEngine::init() { VersionStructure version; if (!f.open(SUPPORT_FILENAME)) { GUIError("Could not locate Lure support file"); - return 1; + return Common::kUnknownError; } f.seek(0xbf * 8); @@ -71,12 +71,12 @@ int LureEngine::init() { if (READ_LE_UINT16(&version.id) != 0xffff) { GUIError("Error validating %s - file is invalid or out of date", SUPPORT_FILENAME); - return 1; + return Common::kUnknownError; } else if ((version.vMajor != LURE_DAT_MAJOR) || (version.vMinor != LURE_DAT_MINOR)) { GUIError("Incorrect version of %s file - expected %d.%d but got %d.%d", SUPPORT_FILENAME, LURE_DAT_MAJOR, LURE_DAT_MINOR, version.vMajor, version.vMinor); - return 1; + return Common::kUnknownError; } _disk = new Disk(); @@ -92,7 +92,7 @@ int LureEngine::init() { _gameToLoad = -1; _initialised = true; - return 0; + return Common::kNoError; } LureEngine::~LureEngine() { @@ -119,7 +119,7 @@ LureEngine &LureEngine::getReference() { return *int_engine; } -int LureEngine::go() { +Common::Error LureEngine::go() { Game *gameInstance = new Game(); // If requested, load a savegame instead of showing the intro @@ -135,7 +135,7 @@ int LureEngine::go() { bool result = dialog->show(); delete dialog; if (shouldQuit()) - return 0; + return Common::kNoError; if (!result) error("Sorry - copy protection failed"); @@ -158,7 +158,7 @@ int LureEngine::go() { } delete gameInstance; - return 0; + return Common::kNoError; } void LureEngine::pauseEngineIntern(bool pause) { diff --git a/engines/lure/lure.h b/engines/lure/lure.h index a1e1448e0f..38029a0601 100644 --- a/engines/lure/lure.h +++ b/engines/lure/lure.h @@ -70,8 +70,8 @@ public: static LureEngine &getReference(); // Engine APIs - virtual int init(); - virtual int go(); + virtual Common::Error init(); + virtual Common::Error go(); virtual bool hasFeature(EngineFeature f) const; virtual void syncSoundSettings(); virtual void pauseEngineIntern(bool pause); diff --git a/engines/m4/m4.cpp b/engines/m4/m4.cpp index 67201c2aff..45185b3b86 100644 --- a/engines/m4/m4.cpp +++ b/engines/m4/m4.cpp @@ -141,7 +141,7 @@ M4Engine::~M4Engine() { delete _resourceManager; } -int M4Engine::init() { +Common::Error M4Engine::init() { // Initialize backend _system->beginGFXTransaction(); initCommonGFX(isM4()); @@ -197,7 +197,7 @@ int M4Engine::init() { _random = new Common::RandomSource(); g_system->getEventManager()->registerRandomSource(*_random, "m4"); - return 0; + return Common::kNoError; } void M4Engine::eventHandler() { @@ -272,14 +272,14 @@ void M4Engine::loadMenu(MenuType menuType, bool loadSaveFromHotkey, bool calledF _viewManager->moveToFront(view); } -int M4Engine::go() { +Common::Error M4Engine::go() { if (isM4()) return goM4(); else return goMADS(); } -int M4Engine::goMADS() { +Common::Error M4Engine::goMADS() { _palette->setMadsSystemPalette(); _mouse->init("cursor.ss", NULL); @@ -351,10 +351,10 @@ int M4Engine::goMADS() { g_system->delayMillis(10); } - return 0; + return Common::kNoError; } -int M4Engine::goM4() { +Common::Error M4Engine::goM4() { _script->open("m4.dat"); @@ -375,7 +375,7 @@ int M4Engine::goM4() { } #endif - return 0; + return Common::kNoError; #endif // Set up the inventory @@ -520,7 +520,7 @@ int M4Engine::goM4() { g_system->delayMillis(10); } - return 0; + return Common::kNoError; } void M4Engine::dumpFile(const char* filename, bool uncompress) { diff --git a/engines/m4/m4.h b/engines/m4/m4.h index e989bcc4e6..ac3262e7b8 100644 --- a/engines/m4/m4.h +++ b/engines/m4/m4.h @@ -107,12 +107,14 @@ FORCEINLINE long FixedDiv(long a, long b) { return (long)(((float)a / (float)b) class M4Engine : public Engine { private: - int goMADS(); - int goM4(); + Common::Error goMADS(); + Common::Error goM4(); protected: - int init(); - int go(); + // Engine APIs + virtual Common::Error init(); + virtual Common::Error go(); + void shutdown(); MidiPlayer *_midi; diff --git a/engines/made/made.cpp b/engines/made/made.cpp index dc45dc4d2f..2b7411fb3d 100644 --- a/engines/made/made.cpp +++ b/engines/made/made.cpp @@ -138,14 +138,14 @@ MadeEngine::~MadeEngine() { delete _music; } -int MadeEngine::init() { +Common::Error MadeEngine::init() { // Initialize backend _system->beginGFXTransaction(); initCommonGFX(false); _system->initSize(320, 200); _system->endGFXTransaction(); - return 0; + return Common::kNoError; } int16 MadeEngine::getTicks() { @@ -244,7 +244,7 @@ void MadeEngine::handleEvents() { } -int MadeEngine::go() { +Common::Error MadeEngine::go() { for (int i = 0; i < ARRAYSIZE(_timers); i++) _timers[i] = -1; @@ -297,7 +297,7 @@ int MadeEngine::go() { _script->runScript(_dat->getMainCodeObjectIndex()); #endif - return 0; + return Common::kNoError; } } // End of namespace Made diff --git a/engines/made/made.h b/engines/made/made.h index 971961c867..e06d0fd0b1 100644 --- a/engines/made/made.h +++ b/engines/made/made.h @@ -78,8 +78,9 @@ class MadeEngine : public ::Engine { protected: - int init(); - int go(); + // Engine APIs + virtual Common::Error init(); + virtual Common::Error go(); public: MadeEngine(OSystem *syst, const MadeGameDescription *gameDesc); diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 388675e31a..5abc308bee 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -109,7 +109,7 @@ Parallaction::~Parallaction() { } -int Parallaction::init() { +Common::Error Parallaction::init() { _engineFlags = 0; _objectsNames = NULL; @@ -145,7 +145,7 @@ int Parallaction::init() { setupBalloonManager(); - return 0; + return Common::kNoError; } void Parallaction::updateView() { diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index b1baa28530..5b56f29e94 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -228,7 +228,7 @@ public: ~Parallaction(); // Engine APIs - virtual int init(); + virtual Common::Error init(); virtual bool hasFeature(EngineFeature f) const; // info @@ -363,8 +363,8 @@ public: ~Parallaction_ns(); // Engine APIs - virtual int init(); - virtual int go(); + virtual Common::Error init(); + virtual Common::Error go(); public: virtual void parseLocation(const char *filename); @@ -451,8 +451,8 @@ public: Parallaction_br(OSystem* syst, const PARALLACTIONGameDescription *gameDesc) : Parallaction_ns(syst, gameDesc) { } ~Parallaction_br(); - int init(); - int go(); + Common::Error init(); + Common::Error go(); public: virtual void parseLocation(const char* name); diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp index 2988350cb4..fe179a0ba4 100644 --- a/engines/parallaction/parallaction_br.cpp +++ b/engines/parallaction/parallaction_br.cpp @@ -42,7 +42,7 @@ const char *Parallaction_br::_partNames[] = { "PART4" }; -int Parallaction_br::init() { +Common::Error Parallaction_br::init() { _screenWidth = 640; _screenHeight = 400; @@ -89,7 +89,7 @@ int Parallaction_br::init() { Parallaction::init(); - return 0; + return Common::kNoError; } Parallaction_br::~Parallaction_br() { @@ -102,7 +102,7 @@ void Parallaction_br::callFunction(uint index, void* parm) { (this->*_callables[index])(parm); } -int Parallaction_br::go() { +Common::Error Parallaction_br::go() { bool splash = true; @@ -127,7 +127,7 @@ int Parallaction_br::go() { cleanupGame(); } - return 0; + return Common::kNoError; } diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index a0fba08287..efb5f94b84 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -143,7 +143,7 @@ void LocationName::bind(const char *s) { -int Parallaction_ns::init() { +Common::Error Parallaction_ns::init() { _screenWidth = 320; _screenHeight = 200; @@ -193,7 +193,7 @@ int Parallaction_ns::init() { Parallaction::init(); - return 0; + return Common::kNoError; } Parallaction_ns::~Parallaction_ns() { @@ -228,7 +228,7 @@ void Parallaction_ns::callFunction(uint index, void* parm) { } -int Parallaction_ns::go() { +Common::Error Parallaction_ns::go() { _saveLoad->renameOldSavefiles(); _globalFlagsNames = _disk->loadTable("global"); @@ -239,7 +239,7 @@ int Parallaction_ns::go() { runGame(); } - return 0; + return Common::kNoError; } void Parallaction_ns::switchBackground(const char* background, const char* mask) { diff --git a/engines/queen/queen.cpp b/engines/queen/queen.cpp index 1232b12288..995c2aff60 100644 --- a/engines/queen/queen.cpp +++ b/engines/queen/queen.cpp @@ -312,9 +312,10 @@ bool QueenEngine::canLoadOrSave() const { return !_input->cutawayRunning() && !(_resource->isDemo() || _resource->isInterview()); } -int QueenEngine::saveGameState(int slot, const char *desc) { +Common::Error QueenEngine::saveGameState(int slot, const char *desc) { debug(3, "Saving game to slot %d", slot); char name[20]; + Common::Error err = Common::kNoError; makeGameStateName(slot, name); Common::OutSaveFile *file = _saveFileMan->openForSaving(name); if (file) { @@ -345,18 +346,21 @@ int QueenEngine::saveGameState(int slot, const char *desc) { // check for errors if (file->ioFailed()) { warning("Can't write file '%s'. (Disk full?)", name); + err = Common::kWritingFailed; } delete[] saveData; delete file; } else { warning("Can't create file '%s', game not saved", name); + err = Common::kCreatingFileFailed; } - return 0; + return err; } -int QueenEngine::loadGameState(int slot) { +Common::Error QueenEngine::loadGameState(int slot) { debug(3, "Loading game from slot %d", slot); + Common::Error err = Common::kNoError; GameStateHeader header; Common::InSaveFile *file = readGameStateHeader(slot, &header); if (file && header.dataSize != 0) { @@ -364,6 +368,7 @@ int QueenEngine::loadGameState(int slot) { byte *p = saveData; if (file->read(saveData, header.dataSize) != header.dataSize) { warning("Error reading savegame file"); + err = Common::kReadingFailed; } else { _bam->loadState(header.version, p); _grid->loadState(header.version, p); @@ -371,15 +376,18 @@ int QueenEngine::loadGameState(int slot) { _sound->loadState(header.version, p); if (header.dataSize != (uint32)(p - saveData)) { warning("Corrupted savegame file"); + err = Common::kReadingFailed; // FIXME } else { _logic->setupRestoredGame(); } } delete[] saveData; delete file; + } else { + err = Common::kReadingFailed; } - return 0; // TODO: return success/failure + return err; } Common::InSaveFile *QueenEngine::readGameStateHeader(int slot, GameStateHeader *gsh) { @@ -436,7 +444,7 @@ GUI::Debugger *QueenEngine::getDebugger() { return _debugger; } -int QueenEngine::go() { +Common::Error QueenEngine::go() { _logic->start(); if (ConfMan.hasKey("save_slot") && canLoadOrSave()) { loadGameState(ConfMan.getInt("save_slot")); @@ -461,10 +469,10 @@ int QueenEngine::go() { update(true); } } - return 0; + return Common::kNoError; } -int QueenEngine::init() { +Common::Error QueenEngine::init() { _system->beginGFXTransaction(); initCommonGFX(false); _system->initSize(GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT); @@ -496,7 +504,7 @@ int QueenEngine::init() { registerDefaultSettings(); readOptionSettings(); - return 0; + return Common::kNoError; } } // End of namespace Queen diff --git a/engines/queen/queen.h b/engines/queen/queen.h index df218a64a2..34ba0ab8e7 100644 --- a/engines/queen/queen.h +++ b/engines/queen/queen.h @@ -106,8 +106,8 @@ public: void update(bool checkPlayerInput = false); bool canLoadOrSave() const; - int saveGameState(int slot, const char *desc); - int loadGameState(int slot); + Common::Error saveGameState(int slot, const char *desc); + Common::Error loadGameState(int slot); void makeGameStateName(int slot, char *buf) const; int getGameStateSlot(const char *filename) const; void findGameStateDescriptions(char descriptions[100][32]); @@ -129,8 +129,8 @@ public: protected: // Engine APIs - virtual int init(); - virtual int go(); + virtual Common::Error init(); + virtual Common::Error go(); virtual GUI::Debugger *getDebugger(); virtual bool hasFeature(EngineFeature f) const; virtual void syncSoundSettings(); diff --git a/engines/saga/detection.cpp b/engines/saga/detection.cpp index d5f3659dd4..c49661a052 100644 --- a/engines/saga/detection.cpp +++ b/engines/saga/detection.cpp @@ -245,7 +245,7 @@ int SagaEngine::getDisplayHeight() const { return di.logicalHeight; } -int SagaEngine::loadGameState(int slot) { +Common::Error SagaEngine::loadGameState(int slot) { // Init the current chapter to 8 (character selection) for IHNM if (getGameType() == GType_IHNM) _scene->changeScene(-2, 0, kTransitionFade, 8); @@ -262,7 +262,7 @@ int SagaEngine::loadGameState(int slot) { load(calcSaveFileName((uint)slot)); syncSoundSettings(); - return 0; // TODO: return success/failure + return Common::kNoError; // TODO: return success/failure } } // End of namespace Saga diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp index 4ee81269d2..ee471f9330 100644 --- a/engines/saga/saga.cpp +++ b/engines/saga/saga.cpp @@ -140,7 +140,7 @@ SagaEngine::~SagaEngine() { delete _resource; } -int SagaEngine::init() { +Common::Error SagaEngine::init() { _musicVolume = ConfMan.getInt("music_volume"); _subtitlesEnabled = ConfMan.getBool("subtitles"); _readingSpeed = getTalkspeed(); @@ -156,7 +156,7 @@ int SagaEngine::init() { // Detect game and open resource files if (!initGame()) { GUIErrorMessage("Error loading game resources."); - return FAILURE; + return Common::kUnknownError; } // Initialize engine modules @@ -197,7 +197,7 @@ int SagaEngine::init() { _music->setAdlib(adlib); _render = new Render(this, _system); if (!_render->initialized()) { - return FAILURE; + return Common::kUnknownError; } // Initialize system specific sound @@ -232,10 +232,10 @@ int SagaEngine::init() { if (getGameType() == GType_ITE) _system->setFeatureState(OSystem::kFeatureAutoComputeDirtyRects, true); - return SUCCESS; + return Common::kNoError; } -int SagaEngine::go() { +Common::Error SagaEngine::go() { int msec = 0; _previousTicks = _system->getMillis(); @@ -310,7 +310,7 @@ int SagaEngine::go() { _system->delayMillis(10); } - return 0; + return Common::kNoError; } void SagaEngine::loadStrings(StringsTable &stringsTable, const byte *stringsPointer, size_t stringsLength) { diff --git a/engines/saga/saga.h b/engines/saga/saga.h index 86c91c2f3a..6563cd30d6 100644 --- a/engines/saga/saga.h +++ b/engines/saga/saga.h @@ -488,8 +488,8 @@ class SagaEngine : public Engine { public: // Engine APIs - virtual int init(); - virtual int go(); + virtual Common::Error init(); + virtual Common::Error go(); virtual bool hasFeature(EngineFeature f) const; virtual void syncSoundSettings(); @@ -652,7 +652,7 @@ public: const Common::Rect &getDisplayClip() const { return _displayClip;} int getDisplayWidth() const; int getDisplayHeight() const; - int loadGameState(int slot); + Common::Error loadGameState(int slot); bool canLoadGameStateCurrently(); bool canSaveGameStateCurrently(); const GameDisplayInfo &getDisplayInfo(); diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp index 6ca3406230..e4694cf68b 100644 --- a/engines/scumm/detection.cpp +++ b/engines/scumm/detection.cpp @@ -794,18 +794,18 @@ Common::Error ScummMetaEngine::createInstance(OSystem *syst, Engine **engine) co // Fetch the list of files in the current directory Common::FSList fslist; Common::FSNode dir(ConfMan.get("path")); - if (!dir.getChildren(fslist, Common::FSNode::kListFilesOnly)) { + if (!dir.isDirectory()) return Common::kInvalidPathError; - } + if (!dir.getChildren(fslist, Common::FSNode::kListFilesOnly)) + return Common::kNoGameDataFoundError; // Invoke the detector, but fixed to the specified gameid. Common::List results; ::detectGames(fslist, results, gameid); // Unable to locate game data - if (results.empty()) { + if (results.empty()) return Common::kNoGameDataFoundError; - } // No unique match found. If a platform override is present, try to // narrow down the list a bit more. @@ -831,9 +831,8 @@ Common::Error ScummMetaEngine::createInstance(OSystem *syst, Engine **engine) co } // Still no unique match found -> print a warning - if (results.size() > 1) { + if (results.size() > 1) warning("Engine_SCUMM_create: No unique game candidate found, using first one"); - } // Simply use the first match DetectorResult res(*(results.begin())); diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h index 8fd9122503..3b9bd40b17 100644 --- a/engines/scumm/he/intern_he.h +++ b/engines/scumm/he/intern_he.h @@ -669,8 +669,8 @@ public: ScummEngine_vCUPhe(OSystem *syst, const DetectorResult &dr); ~ScummEngine_vCUPhe(); - int init(); - int go(); + Common::Error init(); + Common::Error go(); void parseEvents(); diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp index bb8a6bac65..069302482c 100644 --- a/engines/scumm/saveload.cpp +++ b/engines/scumm/saveload.cpp @@ -75,9 +75,9 @@ struct SaveInfoSection { #pragma mark - -int ScummEngine::loadGameState(int slot) { +Common::Error ScummEngine::loadGameState(int slot) { requestLoad(slot); - return 0; + return Common::kNoError; } bool ScummEngine::canLoadGameStateCurrently() { @@ -85,9 +85,9 @@ bool ScummEngine::canLoadGameStateCurrently() { return true; } -int ScummEngine::saveGameState(int slot, const char *desc) { +Common::Error ScummEngine::saveGameState(int slot, const char *desc) { requestSave(slot, desc); - return 0; + return Common::kNoError; } bool ScummEngine::canSaveGameStateCurrently() { diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index bb22ee6381..8ee880691b 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -821,21 +821,21 @@ ScummEngine_vCUPhe::~ScummEngine_vCUPhe() { delete _cupPlayer; } -int ScummEngine_vCUPhe::init() { +Common::Error ScummEngine_vCUPhe::init() { _system->beginGFXTransaction(); _system->initSize(CUP_Player::kDefaultVideoWidth, CUP_Player::kDefaultVideoHeight); initCommonGFX(true); _system->endGFXTransaction(); - return 0; + return Common::kNoError; } -int ScummEngine_vCUPhe::go() { +Common::Error ScummEngine_vCUPhe::go() { if (_cupPlayer->open(_filenamePattern.pattern)) { _cupPlayer->play(); _cupPlayer->close(); } - return 0; + return Common::kNoError; } void ScummEngine_vCUPhe::parseEvents() { @@ -907,7 +907,7 @@ ScummEngine_v8::~ScummEngine_v8() { #pragma mark --- Initialization --- #pragma mark - -int ScummEngine::init() { +Common::Error ScummEngine::init() { // Add default file directories. if (((_game.platform == Common::kPlatformAmiga) || (_game.platform == Common::kPlatformAtariST)) && (_game.version <= 4)) { @@ -1106,7 +1106,7 @@ int ScummEngine::init() { syncSoundSettings(); - return 0; + return Common::kNoError; } void ScummEngine::setupScumm() { @@ -1712,7 +1712,7 @@ int ScummEngine::getTalkDelay() { #pragma mark --- Main loop --- #pragma mark - -int ScummEngine::go() { +Common::Error ScummEngine::go() { _engineStartTime = _system->getMillis() / 1000; // If requested, load a save game instead of running the boot script @@ -1763,7 +1763,7 @@ int ScummEngine::go() { } } - return 0; + return Common::kNoError; } void ScummEngine::waitForTimer(int msec_delay) { diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 80f5784351..582d9fdf60 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -443,16 +443,16 @@ public: virtual ~ScummEngine(); // Engine APIs - virtual int init(); - virtual int go(); + virtual Common::Error init(); + virtual Common::Error go(); virtual void errorString(const char *buf_input, char *buf_output); virtual GUI::Debugger *getDebugger(); virtual bool hasFeature(EngineFeature f) const; virtual void syncSoundSettings(); - virtual int loadGameState(int slot); + virtual Common::Error loadGameState(int slot); virtual bool canLoadGameStateCurrently(); - virtual int saveGameState(int slot, const char *desc); + virtual Common::Error saveGameState(int slot, const char *desc); virtual bool canSaveGameStateCurrently(); virtual void pauseEngineIntern(bool pause); diff --git a/engines/sky/sky.cpp b/engines/sky/sky.cpp index 1abb3d94f6..7e8250aa1f 100644 --- a/engines/sky/sky.cpp +++ b/engines/sky/sky.cpp @@ -349,7 +349,7 @@ void SkyEngine::handleKey(void) { _keyPressed.reset(); } -int SkyEngine::go() { +Common::Error SkyEngine::go() { _keyPressed.reset(); @@ -428,10 +428,10 @@ int SkyEngine::go() { _skyMusic->stopMusic(); ConfMan.flushToDisk(); delay(1500); - return 0; + return Common::kNoError; } -int SkyEngine::init() { +Common::Error SkyEngine::init() { _system->beginGFXTransaction(); initCommonGFX(false); _system->initSize(320, 200); @@ -549,7 +549,7 @@ int SkyEngine::init() { _skyMusic->setVolume(ConfMan.getInt("music_volume") >> 1); _debugger = new Debugger(_skyLogic, _skyMouse, _skyScreen, _skyCompact); - return 0; + return Common::kNoError; } void SkyEngine::initItemList() { diff --git a/engines/sky/sky.h b/engines/sky/sky.h index f3d2e564c8..47c67c743b 100644 --- a/engines/sky/sky.h +++ b/engines/sky/sky.h @@ -89,8 +89,8 @@ public: protected: // Engine APIs - virtual int init(); - virtual int go(); + virtual Common::Error init(); + virtual Common::Error go(); virtual GUI::Debugger *getDebugger(); virtual bool hasFeature(EngineFeature f) const; diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp index 9a6bfac030..7f942f3b2d 100644 --- a/engines/sword1/sword1.cpp +++ b/engines/sword1/sword1.cpp @@ -309,7 +309,7 @@ SwordEngine::~SwordEngine() { delete _resMan; } -int SwordEngine::init() { +Common::Error SwordEngine::init() { _system->beginGFXTransaction(); initCommonGFX(true); @@ -377,7 +377,7 @@ int SwordEngine::init() { _mouse->initialize(); _control = new Control(_saveFileMan, _resMan, _objectMan, _system, _mouse, _sound, _music); - return 0; + return Common::kNoError; } void SwordEngine::reinitialize(void) { @@ -719,7 +719,7 @@ void SwordEngine::checkCdFiles(void) { // check if we're running from cd, hdd or #endif } -int SwordEngine::go() { +Common::Error SwordEngine::go() { uint16 startPos = ConfMan.getInt("boot_param"); if (startPos) { _logic->startPositions(startPos); @@ -757,7 +757,7 @@ int SwordEngine::go() { } } - return 0; + return Common::kNoError; } void SwordEngine::checkCd(void) { diff --git a/engines/sword1/sword1.h b/engines/sword1/sword1.h index 8397f30705..8f77f3119a 100644 --- a/engines/sword1/sword1.h +++ b/engines/sword1/sword1.h @@ -81,8 +81,8 @@ public: uint32 _features; protected: // Engine APIs - virtual int init(); - virtual int go(); + virtual Common::Error init(); + virtual Common::Error go(); virtual bool hasFeature(EngineFeature f) const; virtual void syncSoundSettings(); diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp index c596e2f8c0..f1f880c11e 100644 --- a/engines/sword2/sword2.cpp +++ b/engines/sword2/sword2.cpp @@ -218,7 +218,7 @@ Common::Error Sword2MetaEngine::createInstance(OSystem *syst, Engine **engine) c Common::FSList fslist; Common::FSNode dir(ConfMan.get("path")); if (!dir.getChildren(fslist, Common::FSNode::kListAll)) { - return Common::kInvalidPathError; + return Common::kNoGameDataFoundError; } // Invoke the detector @@ -349,7 +349,7 @@ void Sword2Engine::setupPersistentResources() { _resman->openResource(CUR_PLAYER_ID); } -int Sword2Engine::init() { +Common::Error Sword2Engine::init() { // Get some falling RAM and put it in your pocket, never let it slip // away @@ -378,7 +378,7 @@ int Sword2Engine::init() { _resman = new ResourceManager(this); if (!_resman->init()) - return 1; + return Common::kUnknownError; _logic = new Logic(this); _fontRenderer = new FontRenderer(this); @@ -426,7 +426,7 @@ int Sword2Engine::init() { // will either have killed the music, or done a crossfade. if (shouldQuit()) - return 0; + return Common::kNoError; if (result) startGame(); @@ -435,10 +435,10 @@ int Sword2Engine::init() { _screen->initialiseRenderCycle(); - return 0; + return Common::kNoError; } -int Sword2Engine::go() { +Common::Error Sword2Engine::go() { while (1) { if (_debugger->isAttached()) _debugger->onFrame(); @@ -514,7 +514,7 @@ int Sword2Engine::go() { #endif } - return 0; + return Common::kNoError; } void Sword2Engine::restartGame() { diff --git a/engines/sword2/sword2.h b/engines/sword2/sword2.h index 06d6292ec2..172dcea35c 100644 --- a/engines/sword2/sword2.h +++ b/engines/sword2/sword2.h @@ -127,8 +127,8 @@ public: ~Sword2Engine(); // Engine APIs - virtual int init(); - virtual int go(); + virtual Common::Error init(); + virtual Common::Error go(); virtual GUI::Debugger *getDebugger(); virtual bool hasFeature(EngineFeature f) const; virtual void pauseEngineIntern(bool pause); diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp index 1ac36efb13..e876fbc40c 100644 --- a/engines/tinsel/tinsel.cpp +++ b/engines/tinsel/tinsel.cpp @@ -658,7 +658,7 @@ TinselEngine::~TinselEngine() { delete _scheduler; } -int TinselEngine::init() { +Common::Error TinselEngine::init() { // Initialize backend _system->beginGFXTransaction(); initCommonGFX(false); @@ -707,7 +707,7 @@ int TinselEngine::init() { // Actors, globals and inventory icons LoadBasicChunks(); - return 0; + return Common::kNoError; } Common::String TinselEngine::getSavegameFilename(int16 saveNum) const { @@ -718,7 +718,7 @@ Common::String TinselEngine::getSavegameFilename(int16 saveNum) const { #define GAME_FRAME_DELAY (1000 / ONE_SECOND) -int TinselEngine::go() { +Common::Error TinselEngine::go() { uint32 timerVal = 0; // Continuous game processes @@ -774,7 +774,7 @@ int TinselEngine::go() { // Write configuration WriteConfig(); - return 0; + return Common::kNoError; } diff --git a/engines/tinsel/tinsel.h b/engines/tinsel/tinsel.h index 9820be7ddd..080e539f69 100644 --- a/engines/tinsel/tinsel.h +++ b/engines/tinsel/tinsel.h @@ -91,8 +91,9 @@ class TinselEngine : public Engine { protected: - int init(); - int go(); + // Engine APIs + virtual Common::Error init(); + virtual Common::Error go(); public: TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc); diff --git a/engines/touche/menu.cpp b/engines/touche/menu.cpp index 2d7af18da3..fbc73d027e 100644 --- a/engines/touche/menu.cpp +++ b/engines/touche/menu.cpp @@ -331,14 +331,14 @@ void ToucheEngine::handleMenuAction(void *menu, int actionId) { break; case kActionPerformSaveLoad: if (menuData->mode == kMenuLoadStateMode) { - if (loadGameState(_saveLoadCurrentSlot) == 0) { + if (loadGameState(_saveLoadCurrentSlot) == Common::kNoError) { menuData->quit = true; } } else if (menuData->mode == kMenuSaveStateMode) { _system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false); const char *description = menuData->saveLoadDescriptionsTable[_saveLoadCurrentSlot]; if (strlen(description) > 0) { - if (saveGameState(_saveLoadCurrentSlot, description)) { + if (saveGameState(_saveLoadCurrentSlot, description) == Common::kNoError) { menuData->quit = true; } } diff --git a/engines/touche/saveload.cpp b/engines/touche/saveload.cpp index 0890d4688f..5d63d45bb5 100644 --- a/engines/touche/saveload.cpp +++ b/engines/touche/saveload.cpp @@ -316,7 +316,7 @@ void ToucheEngine::loadGameStateData(Common::ReadStream *stream) { debug(0, "Loaded state, current episode %d", _currentEpisodeNum); } -int ToucheEngine::saveGameState(int num, const char *description) { +Common::Error ToucheEngine::saveGameState(int num, const char *description) { bool saveOk = false; char gameStateFileName[64]; generateGameStateFileName(num, gameStateFileName, 63); @@ -337,10 +337,10 @@ int ToucheEngine::saveGameState(int num, const char *description) { } delete f; } - return saveOk; + return saveOk ? Common::kNoError : Common::kUnknownError; } -int ToucheEngine::loadGameState(int num) { +Common::Error ToucheEngine::loadGameState(int num) { bool loadOk = false; char gameStateFileName[64]; generateGameStateFileName(num, gameStateFileName, 63); @@ -360,7 +360,7 @@ int ToucheEngine::loadGameState(int num) { } delete f; } - return loadOk ? 0 : 1; + return loadOk ? Common::kNoError : Common::kUnknownError; } void ToucheEngine::readGameStateDescription(int num, char *description, int len) { diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp index 26170e2734..0033d80cb2 100644 --- a/engines/touche/touche.cpp +++ b/engines/touche/touche.cpp @@ -81,7 +81,7 @@ ToucheEngine::~ToucheEngine() { delete _midiPlayer; } -int ToucheEngine::init() { +Common::Error ToucheEngine::init() { _system->beginGFXTransaction(); initCommonGFX(true); _system->initSize(kScreenWidth, kScreenHeight); @@ -96,10 +96,10 @@ int ToucheEngine::init() { _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume")); - return 0; + return Common::kNoError; } -int ToucheEngine::go() { +Common::Error ToucheEngine::go() { res_openDataFile(); res_allocateTables(); res_loadSpriteImage(18, _menuKitData); @@ -111,7 +111,7 @@ int ToucheEngine::go() { res_deallocateTables(); res_closeDataFile(); - return 0; + return Common::kNoError; } void ToucheEngine::restart() { diff --git a/engines/touche/touche.h b/engines/touche/touche.h index 9d66d839a0..b5256a9d8f 100644 --- a/engines/touche/touche.h +++ b/engines/touche/touche.h @@ -362,8 +362,8 @@ public: virtual ~ToucheEngine(); // Engine APIs - virtual int init(); - virtual int go(); + virtual Common::Error init(); + virtual Common::Error go(); virtual bool hasFeature(EngineFeature f) const; virtual void syncSoundSettings(); @@ -497,8 +497,8 @@ protected: void saveGameStateData(Common::WriteStream *stream); void loadGameStateData(Common::ReadStream *stream); - int saveGameState(int num, const char *description); - int loadGameState(int num); + Common::Error saveGameState(int num, const char *description); + Common::Error loadGameState(int num); void readGameStateDescription(int num, char *description, int len); void generateGameStateFileName(int num, char *dst, int len, bool prefixOnly = false) const; int getGameStateFileSlot(const char *filename) const; -- cgit v1.2.3