From bd2e21c97afa10901fc8674fd23a76c6e3148fd4 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 14 May 2009 23:39:36 +0000 Subject: SCI: Fixed restoring scripts when loading a SCI 1.1 savestate svn-id: r40582 --- engines/sci/engine/savegame.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'engines/sci/engine') diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 8278730d61..a4f3606519 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -580,14 +580,22 @@ static void reconstruct_scripts(EngineState *s, SegManager *self) { case MEM_OBJ_SCRIPT: { Script *scr = (Script *)mobj; + // FIXME: Unify this code with script_instantiate_* load_script(s, i); scr->locals_block = (scr->locals_segment == 0) ? NULL : (LocalVariables *)(s->seg_manager->_heap[scr->locals_segment]); - scr->export_table = (uint16 *) find_unique_script_block(s, scr->buf, SCI_OBJ_EXPORTS); - scr->synonyms = find_unique_script_block(s, scr->buf, SCI_OBJ_SYNONYMS); - scr->_codeBlocks.clear(); - - if (!self->isSci1_1) + if (s->seg_manager->isSci1_1) { + scr->export_table = 0; + scr->synonyms = 0; + if (READ_LE_UINT16(scr->buf + 6) > 0) { + scr->export_table = (uint16 *)(scr->buf + 8); + scr->exports_nr = READ_LE_UINT16((byte *)(scr->export_table - 1)); + } + } else { + scr->export_table = (uint16 *) find_unique_script_block(s, scr->buf, SCI_OBJ_EXPORTS); + scr->synonyms = find_unique_script_block(s, scr->buf, SCI_OBJ_SYNONYMS); scr->export_table += 3; + } + scr->_codeBlocks.clear(); for (j = 0; j < scr->_objects.size(); j++) { byte *data = scr->buf + scr->_objects[j].pos.offset; -- cgit v1.2.3