diff options
author | Filippos Karapetis | 2010-05-30 18:45:07 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-05-30 18:45:07 +0000 |
commit | 016862ac3a4928529d9eaedf6edf3e916c89155c (patch) | |
tree | 99d7cca38a0dfa5eebc3bcf465d86ff7922348de /engines/sci/engine/segment.cpp | |
parent | 29c2f30558e9c40d5c1a76ab600611b21ee72851 (diff) | |
download | scummvm-rg350-016862ac3a4928529d9eaedf6edf3e916c89155c.tar.gz scummvm-rg350-016862ac3a4928529d9eaedf6edf3e916c89155c.tar.bz2 scummvm-rg350-016862ac3a4928529d9eaedf6edf3e916c89155c.zip |
Moved setScriptSize() inside Script::init(), and removed a FIXME - the SCI1.1 word-align is done inside Script::init()
svn-id: r49330
Diffstat (limited to 'engines/sci/engine/segment.cpp')
-rw-r--r-- | engines/sci/engine/segment.cpp | 60 |
1 files changed, 21 insertions, 39 deletions
diff --git a/engines/sci/engine/segment.cpp b/engines/sci/engine/segment.cpp index 8a9b953289..a8c4eb73f6 100644 --- a/engines/sci/engine/segment.cpp +++ b/engines/sci/engine/segment.cpp @@ -117,8 +117,8 @@ void Script::freeScript() { _codeBlocks.clear(); } -bool Script::init(int script_nr, ResourceManager *resMan) { - setScriptSize(script_nr, resMan); +void Script::init(int script_nr, ResourceManager *resMan) { + Resource *script = resMan->findResource(ResourceId(kResourceTypeScript, script_nr), 0); _localsOffset = 0; _localsBlock = NULL; @@ -132,7 +132,25 @@ bool Script::init(int script_nr, ResourceManager *resMan) { _buf = 0; _heapStart = 0; - return true; + _scriptSize = script->size; + _bufSize = script->size; + _heapSize = 0; + + if (getSciVersion() == SCI_VERSION_0_EARLY) { + _bufSize += READ_LE_UINT16(script->data) * 2; + } else if (getSciVersion() >= SCI_VERSION_1_1) { + Resource *heap = resMan->findResource(ResourceId(kResourceTypeHeap, script_nr), 0); + _bufSize += heap->size; + _heapSize = heap->size; + + // Ensure that the start of the heap resource can be word-aligned. + if (script->size & 2) { + _bufSize++; + _scriptSize++; + } + + assert(_bufSize <= 65535); + } } void Script::load(ResourceManager *resMan) { @@ -156,42 +174,6 @@ void Script::load(ResourceManager *resMan) { } } -void Script::setScriptSize(int script_nr, ResourceManager *resMan) { - Resource *script = resMan->findResource(ResourceId(kResourceTypeScript, script_nr), 0); - Resource *heap = resMan->findResource(ResourceId(kResourceTypeHeap, script_nr), 0); - bool oldScriptHeader = (getSciVersion() == SCI_VERSION_0_EARLY); - - _scriptSize = script->size; - _heapSize = 0; // Set later - - if (!script || (getSciVersion() >= SCI_VERSION_1_1 && !heap)) { - error("SegManager::setScriptSize: failed to load %s", !script ? "script" : "heap"); - } - if (oldScriptHeader) { - _bufSize = script->size + READ_LE_UINT16(script->data) * 2; - //locals_size = READ_LE_UINT16(script->data) * 2; - } else if (getSciVersion() < SCI_VERSION_1_1) { - _bufSize = script->size; - } else { - _bufSize = script->size + heap->size; - _heapSize = heap->size; - - // Ensure that the start of the heap resource can be word-aligned. - if (script->size & 2) { - _bufSize++; - _scriptSize++; - } - - if (_bufSize > 65535) { - error("Script and heap sizes combined exceed 64K." - "This means a fundamental design bug was made in SCI\n" - "regarding SCI1.1 games.\nPlease report this so it can be" - "fixed in the next major version"); - return; - } - } -} - Object *Script::allocateObject(uint16 offset) { return &_objects[offset]; } |