SCI: adding detection for SCI01 vocab inside a SCI0 game that's using the SCI0 vocab resource number, fixes pq2 japanese crashing on startup

svn-id: r50970
This commit is contained in:
Martin Kiewitz 2010-07-17 22:11:35 +00:00
parent 88dfa3142f
commit bbcf020457

View File

@ -85,6 +85,24 @@ bool Vocabulary::loadParserWords() {
return false; // NOT critical: SCI1 games and some demos don't have one!
}
if (_vocabVersion == kVocabularySCI0) {
if (resource->size < 26 * 2) {
warning("Invalid main vocabulary encountered: Much too small");
return false;
}
// Check the alphabet-offset table for any content
int alphabetNr;
for (alphabetNr = 0; alphabetNr < 26; alphabetNr++) {
if (READ_LE_UINT16(resource->data + alphabetNr * 2))
break;
}
// If all of them were empty, we are definitely seeing SCI01 vocab in disguise (e.g. pq2 japanese)
if (alphabetNr == 26) {
warning("SCI0: Found SCI01 vocabulary in disguise");
_vocabVersion = kVocabularySCI1;
}
}
unsigned int seeker;
if (_vocabVersion == kVocabularySCI1)
seeker = 255 * 2; // vocab.900 starts with 255 16-bit pointers which we don't use