Skip to content

Commit

Permalink
MOHAWK: Change the delay function not to have an event loop
Browse files Browse the repository at this point in the history
Fixes events getting lost during delays
  • Loading branch information
bgK authored and sev- committed Jul 3, 2017
1 parent f977b57 commit 44943e1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
14 changes: 2 additions & 12 deletions engines/mohawk/riven.cpp
Expand Up @@ -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();
}
}

Expand Down
2 changes: 1 addition & 1 deletion engines/mohawk/riven.h
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions engines/mohawk/riven_scripts.cpp
Expand Up @@ -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
Expand Down

0 comments on commit 44943e1

Please sign in to comment.