From 699a147348966dd5c12824b1e1c2b6c6e82bca41 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 12 Oct 2016 01:03:35 +0200 Subject: SCI: Make -propDict- unique for each class Previously, this was using the offset of the property dict inside the script. However, this isn't unique. For example, SQ6's DPath and PolyPath classes both have their property dict at offset 8 of their respective scripts. This would break Obj::isMemberOf. Closes #846. --- engines/sci/engine/script.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp index 26a7ff5718..aef9cb198f 100644 --- a/engines/sci/engine/script.cpp +++ b/engines/sci/engine/script.cpp @@ -1058,11 +1058,17 @@ void Script::initializeObjectsSci11(SegManager *segMan, SegmentId segmentId) { obj->setSuperClassSelector( segMan->getClassAddress(obj->getSuperClassSelector().getOffset(), SCRIPT_GET_LOCK, 0)); - // If object is instance, get -propDict- from class and set it for this - // object. This is needed for ::isMemberOf() to work. + // -propDict- is used by Obj::isMemberOf to determine if an object + // is an instance of a class. For classes, we therefore relocate + // -propDict- to the script's segment. For instances, we copy + // -propDict- from its class. // Example test case - room 381 of sq4cd - if isMemberOf() doesn't work, - // talk-clicks on the robot will act like clicking on ego - if (!obj->isClass()) { + // talk-clicks on the robot will act like clicking on ego. + if (obj->isClass()) { + reg_t propDict = obj->getPropDictSelector(); + propDict.setSegment(segmentId); + obj->setPropDictSelector(propDict); + } else { reg_t classObject = obj->getSuperClassSelector(); const Object *classObj = segMan->getObject(classObject); obj->setPropDictSelector(classObj->getPropDictSelector()); -- cgit v1.2.3