From 2b8a41b980950df8ff9f481c61d964c93236c746 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 8 Nov 2016 17:20:19 +0100 Subject: DIRECTOR: Fix string lists loading --- engines/director/score.cpp | 30 +++++++++++++++--------------- 1 file 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 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; } -- cgit v1.2.3