From 5b63e29d5e2ff4710cf4d417474b607d84317dee Mon Sep 17 00:00:00 2001 From: Borja Lorente Date: Thu, 4 Aug 2016 10:56:51 +0200 Subject: MACVENTURE: Clean up updateState function --- engines/macventure/macventure.cpp | 34 ++++++++++++---------------------- engines/macventure/macventure.h | 6 +++--- engines/macventure/script.cpp | 11 +++++------ engines/macventure/script.h | 2 +- 4 files changed, 21 insertions(+), 32 deletions(-) (limited to 'engines') diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp index 6ed11eb9c7..867504b427 100644 --- a/engines/macventure/macventure.cpp +++ b/engines/macventure/macventure.cpp @@ -160,20 +160,18 @@ Common::Error MacVentureEngine::run() { _prepared = false; if (!_halted) - updateState(); + updateState(false); if (_cmdReady || _halted) { _halted = false; if (runScriptEngine()) { _halted = true; _paused = true; - } - else { + } else { _paused = false; - if (!updateState()) { - updateControls(); - updateExits(); - } + updateState(true); + updateControls(); + updateExits(); } } @@ -485,8 +483,7 @@ bool MacVenture::MacVentureEngine::runScriptEngine() { _haltedInSelection = true; return true; } - if (updateState()) - return true; + updateState(true); } while (!_currentSelection.empty()) { @@ -497,9 +494,7 @@ bool MacVenture::MacVentureEngine::runScriptEngine() { _haltedInSelection = true; return true; } - if (updateState()) { - return true; - } + updateState(true); } } if (_selectedControl == 1) @@ -518,12 +513,10 @@ void MacVentureEngine::endGame() { requestQuit(); } -bool MacVentureEngine::updateState() { +void MacVentureEngine::updateState(bool pause) { runObjQueue(); - bool wait = printTexts(); - // HACK playSounds should accept a bool passed to updateState - wait |= playSounds(true); - return wait; + printTexts(); + playSounds(pause); } void MacVentureEngine::revert() { @@ -575,7 +568,7 @@ void MacVentureEngine::runObjQueue() { } } -bool MacVentureEngine::printTexts() { +void MacVentureEngine::printTexts() { for (uint i = 0; i < _textQueue.size(); i++) { QueuedText text = _textQueue.front(); _textQueue.remove_at(0); @@ -594,10 +587,9 @@ bool MacVentureEngine::printTexts() { break; } } - return false; } -bool MacVentureEngine::playSounds(bool pause) { +void MacVentureEngine::playSounds(bool pause) { int delay=0; while (!_soundQueue.empty()) { QueuedSound item = _soundQueue.front(); @@ -618,9 +610,7 @@ bool MacVentureEngine::playSounds(bool pause) { warning("Sound pausing not yet tested. Pausing for %d", delay * 1000); g_system->delayMillis(delay * 1000); preparedToRun(); - return true; } - return false; } void MacVentureEngine::updateControls() { diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h index 6953b61904..275a7ac1a7 100644 --- a/engines/macventure/macventure.h +++ b/engines/macventure/macventure.h @@ -210,7 +210,7 @@ public: void loseGame(); void clickToContinue(); - bool updateState(); + void updateState(bool pause); void revert(); void enqueueObject(ObjectQueueID type, ObjID objID, ObjID target = 0); @@ -218,8 +218,8 @@ public: void enqueueSound(SoundQueueID type, ObjID target); void runObjQueue(); - bool printTexts(); - bool playSounds(bool pause); + void printTexts(); + void playSounds(bool pause); void handleObjectSelect(ObjID objID, WindowReference win, bool shiftPressed, bool isDoubleClick); void handleObjectDrop(ObjID objID, Common::Point delta, ObjID newParent); diff --git a/engines/macventure/script.cpp b/engines/macventure/script.cpp index 6f0a7820b3..ef1d36cbae 100644 --- a/engines/macventure/script.cpp +++ b/engines/macventure/script.cpp @@ -453,8 +453,7 @@ bool ScriptEngine::runFunc(EngineFrame *frame) { opdbROBQ(state, frame); break; case 0xdc: //run sound queue - if (opdcRSQ(state, frame)) - return true; + opdcRSQ(state, frame); break; case 0xdd: //run text queue opddRTQ(state, frame); @@ -1102,7 +1101,7 @@ void ScriptEngine::opd9SLEEP(EngineState * state, EngineFrame * frame) { } void ScriptEngine::opdaCLICK(EngineState * state, EngineFrame * frame) { - _engine->updateState(); + _engine->updateState(false); _engine->clickToContinue(); } @@ -1110,8 +1109,8 @@ void ScriptEngine::opdbROBQ(EngineState * state, EngineFrame * frame) { _engine->runObjQueue(); } -bool ScriptEngine::opdcRSQ(EngineState * state, EngineFrame * frame) { - return _engine->playSounds(true); +void ScriptEngine::opdcRSQ(EngineState * state, EngineFrame * frame) { + _engine->playSounds(true); } void ScriptEngine::opddRTQ(EngineState * state, EngineFrame * frame) { @@ -1119,7 +1118,7 @@ void ScriptEngine::opddRTQ(EngineState * state, EngineFrame * frame) { } void ScriptEngine::opdeUPSC(EngineState * state, EngineFrame * frame) { - _engine->updateState(); + _engine->updateState(true); } void ScriptEngine::opdfFMAI(EngineState * state, EngineFrame * frame) { diff --git a/engines/macventure/script.h b/engines/macventure/script.h index 7c4b77df75..5760a31e8a 100644 --- a/engines/macventure/script.h +++ b/engines/macventure/script.h @@ -257,7 +257,7 @@ private: void opd9SLEEP(EngineState *state, EngineFrame *frame); //sleep void opdaCLICK(EngineState *state, EngineFrame *frame); //click to continue void opdbROBQ(EngineState *state, EngineFrame *frame); //run queue - bool opdcRSQ(EngineState *state, EngineFrame *frame); //run sound queue + void opdcRSQ(EngineState *state, EngineFrame *frame); //run sound queue void opddRTQ(EngineState *state, EngineFrame *frame); //run text queue void opdeUPSC(EngineState *state, EngineFrame *frame); //update screen void opdfFMAI(EngineState *state, EngineFrame *frame); //flash main window -- cgit v1.2.3