aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2010-05-14 15:23:42 +0000
committerFilippos Karapetis2010-05-14 15:23:42 +0000
commit6d38cf8b8f164b6d8e03715540b1d9bcfdad1ce7 (patch)
tree679b329a60bcc829246220aaba338cc9cd00c7ca
parent25bac3bef494aede6167734b7837c9308c9d9445 (diff)
downloadscummvm-rg350-6d38cf8b8f164b6d8e03715540b1d9bcfdad1ce7.tar.gz
scummvm-rg350-6d38cf8b8f164b6d8e03715540b1d9bcfdad1ce7.tar.bz2
scummvm-rg350-6d38cf8b8f164b6d8e03715540b1d9bcfdad1ce7.zip
Made locateVarSelector() a method of the Object class
svn-id: r49031
-rw-r--r--engines/sci/engine/segment.cpp27
-rw-r--r--engines/sci/engine/segment.h7
-rw-r--r--engines/sci/engine/selector.cpp27
3 files changed, 35 insertions, 26 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) {
diff --git a/engines/sci/engine/segment.h b/engines/sci/engine/segment.h
index 5651e2ef21..0b60675a6b 100644
--- a/engines/sci/engine/segment.h
+++ b/engines/sci/engine/segment.h
@@ -254,7 +254,14 @@ public:
return -1;
}
+ /**
+ * Determines if the object explicitly defines slc as a varselector
+ * Returns -1 if not found
+ */
+ int locateVarSelector(SegManager *segMan, Selector slc);
+
bool isClass() { return (getInfoSelector().offset & SCRIPT_INFO_CLASS); }
+ Object *getClass(SegManager *segMan);
void markAsFreed() { _flags |= OBJECT_FLAG_FREED; }
bool isFreed() { return _flags & OBJECT_FLAG_FREED; }
diff --git a/engines/sci/engine/selector.cpp b/engines/sci/engine/selector.cpp
index 20a10a180e..e226c4b574 100644
--- a/engines/sci/engine/selector.cpp
+++ b/engines/sci/engine/selector.cpp
@@ -258,31 +258,6 @@ int invoke_selector(EngineState *s, reg_t object, int selector_id, SelectorInvoc
return retval;
}
-static int _obj_locate_varselector(SegManager *segMan, Object *obj, Selector slc) {
- // Determines if obj explicitly defines slc as a varselector
- // Returns -1 if not found
- byte *buf;
- uint varnum;
-
- if (getSciVersion() < SCI_VERSION_1_1) {
- varnum = obj->getVarCount();
- int selector_name_offset = varnum * 2 + SCRIPT_SELECTOR_OFFSET;
- buf = obj->_baseObj + selector_name_offset;
- } else {
- if (!(obj->getInfoSelector().offset & SCRIPT_INFO_CLASS))
- obj = segMan->getObject(obj->getSuperClassSelector());
-
- buf = (byte *)obj->_baseVars;
- varnum = obj->getVariable(1).toUint16();
- }
-
- for (uint i = 0; i < varnum; i++)
- if (READ_LE_UINT16(buf + (i << 1)) == slc) // Found it?
- return i; // report success
-
- return -1; // Failed
-}
-
SelectorType lookup_selector(SegManager *segMan, reg_t obj_location, Selector selector_id, ObjVarRef *varp, reg_t *fptr) {
Object *obj = segMan->getObject(obj_location);
int index;
@@ -298,7 +273,7 @@ SelectorType lookup_selector(SegManager *segMan, reg_t obj_location, Selector se
PRINT_REG(obj_location));
}
- index = _obj_locate_varselector(segMan, obj, selector_id);
+ index = obj->locateVarSelector(segMan, selector_id);
if (index >= 0) {
// Found it as a variable