diff options
author | Eugene Sandulenko | 2020-01-08 23:03:24 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2020-01-08 23:08:13 +0100 |
commit | 25dca26ff82caf5e944212bd39b128484211a830 (patch) | |
tree | 48d1c40094c994d3e77504d275e3791a77562583 /engines/director | |
parent | 50c0d8b3c21b89a26c9add47c0d5ea621087ce5e (diff) | |
download | scummvm-rg350-25dca26ff82caf5e944212bd39b128484211a830.tar.gz scummvm-rg350-25dca26ff82caf5e944212bd39b128484211a830.tar.bz2 scummvm-rg350-25dca26ff82caf5e944212bd39b128484211a830.zip |
DIRECTOR: Fix loading CastInfo strings
Diffstat (limited to 'engines/director')
-rw-r--r-- | engines/director/score.cpp | 35 | ||||
-rw-r--r-- | engines/director/score.h | 2 |
2 files changed, 29 insertions, 8 deletions
diff --git a/engines/director/score.cpp b/engines/director/score.cpp index e92a68dfd1..88927c1366 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -746,12 +746,33 @@ void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id, CastInfo *ci = new CastInfo(); - if (castStrings.size() >= 5) { - ci->script = castStrings[0]; - ci->name = castStrings[1]; - ci->directory = castStrings[2]; - ci->fileName = castStrings[3]; + // We have here variable number of strings. Thus, instead of + // adding tons of ifs, we use this switch() + switch (castStrings.size()) { + default: + warning("Score::loadCastData(): extra %d strings", castStrings.size() - 5); + // fallthrough + case 5: ci->type = castStrings[4]; + // fallthrough + case 4: + ci->fileName = castStrings[3]; + // fallthrough + case 3: + ci->directory = castStrings[2]; + // fallthrough + case 2: + ci->name = castStrings[1]; + + if (!ci->name.empty()) { + _castsNames[ci->name] = id; + } + // fallthrough + case 1: + ci->script = castStrings[0]; + // fallthrough + case 0: + break; } // FIXME. Disabled by default, requires --debugflags=bytecode for now @@ -1231,12 +1252,12 @@ Common::Array<Common::String> Score::loadStrings(Common::SeekableSubReadStreamEn for (uint j = entries[i]; j < entries[i + 1]; j++) if (data[j] == '\r') entryString += '\n'; - else + else if (j > entries[i] || data[j] >= 0x20) // Skip first byte which is string length entryString += data[j]; strings.push_back(entryString); - debugC(6, kDebugLoading, "String %d:\n%s\n", i, entryString.c_str()); + debugC(6, kDebugLoading, "String %d:\n%s\n", i, Common::toPrintable(entryString).c_str()); } free(data); diff --git a/engines/director/score.h b/engines/director/score.h index ef7244bf97..d4d402bb3e 100644 --- a/engines/director/score.h +++ b/engines/director/score.h @@ -123,7 +123,7 @@ private: public: Common::Array<Frame *> _frames; Common::HashMap<uint16, CastInfo *> _castsInfo; - Common::HashMap<Common::String, int> _castsNames; + Common::HashMap<Common::String, int, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _castsNames; Common::SortedArray<Label *> *_labels; Common::HashMap<uint16, Common::String> _actions; Common::HashMap<uint16, bool> _immediateActions; |