diff options
author | Eugene Sandulenko | 2016-11-08 17:20:19 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2016-11-08 17:20:19 +0100 |
commit | 2b8a41b980950df8ff9f481c61d964c93236c746 (patch) | |
tree | 2f851eace0abf4b63af877b20379d8acb9bfcb6f | |
parent | 0dc532e8781cb7009fdf13298425bf6538d55480 (diff) | |
download | scummvm-rg350-2b8a41b980950df8ff9f481c61d964c93236c746.tar.gz scummvm-rg350-2b8a41b980950df8ff9f481c61d964c93236c746.tar.bz2 scummvm-rg350-2b8a41b980950df8ff9f481c61d964c93236c746.zip |
DIRECTOR: Fix string lists loading
-rw-r--r-- | engines/director/score.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/engines/director/score.cpp b/engines/director/score.cpp index a6de557098..98d25cf3f1 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -779,28 +779,28 @@ Common::Array<Common::String> Score::loadStrings(Common::SeekableSubReadStreamEn stream.seek(offset); } - uint16 count = stream.readUint16(); - offset += (count + 1) * 4 + 2; // positions info + uint16 count - uint32 startPos = stream.readUint32() + offset; + uint16 count = stream.readUint16() + 1; - for (uint16 i = 0; i < count; i++) { - Common::String entryString; - uint32 nextPos = stream.readUint32() + offset; - uint32 streamPos = stream.pos(); + uint32 *entries = (uint32 *)calloc(count, sizeof(uint32)); - stream.seek(startPos); + for (uint i = 0; i < count; i++) + entries[i] = stream.readUint32(); - while (startPos != nextPos) { - entryString += stream.readByte(); - ++startPos; - } + byte *data = (byte *)malloc(entries[count - 1]); + stream.read(data, entries[count - 1]); - strings.push_back(entryString); + for (uint i = 0; i < count - 1; i++) { + Common::String entryString; - stream.seek(streamPos); - startPos = nextPos; + for (uint j = entries[i]; j < entries[i + 1]; j++) + entryString += data[j]; + + strings.push_back(entryString); } + free(data); + free(entries); + return strings; } |