diff options
author | Filippos Karapetis | 2010-05-30 16:38:08 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-05-30 16:38:08 +0000 |
commit | 5cdb13b3e8a160e7eae14c03644ad3be5a38b415 (patch) | |
tree | 98eda07103196ae8754f9f069e43198cc0df87af /engines | |
parent | c32e88fe0bb61e75ca983072ba28102d4efbf123 (diff) | |
download | scummvm-rg350-5cdb13b3e8a160e7eae14c03644ad3be5a38b415.tar.gz scummvm-rg350-5cdb13b3e8a160e7eae14c03644ad3be5a38b415.tar.bz2 scummvm-rg350-5cdb13b3e8a160e7eae14c03644ad3be5a38b415.zip |
Made load_script() a member of the Script class
svn-id: r49328
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/savegame.cpp | 23 | ||||
-rw-r--r-- | engines/sci/engine/segment.cpp | 21 | ||||
-rw-r--r-- | engines/sci/engine/segment.h | 1 |
3 files changed, 23 insertions, 22 deletions
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 363dc8a44a..2846aa5b9f 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -757,27 +757,6 @@ static void reconstruct_stack(EngineState *retval) { retval->stack_top = stack->_entries + stack->_capacity; } -static void load_script(EngineState *s, Script *scr) { - scr->_buf = (byte *)malloc(scr->getBufSize()); - assert(scr->_buf); - - Resource *script = g_sci->getResMan()->findResource(ResourceId(kResourceTypeScript, scr->_nr), 0); - assert(script != 0); - - assert(scr->getBufSize() >= script->size); - memcpy(scr->_buf, script->data, script->size); - - if (getSciVersion() >= SCI_VERSION_1_1) { - Resource *heap = g_sci->getResMan()->findResource(ResourceId(kResourceTypeHeap, scr->_nr), 0); - assert(heap != 0); - - scr->_heapStart = scr->_buf + scr->getScriptSize(); - - assert(scr->getBufSize() - scr->getScriptSize() <= heap->size); - memcpy(scr->_heapStart, heap->data, heap->size); - } -} - // TODO: Move thie function to a more appropriate place, such as vm.cpp or script.cpp void SegManager::reconstructScripts(EngineState *s) { uint i; @@ -791,7 +770,7 @@ void SegManager::reconstructScripts(EngineState *s) { Script *scr = (Script *)mobj; // FIXME: Unify this code with script_instantiate_* ? - load_script(s, scr); + scr->load(g_sci->getResMan()); scr->_localsBlock = (scr->_localsSegment == 0) ? NULL : (LocalVariables *)(_heap[scr->_localsSegment]); if (getSciVersion() >= SCI_VERSION_1_1) { scr->_exportTable = 0; diff --git a/engines/sci/engine/segment.cpp b/engines/sci/engine/segment.cpp index 8267de76bd..30cfe2d046 100644 --- a/engines/sci/engine/segment.cpp +++ b/engines/sci/engine/segment.cpp @@ -147,6 +147,27 @@ bool Script::init(int script_nr, ResourceManager *resMan) { return true; } +void Script::load(ResourceManager *resMan) { + Resource *script = resMan->findResource(ResourceId(kResourceTypeScript, _nr), 0); + assert(script != 0); + + _buf = (byte *)malloc(_bufSize); + assert(_buf); + + assert(_bufSize >= script->size); + memcpy(_buf, script->data, script->size); + + if (getSciVersion() >= SCI_VERSION_1_1) { + Resource *heap = resMan->findResource(ResourceId(kResourceTypeHeap, _nr), 0); + assert(heap != 0); + + _heapStart = _buf + _scriptSize; + + assert(_bufSize - _scriptSize <= heap->size); + memcpy(_heapStart, heap->data, heap->size); + } +} + 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); diff --git a/engines/sci/engine/segment.h b/engines/sci/engine/segment.h index 06d53158ce..3a4e929abe 100644 --- a/engines/sci/engine/segment.h +++ b/engines/sci/engine/segment.h @@ -364,6 +364,7 @@ public: void freeScript(); bool init(int script_nr, ResourceManager *resMan); + void load(ResourceManager *resMan); virtual bool isValidOffset(uint16 offset) const; virtual SegmentRef dereference(reg_t pointer); |