Skip to content

Commit

Permalink
SCI: Make -propDict- unique for each class
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wjp authored and csnover committed Oct 15, 2016
1 parent 5aac0e9 commit 699a147
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions engines/sci/engine/script.cpp
Expand Up @@ -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());
Expand Down

0 comments on commit 699a147

Please sign in to comment.