diff options
author | Martin Kiewitz | 2016-02-03 03:07:50 +0100 |
---|---|---|
committer | Martin Kiewitz | 2016-02-03 03:07:50 +0100 |
commit | cc55cb13d3a673b21691c0fab58cf1385c7998e8 (patch) | |
tree | 1f604bc78b3807a8c1038a54611c756086e58ff2 /engines | |
parent | 34117170f2955e854a93925a652af37575361b44 (diff) | |
download | scummvm-rg350-cc55cb13d3a673b21691c0fab58cf1385c7998e8.tar.gz scummvm-rg350-cc55cb13d3a673b21691c0fab58cf1385c7998e8.tar.bz2 scummvm-rg350-cc55cb13d3a673b21691c0fab58cf1385c7998e8.zip |
AGI: Remove _game.state, not needed anymore
Diffstat (limited to 'engines')
-rw-r--r-- | engines/agi/agi.cpp | 45 | ||||
-rw-r--r-- | engines/agi/agi.h | 10 | ||||
-rw-r--r-- | engines/agi/cycle.cpp | 2 | ||||
-rw-r--r-- | engines/agi/saveload.cpp | 5 |
4 files changed, 22 insertions, 40 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index 401c42a76a..79047b0b84 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -207,6 +207,9 @@ void AgiEngine::agiUnloadResources() { int AgiEngine::agiDeinit() { int ec; + if (!_loader) + return errOK; + _words->clearEgoWords(); // remove all words from memory agiUnloadResources(); // unload resources in memory _loader->unloadResource(RESOURCETYPE_LOGIC, 0); @@ -332,7 +335,6 @@ const byte *AgiBase::getFontData() { } AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBase(syst, gameDesc) { - // Setup mixer syncSoundSettings(); @@ -365,8 +367,6 @@ AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBas _game.gfxMode = true; - _game.state = STATE_INIT; - _keyQueueStart = 0; _keyQueueEnd = 0; @@ -391,14 +391,17 @@ AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBas memset(_keyQueue, 0, sizeof(_keyQueue)); - _text = NULL; - _sprites = NULL; - _picture = NULL; - _loader = NULL; - _console = NULL; - _menu = NULL; - _gfx = NULL; - _systemUI = NULL; + _console = nullptr; + _font = nullptr; + _gfx = nullptr; + _sound = nullptr; + _picture = nullptr; + _sprites = nullptr; + _text = nullptr; + _loader = nullptr; + _menu = nullptr; + _systemUI = nullptr; + _inventory = nullptr; _egoHoldKey = false; } @@ -467,7 +470,6 @@ void AgiEngine::initialize() { debugC(2, kDebugLevelMain, "Detect game"); if (agiDetectGame() == errOK) { - _game.state = STATE_LOADED; debugC(2, kDebugLevelMain, "game loaded"); } else { warning("Could not open AGI game"); @@ -504,19 +506,14 @@ void AgiEngine::adjustPosToGameScreen(int16 &x, int16 &y) { } AgiEngine::~AgiEngine() { - // If the engine hasn't been initialized yet via - // AgiEngine::initialize(), don't attempt to free any resources, as - // they haven't been allocated. Fixes bug #1742432 - AGI: Engine - // crashes if no game is detected - if (_game.state == STATE_INIT) { - return; - } - agiDeinit(); delete _loader; - _gfx->deinitVideo(); + if (_gfx) { + _gfx->deinitVideo(); + } delete _inventory; delete _systemUI; + delete _menu; delete _text; delete _sprites; delete _picture; @@ -540,12 +537,6 @@ Common::Error AgiEngine::go() { } inGameTimerReset(); - if (_game.state < STATE_LOADED) { - do { - processAGIEvents(); - } while (_game.state < STATE_RUNNING); - } - runGame(); return Common::kNoError; diff --git a/engines/agi/agi.h b/engines/agi/agi.h index 5d14850509..ca539c9445 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -394,12 +394,6 @@ enum CycleInnerLoopType { CYCLE_INNERLOOP_HAVEKEY = 7 }; -enum State { - STATE_INIT = 0x00, - STATE_LOADED = 0x01, - STATE_RUNNING = 0x02 -}; - typedef Common::Array<int16> SavedGameSlotIdArray; /** @@ -410,8 +404,6 @@ typedef Common::Array<int16> SavedGameSlotIdArray; struct AgiGame { AgiEngine *_vm; - State state; /**< state of the interpreter */ - // TODO: Check whether adjMouseX and adjMouseY must be saved and loaded when using savegames. // If they must be then loading and saving is partially broken at the moment. int adjMouseX; /**< last given adj.ego.move.to.x.y-command's 1st parameter */ @@ -734,6 +726,8 @@ public: void adjustPosToGameScreen(int16 &x, int16 &y); private: + bool initialized; + int _keyQueue[KEY_QUEUE_SIZE]; int _keyQueueStart; int _keyQueueEnd; diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp index 630a91a93a..2758e5208b 100644 --- a/engines/agi/cycle.cpp +++ b/engines/agi/cycle.cpp @@ -440,9 +440,7 @@ int AgiEngine::runGame() { setVar(VM_VAR_MAX_INPUT_CHARACTERS, 38); _text->promptDisable(); - _game.state = STATE_RUNNING; ec = playGame(); - _game.state = STATE_LOADED; agiDeinit(); } while (_restartGame); diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp index b39f1c7320..c2d9de8bb2 100644 --- a/engines/agi/saveload.cpp +++ b/engines/agi/saveload.cpp @@ -110,8 +110,7 @@ int AgiEngine::saveGame(const Common::String &fileName, const Common::String &de out->writeUint32BE(playTime); debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing play time (%d)", playTime); - out->writeByte(_game.state); - debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing game state (%d)", _game.state); + out->writeByte(2); // was _game.state, 2 = STATE_RUNNING strcpy(gameIDstring, _game.id); out->write(gameIDstring, 8); @@ -387,7 +386,7 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) { } } - _game.state = (State)in->readByte(); + in->readByte(); // was _game.state, not needed anymore in->read(loadId, 8); if (strcmp(loadId, _game.id) != 0 && checkId) { |