diff options
-rw-r--r-- | engines/lure/game.cpp | 3 | ||||
-rw-r--r-- | engines/lure/res_struct.cpp | 19 |
2 files changed, 10 insertions, 12 deletions
diff --git a/engines/lure/game.cpp b/engines/lure/game.cpp index c87f81618a..f9b31c21c5 100644 --- a/engines/lure/game.cpp +++ b/engines/lure/game.cpp @@ -167,6 +167,7 @@ void Game::execute() { if (system.getMillis() > timerVal + GAME_FRAME_DELAY) { timerVal = system.getMillis(); nextFrame(); + res.delayList().tick(); Sound.musicInterface_ContinuePlaying(); } @@ -177,8 +178,6 @@ void Game::execute() { tickCheck(); } - res.delayList().tick(); - while (events.pollEvent()) { if (events.type() == Common::EVENT_KEYDOWN) { uint16 roomNum = room.roomNumber(); diff --git a/engines/lure/res_struct.cpp b/engines/lure/res_struct.cpp index 913505c8c9..f3ec7821eb 100644 --- a/engines/lure/res_struct.cpp +++ b/engines/lure/res_struct.cpp @@ -762,8 +762,8 @@ RoomExitCoordinateData &RoomExitCoordinates::getData(uint16 destRoomNumber) { SequenceDelayData::SequenceDelayData(uint16 delay, uint16 seqOffset, bool canClearFlag) { OSystem &system = *g_system; - // The delay is in number of seconds - timeoutCtr = system.getMillis() + delay * 1000; + // The delay is in number of seconds - convert it to remaining milliseconds + timeoutCtr = delay * 1000; sequenceOffset = seqOffset; canClear = canClearFlag; } @@ -784,21 +784,23 @@ void SequenceDelayList::add(uint16 delay, uint16 seqOffset, bool canClear) { } void SequenceDelayList::tick() { - uint32 currTime = g_system->getMillis(); SequenceDelayList::iterator i; - debugC(ERROR_DETAILED, kLureDebugScripts, "Delay List check start at time %d", currTime); + debugC(ERROR_DETAILED, kLureDebugScripts, "Delay List check start at time %d", + g_system->getMillis()); for (i = begin(); i != end(); i++) { SequenceDelayData *entry = (*i).get(); debugC(ERROR_DETAILED, kLureDebugScripts, "Delay List check %xh at time %d", entry->sequenceOffset, entry->timeoutCtr); - if (currTime >= entry->timeoutCtr) { + if (entry->timeoutCtr <= GAME_FRAME_DELAY) { // Timeout reached - delete entry from list and execute the sequence uint16 seqOffset = entry->sequenceOffset; erase(i); Script::execute(seqOffset); return; + } else { + entry->timeoutCtr -= GAME_FRAME_DELAY; } } } @@ -816,14 +818,12 @@ void SequenceDelayList::clear(bool forceClear) { } void SequenceDelayList::saveToStream(WriteStream *stream) { - uint32 currTime = g_system->getMillis(); SequenceDelayList::iterator i; for (i = begin(); i != end(); ++i) { SequenceDelayData *entry = (*i).get(); stream->writeUint16LE(entry->sequenceOffset); - stream->writeUint32LE((currTime > entry->timeoutCtr ) ? 0 : - entry->timeoutCtr - currTime); + stream->writeUint32LE(entry->timeoutCtr); stream->writeByte(entry->canClear); } @@ -833,10 +833,9 @@ void SequenceDelayList::saveToStream(WriteStream *stream) { void SequenceDelayList::loadFromStream(ReadStream *stream) { clear(true); uint16 seqOffset; - uint32 currTime = g_system->getMillis(); while ((seqOffset = stream->readUint16LE()) != 0) { - uint32 delay = currTime + stream->readUint32LE(); + uint32 delay = stream->readUint32LE(); bool canClear = stream->readByte() != 0; push_back(SequenceDelayList::value_type(SequenceDelayData::load(delay, seqOffset, canClear))); } |