diff options
author | Filippos Karapetis | 2019-09-14 11:39:35 +0300 |
---|---|---|
committer | Filippos Karapetis | 2019-09-14 11:39:35 +0300 |
commit | 9dd63b12b15d08f24b39f17f2334b87d99a2a0ef (patch) | |
tree | c65b2c843b1b7cdc1803c310a82c99b3cde2d367 | |
parent | 3bd9954f9a9b45ee7cff1a6f8e5b4a12328b171d (diff) | |
download | scummvm-rg350-9dd63b12b15d08f24b39f17f2334b87d99a2a0ef.tar.gz scummvm-rg350-9dd63b12b15d08f24b39f17f2334b87d99a2a0ef.tar.bz2 scummvm-rg350-9dd63b12b15d08f24b39f17f2334b87d99a2a0ef.zip |
SCI: Add more script patcher checks for games without a selector vocab
Fixes the LSL1 demo
-rw-r--r-- | engines/sci/engine/object.cpp | 20 | ||||
-rw-r--r-- | engines/sci/engine/object.h | 6 | ||||
-rw-r--r-- | engines/sci/engine/script.cpp | 8 | ||||
-rw-r--r-- | engines/sci/engine/script.h | 3 |
4 files changed, 21 insertions, 16 deletions
diff --git a/engines/sci/engine/object.cpp b/engines/sci/engine/object.cpp index 98069b4be6..f3bd1292bd 100644 --- a/engines/sci/engine/object.cpp +++ b/engines/sci/engine/object.cpp @@ -240,25 +240,29 @@ int Object::propertyOffsetToId(SegManager *segMan, int propertyOffset) const { } } -void Object::initSpecies(SegManager *segMan, reg_t addr) { +void Object::initSpecies(SegManager *segMan, reg_t addr, bool applyScriptPatches) { uint16 speciesOffset = getSpeciesSelector().getOffset(); if (speciesOffset == 0xffff) // -1 setSpeciesSelector(NULL_REG); // no species - else - setSpeciesSelector(segMan->getClassAddress(speciesOffset, SCRIPT_GET_LOCK, addr.getSegment())); + else { + reg_t species = segMan->getClassAddress(speciesOffset, SCRIPT_GET_LOCK, addr.getSegment(), applyScriptPatches); + setSpeciesSelector(species); + } } -void Object::initSuperClass(SegManager *segMan, reg_t addr) { +void Object::initSuperClass(SegManager *segMan, reg_t addr, bool applyScriptPatches) { uint16 superClassOffset = getSuperClassSelector().getOffset(); if (superClassOffset == 0xffff) // -1 setSuperClassSelector(NULL_REG); // no superclass - else - setSuperClassSelector(segMan->getClassAddress(superClassOffset, SCRIPT_GET_LOCK, addr.getSegment())); + else { + reg_t classAddress = segMan->getClassAddress(superClassOffset, SCRIPT_GET_LOCK, addr.getSegment(), applyScriptPatches); + setSuperClassSelector(classAddress); + } } -bool Object::initBaseObject(SegManager *segMan, reg_t addr, bool doInitSuperClass) { +bool Object::initBaseObject(SegManager *segMan, reg_t addr, bool doInitSuperClass, bool applyScriptPatches) { const Object *baseObj = segMan->getObject(getSpeciesSelector()); if (baseObj) { @@ -270,7 +274,7 @@ bool Object::initBaseObject(SegManager *segMan, reg_t addr, bool doInitSuperClas _baseObj = baseObj->_baseObj; assert(_baseObj); if (doInitSuperClass) - initSuperClass(segMan, addr); + initSuperClass(segMan, addr, applyScriptPatches); if (_variables.size() != originalVarCount) { // These objects are probably broken. diff --git a/engines/sci/engine/object.h b/engines/sci/engine/object.h index 7b65cc6c92..941a10facc 100644 --- a/engines/sci/engine/object.h +++ b/engines/sci/engine/object.h @@ -300,9 +300,9 @@ public: int propertyOffsetToId(SegManager *segMan, int propertyOffset) const; - void initSpecies(SegManager *segMan, reg_t addr); - void initSuperClass(SegManager *segMan, reg_t addr); - bool initBaseObject(SegManager *segMan, reg_t addr, bool doInitSuperClass = true); + void initSpecies(SegManager *segMan, reg_t addr, bool applyScriptPatches); + void initSuperClass(SegManager *segMan, reg_t addr, bool applyScriptPatches); + bool initBaseObject(SegManager *segMan, reg_t addr, bool doInitSuperClass = true, bool applyScriptPatches = true); #ifdef ENABLE_SCI32 bool mustSetViewVisible(const int index, const bool fromPropertyOp) const; diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp index 25d12833c3..72ae3316e2 100644 --- a/engines/sci/engine/script.cpp +++ b/engines/sci/engine/script.cpp @@ -1068,7 +1068,7 @@ void Script::initializeClasses(SegManager *segMan) { } } -void Script::initializeObjectsSci0(SegManager *segMan, SegmentId segmentId) { +void Script::initializeObjectsSci0(SegManager *segMan, SegmentId segmentId, bool applyScriptPatches) { bool oldScriptHeader = (getSciVersion() == SCI_VERSION_0_EARLY); // We need to make two passes, as the objects in the script might be in the @@ -1089,10 +1089,10 @@ void Script::initializeObjectsSci0(SegManager *segMan, SegmentId segmentId) { Object *obj; if (pass == 1) { obj = scriptObjInit(addr); - obj->initSpecies(segMan, addr); + obj->initSpecies(segMan, addr, applyScriptPatches); } else { obj = getObject(addr.getOffset()); - if (!obj->initBaseObject(segMan, addr)) { + if (!obj->initBaseObject(segMan, addr, true, applyScriptPatches)) { if ((_nr == 202 || _nr == 764) && g_sci->getGameId() == GID_KQ5) { // WORKAROUND: Script 202 of KQ5 French and German // (perhaps Spanish too?) has an invalid object. @@ -1203,7 +1203,7 @@ void Script::initializeObjectsSci3(SegManager *segMan, SegmentId segmentId, bool void Script::initializeObjects(SegManager *segMan, SegmentId segmentId, bool applyScriptPatches) { if (getSciVersion() <= SCI_VERSION_1_LATE) - initializeObjectsSci0(segMan, segmentId); + initializeObjectsSci0(segMan, segmentId, applyScriptPatches); else if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1_LATE) initializeObjectsSci11(segMan, segmentId, applyScriptPatches); #ifdef ENABLE_SCI32 diff --git a/engines/sci/engine/script.h b/engines/sci/engine/script.h index e1a4b9613b..a291ede755 100644 --- a/engines/sci/engine/script.h +++ b/engines/sci/engine/script.h @@ -332,8 +332,9 @@ private: * Initializes the script's objects (SCI0) * @param segMan A reference to the segment manager * @param segmentId The script's segment id + * @applyScriptPatches Apply patches for the script, if available */ - void initializeObjectsSci0(SegManager *segMan, SegmentId segmentId); + void initializeObjectsSci0(SegManager *segMan, SegmentId segmentId, bool applyScriptPatches); /** * Initializes the script's objects (SCI1.1 - SCI2.1) |