From 3053cd2cae6f8c9ed90e09eabc662357e7798847 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 3 Oct 2015 18:20:46 -0400 Subject: SHERLOCK: SS: Fix loading points between scene walkable areas Rose Tattoo had the zone lists cleanly listed end to end, but Serrated Sclapel has, at least for Outside Scotland Yard, a whole bunch of garbage at the start of the walk data block --- engines/sherlock/scene.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp index ea12fafd7b..37c04c681a 100644 --- a/engines/sherlock/scene.cpp +++ b/engines/sherlock/scene.cpp @@ -563,34 +563,37 @@ bool Scene::loadScene(const Common::String &filename) { // Read in the walk data size = rrmStream->readUint16LE(); - Common::SeekableReadStream *walkStream = !_compressed ? rrmStream : + Common::SeekableReadStream *walkStream = !_compressed ? rrmStream->readStream(size) : res.decompress(*rrmStream, size); - int startPos = walkStream->pos(); - while ((walkStream->pos() - startPos) < size) { - _walkPoints.push_back(WalkArray()); - _walkPoints[_walkPoints.size() - 1]._fileOffset = walkStream->pos() - startPos; - _walkPoints[_walkPoints.size() - 1].load(*walkStream, IS_ROSE_TATTOO); - } - - if (_compressed) - delete walkStream; - // Translate the file offsets of the walk directory to indexes in the loaded walk data for (uint idx1 = 0; idx1 < _zones.size(); ++idx1) { for (uint idx2 = 0; idx2 < _zones.size(); ++idx2) { - int fileOffset = _walkDirectory[idx1][idx2]; - if (fileOffset == -1) + int dataOffset = _walkDirectory[idx1][idx2]; + if (dataOffset == -1) continue; + // Check to see if we've already loaded the walk set for the given data offset uint dataIndex = 0; - while (dataIndex < _walkPoints.size() && _walkPoints[dataIndex]._fileOffset != fileOffset) + while (dataIndex < _walkPoints.size() && _walkPoints[dataIndex]._fileOffset != dataOffset) ++dataIndex; - assert(dataIndex < _walkPoints.size()); + + if (dataIndex == _walkPoints.size()) { + // Walk data for that offset hasn't been loaded yet, so load it now + _walkPoints.push_back(WalkArray()); + + walkStream->seek(dataOffset); + _walkPoints[_walkPoints.size() - 1]._fileOffset = dataOffset; + _walkPoints[_walkPoints.size() - 1].load(*walkStream, IS_ROSE_TATTOO); + dataIndex = _walkPoints.size() - 1; + } + _walkDirectory[idx1][idx2] = dataIndex; } } + delete walkStream; + if (IS_ROSE_TATTOO) { // Read in the entrance _entrance.load(*rrmStream); -- cgit v1.2.3