MYST3: Switch file misc metadata to a Common::Array

Should fix failure to load one of the files in the Hebrew version,
as seen in bug #1348
This commit is contained in:
Bastien Bouclet 2017-06-20 14:01:44 +02:00
parent c197adfa46
commit c6e11c3691
2 changed files with 3 additions and 14 deletions

View File

@ -32,9 +32,6 @@ namespace Myst3 {
DirectorySubEntry::DirectorySubEntry(Archive *archive) :
_archive(archive) {
for (uint i = 0; i < ARRAYSIZE(_miscData); i++) {
_miscData[i] = 0;
}
}
void DirectorySubEntry::readFromStream(Common::SeekableReadStream &inStream) {
@ -61,12 +58,7 @@ void DirectorySubEntry::readFromStream(Common::SeekableReadStream &inStream) {
_videoData.width = inStream.readSint32LE();
_videoData.height = inStream.readSint32LE();
} else if (_type == kNumMetadata || _type == kTextMetadata) {
if (_metadataSize > 20) {
warning("Too much metadata, skipping");
inStream.skip(_metadataSize * sizeof(uint32));
return;
}
_miscData.resize(_metadataSize + 2);
_miscData[0] = _offset;
_miscData[1] = _size;
@ -129,8 +121,6 @@ Common::MemoryReadStream *DirectorySubEntry::getData() const {
}
uint32 DirectorySubEntry::getMiscData(uint index) const {
assert(index < 22);
return _miscData[index];
}
@ -141,7 +131,7 @@ Common::String DirectorySubEntry::getTextData(uint index) const {
memset(decrypted, 0, sizeof(decrypted));
uint8 *out = &decrypted[0];
while (_miscData[cnt / 4] && cnt < 89) {
while (cnt / 4 < _miscData.size() && cnt < 89) {
// XORed text stored in little endian 32 bit words
*out++ = (_miscData[cnt / 4] >> (8 * (3 - (cnt % 4)))) ^ key++;
cnt++;

View File

@ -43,7 +43,7 @@ struct VideoData {
int32 height;
};
typedef uint32 MiscData[22];
typedef Common::Array<uint32> MiscData;
class Archive;
@ -69,7 +69,6 @@ class DirectorySubEntry {
kDialogMovie = 74
};
DirectorySubEntry() {}
DirectorySubEntry(Archive *archive);
void readFromStream(Common::SeekableReadStream &inStream);