diff options
author | Filippos Karapetis | 2010-05-14 15:23:42 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-05-14 15:23:42 +0000 |
commit | 6d38cf8b8f164b6d8e03715540b1d9bcfdad1ce7 (patch) | |
tree | 679b329a60bcc829246220aaba338cc9cd00c7ca /engines/sci/engine/segment.cpp | |
parent | 25bac3bef494aede6167734b7837c9308c9d9445 (diff) | |
download | scummvm-rg350-6d38cf8b8f164b6d8e03715540b1d9bcfdad1ce7.tar.gz scummvm-rg350-6d38cf8b8f164b6d8e03715540b1d9bcfdad1ce7.tar.bz2 scummvm-rg350-6d38cf8b8f164b6d8e03715540b1d9bcfdad1ce7.zip |
Made locateVarSelector() a method of the Object class
svn-id: r49031
Diffstat (limited to 'engines/sci/engine/segment.cpp')
-rw-r--r-- | engines/sci/engine/segment.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/engines/sci/engine/segment.cpp b/engines/sci/engine/segment.cpp index 49328c7775..5804e5823e 100644 --- a/engines/sci/engine/segment.cpp +++ b/engines/sci/engine/segment.cpp @@ -674,6 +674,33 @@ void NodeTable::listAllOutgoingReferences(reg_t addr, void *param, NoteCallback //-------------------- hunk -------------------- +//-------------------- object ---------------------------- + +Object *Object::getClass(SegManager *segMan) { + return isClass() ? this : segMan->getObject(getSuperClassSelector()); +} + +int Object::locateVarSelector(SegManager *segMan, Selector slc) { + byte *buf; + uint varnum; + + if (getSciVersion() < SCI_VERSION_1_1) { + varnum = getVarCount(); + int selector_name_offset = varnum * 2 + SCRIPT_SELECTOR_OFFSET; + buf = _baseObj + selector_name_offset; + } else { + Object *obj = getClass(segMan); + varnum = obj->getVariable(1).toUint16(); + buf = (byte *)obj->_baseVars; + } + + for (uint i = 0; i < varnum; i++) + if (READ_LE_UINT16(buf + (i << 1)) == slc) // Found it? + return i; // report success + + return -1; // Failed +} + //-------------------- dynamic memory -------------------- reg_t DynMem::findCanonicAddress(SegManager *segMan, reg_t addr) { |