aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2015-07-13 01:33:03 +0300
committerFilippos Karapetis2015-07-13 01:35:26 +0300
commit3a29dfaebff8b67c5c1ad9f9b0b87d24b17c7dc9 (patch)
tree52583bfbee82b4a8b43fad1226b03ae0cee460da
parent876ea62c14b3192f4e28012a7d3df8d71904907e (diff)
downloadscummvm-rg350-3a29dfaebff8b67c5c1ad9f9b0b87d24b17c7dc9.tar.gz
scummvm-rg350-3a29dfaebff8b67c5c1ad9f9b0b87d24b17c7dc9.tar.bz2
scummvm-rg350-3a29dfaebff8b67c5c1ad9f9b0b87d24b17c7dc9.zip
SCI: Fix object init in SCI3 scripts which are larger than 64kb
-rw-r--r--engines/sci/engine/script.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp
index 6034378ef6..36e33ccfa6 100644
--- a/engines/sci/engine/script.cpp
+++ b/engines/sci/engine/script.cpp
@@ -121,8 +121,8 @@ void Script::load(int script_nr, ResourceManager *resMan, ScriptPatcher *scriptP
//
// TODO: Remove this once such a mechanism is in place
if (script->size > 65535)
- error("TODO: SCI script %d is over 64KB - it's %d bytes long. This can't "
- "be handled at the moment, thus stopping", script_nr, script->size);
+ warning("TODO: SCI script %d is over 64KB - it's %d bytes long. This can't "
+ "be fully handled at the moment", script_nr, script->size);
}
uint extraLocalsWorkaround = 0;
@@ -1086,9 +1086,14 @@ void Script::initializeObjectsSci3(SegManager *segMan, SegmentId segmentId) {
const byte *seeker = getSci3ObjectsPointer();
while (READ_SCI11ENDIAN_UINT16(seeker) == SCRIPT_OBJECT_MAGIC_NUMBER) {
- reg_t reg = make_reg(segmentId, seeker - _buf);
- Object *obj = scriptObjInit(reg);
+ // We call setSegment and setOffset directly here, instead of using
+ // make_reg, as in large scripts, seeker - _buf can be larger than
+ // a 16-bit integer
+ reg_t reg;
+ reg.setSegment(segmentId);
+ reg.setOffset(seeker - _buf);
+ Object *obj = scriptObjInit(reg);
obj->setSuperClassSelector(segMan->getClassAddress(obj->getSuperClassSelector().getOffset(), SCRIPT_GET_LOCK, 0));
seeker += READ_SCI11ENDIAN_UINT16(seeker + 2);
}