aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorFilippos Karapetis2010-05-31 18:35:13 +0000
committerFilippos Karapetis2010-05-31 18:35:13 +0000
commit844ef9ba1a08de70058cfa8014f55a801b7c77aa (patch)
tree1a4348b7335e9e3d87de774263c4c14b221bd888 /engines/sci/engine
parentde2e935b2c6ca2091e37068772931da1ec51ceb3 (diff)
downloadscummvm-rg350-844ef9ba1a08de70058cfa8014f55a801b7c77aa.tar.gz
scummvm-rg350-844ef9ba1a08de70058cfa8014f55a801b7c77aa.tar.bz2
scummvm-rg350-844ef9ba1a08de70058cfa8014f55a801b7c77aa.zip
Merged all the script relocation code inside script_instantiate(), and changed the warning when reading an invalid species into an error (as it's severe, and if it happens it means something is seriously wrong)
svn-id: r49361
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/script.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp
index 304fd4d6fd..3fb8a5763e 100644
--- a/engines/sci/engine/script.cpp
+++ b/engines/sci/engine/script.cpp
@@ -252,10 +252,9 @@ void SegManager::scriptInitialiseObjectsSci11(SegmentId seg) {
}
}
-int script_instantiate_sci0(Script *scr, int segmentId, SegManager *segMan) {
+void script_instantiate_sci0(Script *scr, int segmentId, SegManager *segMan) {
int objType;
uint32 objLength = 0;
- int relocation = -1;
bool oldScriptHeader = (getSciVersion() == SCI_VERSION_0_EARLY);
uint16 curOffset = oldScriptHeader ? 2 : 0;
@@ -293,11 +292,11 @@ int script_instantiate_sci0(Script *scr, int segmentId, SegManager *segMan) {
warning("Applying workaround for an off-by-one invalid species access");
segMan->resizeClassTable(segMan->classTableSize() + 1);
} else {
- warning("Invalid species %d(0x%x) not in interval "
+ error("Invalid species %d(0x%x) not in interval "
"[0,%d) while instantiating script at segment %d\n",
species, species, segMan->classTableSize(),
segmentId);
- return 0;
+ return;
}
}
@@ -342,21 +341,12 @@ int script_instantiate_sci0(Script *scr, int segmentId, SegManager *segMan) {
}
} // if object or class
break;
- case SCI_OBJ_POINTERS: // A relocation table
- relocation = addr.offset;
- break;
-
default:
break;
}
curOffset += objLength - 4;
} while (objType != 0 && curOffset < scr->getScriptSize() - 2);
-
- if (relocation >= 0)
- scr->relocate(make_reg(segmentId, relocation));
-
- return segmentId; // instantiation successful
}
int script_instantiate(ResourceManager *resMan, SegManager *segMan, int scriptNum) {
@@ -381,10 +371,14 @@ int script_instantiate(ResourceManager *resMan, SegManager *segMan, int scriptNu
segMan->scriptInitialiseLocals(make_reg(segmentId, heapStart + 4));
segMan->scriptInitialiseObjectsSci11(segmentId);
scr->relocate(make_reg(segmentId, READ_SCI11ENDIAN_UINT16(scr->_heapStart)));
- return segmentId;
} else {
- return script_instantiate_sci0(scr, segmentId, segMan);
+ script_instantiate_sci0(scr, segmentId, segMan);
+ byte *relocationBlock = scr->findBlock(SCI_OBJ_POINTERS);
+ if (relocationBlock)
+ scr->relocate(make_reg(segmentId, relocationBlock - scr->_buf + 4));
}
+
+ return segmentId;
}
void script_uninstantiate_sci0(SegManager *segMan, int script_nr, SegmentId seg) {