aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2012-06-15 11:48:56 +0300
committerFilippos Karapetis2012-06-15 12:24:16 +0300
commite1ae1108601cce0ad7aeab5f3e017f630f02e7ea (patch)
tree4a281f5fe357d62b0f0aadfb14c2fd34fa74e505
parent577d7e41c9ca2c498dc85e41c373fbdca8d2ed41 (diff)
downloadscummvm-rg350-e1ae1108601cce0ad7aeab5f3e017f630f02e7ea.tar.gz
scummvm-rg350-e1ae1108601cce0ad7aeab5f3e017f630f02e7ea.tar.bz2
scummvm-rg350-e1ae1108601cce0ad7aeab5f3e017f630f02e7ea.zip
SCI: Clean up the script initialization code
-rw-r--r--engines/sci/engine/script.cpp30
1 files changed, 8 insertions, 22 deletions
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp
index 08f7922b1e..f8c5539325 100644
--- a/engines/sci/engine/script.cpp
+++ b/engines/sci/engine/script.cpp
@@ -37,17 +37,22 @@ Script::Script() : SegmentObj(SEG_TYPE_SCRIPT) {
_buf = NULL;
_bufSize = 0;
_scriptSize = 0;
- _heapSize = 0;
- _synonyms = NULL;
_heapStart = NULL;
+ _heapSize = 0;
+
_exportTable = NULL;
+ _numExports = 0;
+ _synonyms = NULL;
+ _numSynonyms = 0;
_localsOffset = 0;
_localsSegment = 0;
_localsBlock = NULL;
_localsCount = 0;
+ _lockers = 1;
+
_markedAsDeleted = false;
}
@@ -65,25 +70,11 @@ void Script::freeScript() {
void Script::init(int script_nr, ResourceManager *resMan) {
Resource *script = resMan->findResource(ResourceId(kResourceTypeScript, script_nr), 0);
-
if (!script)
error("Script %d not found", script_nr);
- _localsOffset = 0;
- _localsBlock = NULL;
- _localsCount = 0;
-
- _markedAsDeleted = false;
-
_nr = script_nr;
- _buf = 0;
- _heapStart = 0;
-
- _scriptSize = script->size;
- _bufSize = script->size;
- _heapSize = 0;
-
- _lockers = 1;
+ _bufSize = _scriptSize = script->size;
if (getSciVersion() == SCI_VERSION_0_EARLY) {
_bufSize += READ_LE_UINT16(script->data) * 2;
@@ -163,11 +154,6 @@ void Script::load(ResourceManager *resMan) {
memcpy(_heapStart, heap->data, heap->size);
}
- _exportTable = 0;
- _numExports = 0;
- _synonyms = 0;
- _numSynonyms = 0;
-
if (getSciVersion() <= SCI_VERSION_1_LATE) {
_exportTable = (const uint16 *)findBlockSCI0(SCI_OBJ_EXPORTS);
if (_exportTable) {