DIRECTOR: Handle duplicate cast names

Multiple casts can have the same name. The last encountered cast with
that name was save in a hashtable.
Director seems to use the cast that was encountered last.
This solves the problem by not writing existing cast names.

It happened in the game Louis Catorze. The name mainMenu was associated
with a TextCast but also a ScriptCast. The chunkexpression 'line 5 of
mainMenu' is not valid for a ScriptCast.
This commit is contained in:
Roland van Laar
2022-01-21 12:49:53 +01:00
parent eaa602bb3d
commit 3caf5013a6
+6 -1
View File
@@ -1205,7 +1205,12 @@ void Cast::loadCastInfo(Common::SeekableReadStreamEndian &stream, uint16 id) {
ci->name = castInfo.strings[1].readString();
if (!ci->name.empty()) {
_castsNames[ci->name] = id;
// Multiple casts can have the same name. In director only the first one is used.
if (!_castsNames.contains(ci->name)) {
_castsNames[ci->name] = id;
} else {
debugC(4, kDebugLoading, "Cast::loadCastInfo(): duplicate cast name: %s for castIDs: %s %s", ci->name.c_str(), numToCastNum(id), numToCastNum(_castsNames[ci->name]));
}
}
// fallthrough
case 1: