From f2f6c75ba575cf40fdd0bb0842a359f24355c78b Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Sat, 13 Mar 2004 17:41:36 +0000 Subject: fix for voice bundle bug in german version comi svn-id: r13260 --- scumm/imuse_digi/dimuse_bndmgr.cpp | 8 +++++++- scumm/imuse_digi/dimuse_bndmgr.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/scumm/imuse_digi/dimuse_bndmgr.cpp b/scumm/imuse_digi/dimuse_bndmgr.cpp index 4e6f2a5632..49dc33169f 100644 --- a/scumm/imuse_digi/dimuse_bndmgr.cpp +++ b/scumm/imuse_digi/dimuse_bndmgr.cpp @@ -117,6 +117,7 @@ BundleMgr::BundleMgr(BundleDirCache *cache) { _bundleTable = NULL; _compTable = NULL; _numFiles = 0; + _numCompItems = 0; _curSample = -1; _fileBundleId = -1; } @@ -150,6 +151,7 @@ void BundleMgr::closeFile() { _file.close(); _bundleTable = NULL; _numFiles = 0; + _numCompItems = 0; _compTableLoaded = false; _lastBlock = -1; _lastCacheOutputSize = 0; @@ -179,7 +181,7 @@ int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size, if (!_compTableLoaded) { _file.seek(_bundleTable[index].offset, SEEK_SET); tag = _file.readUint32BE(); - num = _file.readUint32BE(); + _numCompItems = num = _file.readUint32BE(); _file.readUint32BE(); _file.readUint32BE(); @@ -201,6 +203,10 @@ int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size, first_block = (offset + header_size) / 0x2000; last_block = (offset + size + header_size - 1) / 0x2000; + // workaround for bug when (offset + size + header_size - 1) is more one byte after sound resource + if ((last_block >= _numCompItems) && (_numCompItems > 0)) + last_block = _numCompItems - 1; + comp_output = (byte *)malloc(0x2000); int32 blocks_final_size = 0x2000 * (1 + last_block - first_block); *comp_final = (byte *)malloc(blocks_final_size); diff --git a/scumm/imuse_digi/dimuse_bndmgr.h b/scumm/imuse_digi/dimuse_bndmgr.h index b30c8f9c38..a8819a500e 100644 --- a/scumm/imuse_digi/dimuse_bndmgr.h +++ b/scumm/imuse_digi/dimuse_bndmgr.h @@ -64,6 +64,7 @@ private: BundleDirCache::AudioTable *_bundleTable; CompTable *_compTable; int32 _numFiles; + int32 _numCompItems; int32 _curSample; File _file; bool _compTableLoaded; -- cgit v1.2.3