From b5c552b3bb7f6cd18c493dc23b678135c86a12e7 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 29 Aug 2017 09:33:14 +0200 Subject: WAGE: Quit gracefully when requested --- engines/wage/script.cpp | 2 +- engines/wage/wage.cpp | 8 ++++++-- engines/wage/wage.h | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'engines/wage') diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp index 3405c8bf47..bff75d06bd 100644 --- a/engines/wage/script.cpp +++ b/engines/wage/script.cpp @@ -165,7 +165,7 @@ bool Script::execute(World *world, int loopCount, Common::String *inputText, Des } _data->seek(12); - while (_data->pos() < _data->size()) { + while (_data->pos() < _data->size() && !_engine->_shouldQuit) { printLine(_data->pos()); byte command = _data->readByte(); diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp index 7f9fb073f5..ce47e3ebea 100644 --- a/engines/wage/wage.cpp +++ b/engines/wage/wage.cpp @@ -123,6 +123,8 @@ Common::Error WageEngine::run() { if (!_world->loadWorld(_resManager)) return Common::kNoGameDataFoundError; + _shouldQuit = false; + _gui = new Gui(this); _temporarilyHidden = true; @@ -140,8 +142,6 @@ Common::Error WageEngine::run() { processTurn(&input, NULL); _temporarilyHidden = false; - _shouldQuit = false; - while (!_shouldQuit) { _debugger->onFrame(); @@ -445,6 +445,10 @@ void WageEngine::processTurnInternal(Common::String *textInput, Designed *clickI regen(); Common::String input("look"); processTurnInternal(&input, NULL); + + if (_shouldQuit) + return; + redrawScene(); _temporarilyHidden = false; } else if (_loopCount == 1) { diff --git a/engines/wage/wage.h b/engines/wage/wage.h index d2c97adfa0..51a6951d9f 100644 --- a/engines/wage/wage.h +++ b/engines/wage/wage.h @@ -192,6 +192,8 @@ public: bool _isGameOver; bool _commandWasQuick; + bool _shouldQuit; + Common::String _inputText; void playSound(Common::String soundName); @@ -234,8 +236,6 @@ private: Common::MacResManager *_resManager; - bool _shouldQuit; - Audio::SoundHandle _soundHandle; }; -- cgit v1.2.3