From 44943e1285f128dc1975789b937dd6540bbaa301 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sun, 25 Jun 2017 11:35:32 +0200 Subject: [PATCH] MOHAWK: Change the delay function not to have an event loop Fixes events getting lost during delays --- engines/mohawk/riven.cpp | 14 ++------------ engines/mohawk/riven.h | 2 +- engines/mohawk/riven_scripts.cpp | 3 +-- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp index 52784e58e453..0288266daf11 100644 --- a/engines/mohawk/riven.cpp +++ b/engines/mohawk/riven.cpp @@ -447,21 +447,11 @@ Common::SeekableReadStream *MohawkEngine_Riven::getExtrasResource(uint32 tag, ui return _extrasFile->getResource(tag, id); } -void MohawkEngine_Riven::delayAndUpdate(uint32 ms) { +void MohawkEngine_Riven::delay(uint32 ms) { uint32 startTime = _system->getMillis(); while (_system->getMillis() < startTime + ms && !shouldQuit()) { - _sound->updateSLST(); - _stack->onFrame(); - _video->updateMovies(); - - Common::Event event; - while (_system->getEventManager()->pollEvent(event)) - ; - - _system->updateScreen(); - - _system->delayMillis(10); // Ease off the CPU + doFrame(); } } diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h index 1cb8d9dbdf52..32863d6ecff1 100644 --- a/engines/mohawk/riven.h +++ b/engines/mohawk/riven.h @@ -152,7 +152,7 @@ class MohawkEngine_Riven : public MohawkEngine { bool _activatedPLST; bool _activatedSLST; void runLoadDialog(); - void delayAndUpdate(uint32 ms); + void delay(uint32 ms); // Timer void installTimer(TimerProc *proc, uint32 time); diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp index e6ebd6e281e9..9cb6a04b1bad 100644 --- a/engines/mohawk/riven_scripts.cpp +++ b/engines/mohawk/riven_scripts.cpp @@ -462,13 +462,12 @@ void RivenSimpleCommand::stopSound(uint16 op, uint16 argc, uint16 *argv) { // Command 13: set mouse cursor (cursor_id) void RivenSimpleCommand::changeCursor(uint16 op, uint16 argc, uint16 *argv) { _vm->_cursor->setCursor(argv[0]); - _vm->_system->updateScreen(); } // Command 14: pause script execution (delay in ms, u1) void RivenSimpleCommand::delay(uint16 op, uint16 argc, uint16 *argv) { if (argv[0] > 0) - _vm->delayAndUpdate(argv[0]); + _vm->delay(argv[0]); } // Command 17: call external command