diff options
author | Filippos Karapetis | 2010-05-31 11:25:59 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-05-31 11:25:59 +0000 |
commit | 3f4302214c334a590b8428fe7ae32c76e64b6ed5 (patch) | |
tree | 974dea8d632d482a566d57e742c0f2daf13fa995 /engines/sci/engine/savegame.cpp | |
parent | 9d50dac101b0d545b23397eef83f34b75a382303 (diff) | |
download | scummvm-rg350-3f4302214c334a590b8428fe7ae32c76e64b6ed5.tar.gz scummvm-rg350-3f4302214c334a590b8428fe7ae32c76e64b6ed5.tar.bz2 scummvm-rg350-3f4302214c334a590b8428fe7ae32c76e64b6ed5.zip |
The save/load object init code is now unified with the regular object init code
svn-id: r49346
Diffstat (limited to 'engines/sci/engine/savegame.cpp')
-rw-r--r-- | engines/sci/engine/savegame.cpp | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 07c40b332c..20bcb687d5 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -757,17 +757,11 @@ void SegManager::reconstructScripts(EngineState *s) { continue; Script *scr = (Script *)_heap[i]; - - // FIXME: Unify this code with script_instantiate_* ? scr->load(g_sci->getResMan()); scr->_localsBlock = (scr->_localsSegment == 0) ? NULL : (LocalVariables *)(_heap[scr->_localsSegment]); - ObjMap::iterator it; - const ObjMap::iterator end = scr->_objects.end(); - for (it = scr->_objects.begin(); it != end; ++it) { - byte *data = scr->_buf + it->_value.getPos().offset; - it->_value._baseObj = data; - } + for (ObjMap::iterator it = scr->_objects.begin(); it != scr->_objects.end(); ++it) + it->_value._baseObj = scr->_buf + it->_value.getPos().offset; } for (i = 0; i < _heap.size(); i++) { @@ -776,29 +770,15 @@ void SegManager::reconstructScripts(EngineState *s) { Script *scr = (Script *)_heap[i]; - // FIXME: Unify this code with Script::scriptObjInit ? - ObjMap::iterator it; - const ObjMap::iterator end = scr->_objects.end(); - for (it = scr->_objects.begin(); it != end; ++it) { - byte *data = scr->_buf + it->_value.getPos().offset; - - if (getSciVersion() >= SCI_VERSION_1_1) { - it->_value._baseMethod = (uint16 *)(scr->_buf + READ_LE_UINT16( data + 6 )); - it->_value._baseVars = (uint16 *)(scr->_buf + READ_LE_UINT16( data + 4 )); - } else { - int funct_area = READ_LE_UINT16(data + SCRIPT_FUNCTAREAPTR_OFFSET); - const Object *baseObj = s->_segMan->getObject(it->_value.getSpeciesSelector()); - - if (!baseObj) { - warning("Object without a base class: Script %d, index %d (reg address %04x:%04x", - scr->_nr, i, PRINT_REG(it->_value.getSpeciesSelector())); - continue; - } - it->_value.setVarCount(baseObj->getVarCount()); - it->_value._baseObj = baseObj->_baseObj; + for (ObjMap::iterator it = scr->_objects.begin(); it != scr->_objects.end(); ++it) { + reg_t addr = it->_value.getPos(); + Object *obj = scr->scriptObjInit(addr, false); - it->_value._baseMethod = (uint16 *)(data + funct_area); - it->_value._baseVars = (uint16 *)(data + it->_value.getVarCount() * 2 + SCRIPT_SELECTOR_OFFSET); + if (getSciVersion() < SCI_VERSION_1_1) { + if (!obj->initBaseObject(this, addr, false)) { + warning("Failed to locate base object for object at %04X:%04X; skipping", PRINT_REG(addr)); + scr->scriptObjRemove(addr); + } } } } |