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/segment.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/segment.cpp')
-rw-r--r-- | engines/sci/engine/segment.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/engines/sci/engine/segment.cpp b/engines/sci/engine/segment.cpp index e1e7fd4ae6..07fe6f0a92 100644 --- a/engines/sci/engine/segment.cpp +++ b/engines/sci/engine/segment.cpp @@ -227,10 +227,10 @@ const Object *Script::getObject(uint16 offset) const { return 0; } -Object *Script::scriptObjInit(reg_t obj_pos) { +Object *Script::scriptObjInit(reg_t obj_pos, bool fullObjectInit) { Object *obj; - if (getSciVersion() < SCI_VERSION_1_1) + if (getSciVersion() < SCI_VERSION_1_1 && fullObjectInit) obj_pos.offset += 8; // magic offset (SCRIPT_OBJECT_MAGIC_OFFSET) VERIFY(obj_pos.offset < _bufSize, "Attempt to initialize object beyond end of script\n"); @@ -239,7 +239,7 @@ Object *Script::scriptObjInit(reg_t obj_pos) { VERIFY(obj_pos.offset + SCRIPT_FUNCTAREAPTR_OFFSET < (int)_bufSize, "Function area pointer stored beyond end of script\n"); - obj->init(_buf, obj_pos); + obj->init(_buf, obj_pos, fullObjectInit); return obj; } @@ -680,7 +680,7 @@ void NodeTable::listAllOutgoingReferences(reg_t addr, void *param, NoteCallback //-------------------- object ---------------------------- -void Object::init(byte *buf, reg_t obj_pos) { +void Object::init(byte *buf, reg_t obj_pos, bool initVariables) { byte *data = buf + obj_pos.offset; _baseObj = data; _pos = obj_pos; @@ -697,8 +697,10 @@ void Object::init(byte *buf, reg_t obj_pos) { _methodCount = READ_SCI11ENDIAN_UINT16(_baseMethod); } - for (uint i = 0; i < _variables.size(); i++) - _variables[i] = make_reg(0, READ_SCI11ENDIAN_UINT16(data + (i * 2))); + if (initVariables) { + for (uint i = 0; i < _variables.size(); i++) + _variables[i] = make_reg(0, READ_SCI11ENDIAN_UINT16(data + (i * 2))); + } } const Object *Object::getClass(SegManager *segMan) const { @@ -769,14 +771,15 @@ void Object::initSuperClass(SegManager *segMan, reg_t addr) { setSuperClassSelector(segMan->getClassAddress(superClassOffset, SCRIPT_GET_LOCK, addr)); } -bool Object::initBaseObject(SegManager *segMan, reg_t addr) { +bool Object::initBaseObject(SegManager *segMan, reg_t addr, bool doInitSuperClass) { const Object *baseObj = segMan->getObject(getSpeciesSelector()); if (baseObj) { - setVarCount(baseObj->getVarCount()); + _variables.resize(baseObj->getVarCount()); // Copy base from species class, as we need its selector IDs _baseObj = baseObj->_baseObj; - initSuperClass(segMan, addr); + if (doInitSuperClass) + initSuperClass(segMan, addr); return true; } |