diff options
author | Paul Gilbert | 2015-10-03 19:04:36 -0400 |
---|---|---|
committer | Paul Gilbert | 2015-10-03 19:04:36 -0400 |
commit | f4a57cfde01268440f30447ddb6c8c78da6ae44e (patch) | |
tree | e5e5cc78891defda7902fa72484678fd284eb855 /engines/sherlock | |
parent | 3053cd2cae6f8c9ed90e09eabc662357e7798847 (diff) | |
download | scummvm-rg350-f4a57cfde01268440f30447ddb6c8c78da6ae44e.tar.gz scummvm-rg350-f4a57cfde01268440f30447ddb6c8c78da6ae44e.tar.bz2 scummvm-rg350-f4a57cfde01268440f30447ddb6c8c78da6ae44e.zip |
SHERLOCK: 3DO: Apply walk points fix to 3DO scene loading
Diffstat (limited to 'engines/sherlock')
-rw-r--r-- | engines/sherlock/scene.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp index 37c04c681a..c86282fe0e 100644 --- a/engines/sherlock/scene.cpp +++ b/engines/sherlock/scene.cpp @@ -896,28 +896,38 @@ bool Scene::loadScene(const Common::String &filename) { // === WALK DATA === Read in the walk data roomStream->seek(header3DO_walkData_offset); - int startPos = roomStream->pos(); - while ((roomStream->pos() - startPos) < (int)header3DO_walkData_size) { - _walkPoints.push_back(WalkArray()); - _walkPoints[_walkPoints.size() - 1]._fileOffset = roomStream->pos() - startPos; - _walkPoints[_walkPoints.size() - 1].load(*roomStream, false); - } + // Read in the walk data + Common::SeekableReadStream *walkStream = !_compressed ? roomStream->readStream(header3DO_walkData_size) : + res.decompress(*roomStream, header3DO_walkData_size); // 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; + // === EXITS === Read in the exits roomStream->seek(header3DO_exits_offset); |