aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2016-10-12 01:03:35 +0200
committerColin Snover2016-10-14 19:43:32 -0500
commit699a147348966dd5c12824b1e1c2b6c6e82bca41 (patch)
treea4707b213279a02b539c2976548d4f834edd14e1
parent5aac0e9d3973f729d13ab24d29a839c5d4108855 (diff)
downloadscummvm-rg350-699a147348966dd5c12824b1e1c2b6c6e82bca41.tar.gz
scummvm-rg350-699a147348966dd5c12824b1e1c2b6c6e82bca41.tar.bz2
scummvm-rg350-699a147348966dd5c12824b1e1c2b6c6e82bca41.zip
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.
-rw-r--r--engines/sci/engine/script.cpp14
1 files 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());