diff options
author | Paul Gilbert | 2017-02-09 19:54:13 -0500 |
---|---|---|
committer | Paul Gilbert | 2017-02-09 19:54:13 -0500 |
commit | c2b3abd676a194138849252a3e37d6cb977a343c (patch) | |
tree | a84366294ce3f777d05704dedcfa3e23e3c7482e /engines | |
parent | a678a0b27bb0f116833d4164e61414348d67fc2e (diff) | |
download | scummvm-rg350-c2b3abd676a194138849252a3e37d6cb977a343c.tar.gz scummvm-rg350-c2b3abd676a194138849252a3e37d6cb977a343c.tar.bz2 scummvm-rg350-c2b3abd676a194138849252a3e37d6cb977a343c.zip |
TITANIC: Fix calculation of wave file size
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/sound/music_wave.cpp | 6 | ||||
-rw-r--r-- | engines/titanic/sound/wave_file.cpp | 10 |
2 files changed, 10 insertions, 6 deletions
diff --git a/engines/titanic/sound/music_wave.cpp b/engines/titanic/sound/music_wave.cpp index 0f88c32632..8f3f3005ba 100644 --- a/engines/titanic/sound/music_wave.cpp +++ b/engines/titanic/sound/music_wave.cpp @@ -313,13 +313,15 @@ void CMusicWave::chooseWaveFile(int index, int size) { } } - int arrIndex = _arrayIndex - _items[waveIndex]._value + index; + const CMusicWaveFile &wf = _items[waveIndex]; + int arrIndex = _arrayIndex - wf._value + index; + uint waveSize = wf._waveFile->size(); _waveIndex = waveIndex; _readPos = 0; _readIncrement = (int)(_array[arrIndex] * 256); _size = size; - _count = _items[waveIndex]._waveFile->size() / 2; + _count = waveSize / 2; } void CMusicWave::setupArray(int minVal, int maxVal) { diff --git a/engines/titanic/sound/wave_file.cpp b/engines/titanic/sound/wave_file.cpp index 5d9987a33f..04800b6157 100644 --- a/engines/titanic/sound/wave_file.cpp +++ b/engines/titanic/sound/wave_file.cpp @@ -81,12 +81,14 @@ bool CWaveFile::loadSound(const CString &name) { return false; Common::SeekableReadStream *stream = file.readStream(); - _dataSize = stream->size(); - _rawData = new byte[_dataSize]; - stream->read(_rawData, _dataSize); + uint dataSize = stream->size(); + _dataSize = dataSize - 44; + + _rawData = new byte[dataSize]; + stream->read(_rawData, dataSize); _audioStream = Audio::makeWAVStream( - new Common::MemoryReadStream(_rawData, _dataSize, DisposeAfterUse::YES), + new Common::MemoryReadStream(_rawData, dataSize, DisposeAfterUse::YES), DisposeAfterUse::YES); _soundType = Audio::Mixer::kSFXSoundType; |