diff options
author | Walter van Niftrik | 2009-09-01 02:50:40 +0000 |
---|---|---|
committer | Walter van Niftrik | 2009-09-01 02:50:40 +0000 |
commit | 53380a2cbf374f2073fad7134c99ac4f50811979 (patch) | |
tree | 0403afda75042af3d25f6313079821688ee49c18 | |
parent | 2777e9f34958731eba9f6b7cbf5c3e7b3b54315b (diff) | |
download | scummvm-rg350-53380a2cbf374f2073fad7134c99ac4f50811979.tar.gz scummvm-rg350-53380a2cbf374f2073fad7134c99ac4f50811979.tar.bz2 scummvm-rg350-53380a2cbf374f2073fad7134c99ac4f50811979.zip |
SCI: Fix bug in SCI1.1 varselector search.
svn-id: r43872
-rw-r--r-- | engines/sci/engine/vm.cpp | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 8e09e56a68..05b9c96c08 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -1402,34 +1402,26 @@ static int _obj_locate_varselector(SegManager *segManager, Object *obj, Selector // Determines if obj explicitly defines slc as a varselector // Returns -1 if not found SciVersion version = segManager->sciVersion(); // for the selector defines + byte *buf; + uint varnum; if (version < SCI_VERSION_1_1) { - int varnum = obj->variable_names_nr; + varnum = obj->variable_names_nr; int selector_name_offset = varnum * 2 + SCRIPT_SELECTOR_OFFSET; - int i; - byte *buf = obj->base_obj + selector_name_offset; - - obj->base_vars = (uint16 *) buf; - - for (i = 0; i < varnum; i++) - if (READ_LE_UINT16(buf + (i << 1)) == slc) // Found it? - return i; // report success - - return -1; // Failed + buf = obj->base_obj + selector_name_offset; } else { - byte *buf = (byte *) obj->base_vars; - int i; - int varnum = obj->_variables[1].offset; - if (!(obj->_variables[SCRIPT_INFO_SELECTOR].offset & SCRIPT_INFO_CLASS)) - buf = ((byte *) obj_get(segManager, obj->_variables[SCRIPT_SUPERCLASS_SELECTOR])->base_vars); - - for (i = 0; i < varnum; i++) - if (READ_LE_UINT16(buf + (i << 1)) == slc) // Found it? - return i; // report success + obj = obj_get(segManager, obj->_variables[SCRIPT_SUPERCLASS_SELECTOR]); - return -1; // Failed + buf = (byte *)obj->base_vars; + varnum = obj->_variables[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 } static int _class_locate_funcselector(Object *obj, Selector slc, SciVersion version) { |