From 3caf5013a60dc1dfd43f4ff9fc04032343fda874 Mon Sep 17 00:00:00 2001 From: Roland van Laar Date: Fri, 21 Jan 2022 12:49:53 +0100 Subject: [PATCH] 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. --- engines/director/cast.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp index 6b702ae5356..324f77d4aac 100644 --- a/engines/director/cast.cpp +++ b/engines/director/cast.cpp @@ -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: