From 5b3a6fac639505819f9077a52cea7225b09ebd0c Mon Sep 17 00:00:00 2001 From: Florian Kagerer Date: Sun, 1 Jun 2008 13:19:45 +0000 Subject: - (hopefully) fix valgrind warning for installer file decompression - some more pauseEngineIntern code for Hof svn-id: r32462 --- engines/kyra/kyra_hof.cpp | 7 ++++++- engines/kyra/resource.cpp | 14 +++++++++----- engines/kyra/script_tim.cpp | 7 +++++++ engines/kyra/script_tim.h | 1 + 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/engines/kyra/kyra_hof.cpp b/engines/kyra/kyra_hof.cpp index 14bbc574fc..57f0dcc24a 100644 --- a/engines/kyra/kyra_hof.cpp +++ b/engines/kyra/kyra_hof.cpp @@ -206,7 +206,12 @@ void KyraEngine_HoF::pauseEngineIntern(bool pause) { _activeWSA[x].nextFrame += pausedTime; } - // TODO: item animation, idle animation, tim player, etc + _nextIdleAnim += pausedTime; + + for (int x = 0; x < _itemAnimDataSize; x++) + _activeItemAnim[x].nextFrame += pausedTime; + + _tim->refreshTimersAfterPause(pausedTime); } } diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp index 73ff591792..04cfcf879a 100644 --- a/engines/kyra/resource.cpp +++ b/engines/kyra/resource.cpp @@ -795,7 +795,7 @@ Common::SeekableReadStream *ResLoaderTlk::loadFileFromArchive(const Common::Stri class FileExpanderSource { public: - FileExpanderSource(const uint8 *data) : _dataPtr(data), _bitsLeft(8), _key(0), _index(0) {} + FileExpanderSource(const uint8 *data, int dataSize) : _dataPtr(data), _endofBuffer(data + dataSize), _bitsLeft(8), _key(0), _index(0) {} ~FileExpanderSource() {} void advSrcRefresh(); @@ -811,6 +811,7 @@ public: private: const uint8 *_dataPtr; + const uint8 *_endofBuffer; uint16 _key; int8 _bitsLeft; uint8 _index; @@ -819,7 +820,8 @@ private: void FileExpanderSource::advSrcBitsBy1() { _key >>= 1; if (!--_bitsLeft) { - _key = ((*_dataPtr++) << 8 ) | (_key & 0xff); + if (_dataPtr < _endofBuffer) + _key = ((*_dataPtr++) << 8 ) | (_key & 0xff); _bitsLeft = 8; } } @@ -831,7 +833,8 @@ void FileExpanderSource::advSrcBitsByIndex(uint8 newIndex) { _key >>= (_index + _bitsLeft); _index = -_bitsLeft; _bitsLeft = 8 - _index; - _key = (*_dataPtr++ << 8) | (_key & 0xff); + if (_dataPtr < _endofBuffer) + _key = (*_dataPtr++ << 8) | (_key & 0xff); } _key >>= _index; } @@ -880,7 +883,8 @@ uint16 FileExpanderSource::keyMaskedAlign(uint16 val) { void FileExpanderSource::advSrcRefresh() { _key = READ_LE_UINT16(_dataPtr); - _dataPtr += 2; + if (_dataPtr < _endofBuffer - 1) + _dataPtr += 2; _bitsLeft = 8; } @@ -937,7 +941,7 @@ bool FileExpander::process(uint8 *dst, const uint8 *src, uint32 outsize, uint32 bool needrefresh = true; bool postprocess = false; - _src = new FileExpanderSource(src); + _src = new FileExpanderSource(src, compressedSize); while (d < dst + outsize) { diff --git a/engines/kyra/script_tim.cpp b/engines/kyra/script_tim.cpp index 66390047b4..812e867c53 100644 --- a/engines/kyra/script_tim.cpp +++ b/engines/kyra/script_tim.cpp @@ -184,6 +184,13 @@ void TIMInterpreter::exec(TIM *tim, bool loop) { } while (loop); } +void TIMInterpreter::refreshTimersAfterPause(uint32 elapsedTime) { + for (int i = 0; i < 10; i++) { + _currentTim->func[i].lastTime += elapsedTime; + _currentTim->func[i].nextTime += elapsedTime; + } +} + int TIMInterpreter::execCommand(int cmd, const uint16 *param) { if (cmd < 0 || cmd >= _commandsSize) { warning("Calling unimplemented TIM command %d", cmd); diff --git a/engines/kyra/script_tim.h b/engines/kyra/script_tim.h index 957bffcc3c..7d5fe15b28 100644 --- a/engines/kyra/script_tim.h +++ b/engines/kyra/script_tim.h @@ -69,6 +69,7 @@ public: void stopCurFunc() { if (_currentTim) cmd_stopCurFunc(0); } void play(const char *filename); + void refreshTimersAfterPause(uint32 elapsedTime); private: KyraEngine_v1 *_vm; OSystem *_system; -- cgit v1.2.3