diff options
author | Filippos Karapetis | 2010-05-30 21:49:07 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-05-30 21:49:07 +0000 |
commit | a0ee93ece52213cd989a50902281d917fe392ea4 (patch) | |
tree | c3f56972fc286a2fd399ad61dd0fd1d648b9a775 /engines/sci/engine/segment.cpp | |
parent | e13abd77e92a4c363731f4a6775aa26865bb4ad6 (diff) | |
download | scummvm-rg350-a0ee93ece52213cd989a50902281d917fe392ea4.tar.gz scummvm-rg350-a0ee93ece52213cd989a50902281d917fe392ea4.tar.bz2 scummvm-rg350-a0ee93ece52213cd989a50902281d917fe392ea4.zip |
SCI: Script exports and synonyms are now initialized when a script is loaded. Removed a sanity check inside script_instantiate_sci0 for a bug which no longer exists
svn-id: r49336
Diffstat (limited to 'engines/sci/engine/segment.cpp')
-rw-r--r-- | engines/sci/engine/segment.cpp | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/engines/sci/engine/segment.cpp b/engines/sci/engine/segment.cpp index bdd9fbc966..3653ff4ae9 100644 --- a/engines/sci/engine/segment.cpp +++ b/engines/sci/engine/segment.cpp @@ -27,6 +27,7 @@ #include "sci/sci.h" #include "sci/engine/features.h" +#include "sci/engine/script.h" // for SCI_OBJ_EXPORTS and SCI_OBJ_SYNONYMS #include "sci/engine/segment.h" #include "sci/engine/seg_manager.h" #include "sci/engine/state.h" @@ -182,6 +183,28 @@ void Script::load(ResourceManager *resMan) { assert(_bufSize - _scriptSize <= heap->size); memcpy(_heapStart, heap->data, heap->size); } + + _codeBlocks.clear(); + + _exportTable = 0; + _numExports = 0; + _synonyms = 0; + _numSynonyms = 0; + + if (getSciVersion() >= SCI_VERSION_1_1) { + if (READ_LE_UINT16(_buf + 6) > 0) { + _exportTable = (const uint16 *)(_buf + 6 + 2); + _numExports = READ_SCI11ENDIAN_UINT16(_exportTable - 1); + } + } else { + _exportTable = (const uint16 *)findBlock(SCI_OBJ_EXPORTS); + if (_exportTable) { + _exportTable += 3; + _numExports = READ_SCI11ENDIAN_UINT16(_exportTable - 1); + } + _synonyms = findBlock(SCI_OBJ_SYNONYMS); + _numSynonyms = _synonyms ? READ_SCI11ENDIAN_UINT16(_synonyms - 2) / 4 : 0; + } } Object *Script::allocateObject(uint16 offset) { @@ -343,16 +366,6 @@ void Script::setLockers(int lockers) { _lockers = lockers; } -void Script::setExportTableOffset(int offset) { - if (offset) { - _exportTable = (const uint16 *)(_buf + offset + 2); - _numExports = READ_SCI11ENDIAN_UINT16(_exportTable - 1); - } else { - _exportTable = NULL; - _numExports = 0; - } -} - uint16 Script::validateExportFunc(int pubfunct) { bool exportsAreWide = (g_sci->_features->detectLofsType() == SCI_VERSION_1_MIDDLE); @@ -369,18 +382,10 @@ uint16 Script::validateExportFunc(int pubfunct) { return offset; } -void Script::setSynonymsOffset(int offset) { - _synonyms = _buf + offset; -} - const byte *Script::getSynonyms() const { return _synonyms; } -void Script::setSynonymsNr(int n) { - _numSynonyms = n; -} - int Script::getSynonymsNr() const { return _numSynonyms; } |