aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorColin Snover2017-02-18 16:19:26 -0600
committerColin Snover2017-04-23 13:07:25 -0500
commitfc02b34215f218d2e0a0f20990654b120f52efd0 (patch)
tree4feead0acc3cf334bf4340d1bed83b0a65060896 /engines
parenteadf5d818f7dd124a8d70fde7ced8a9e5ce35c04 (diff)
downloadscummvm-rg350-fc02b34215f218d2e0a0f20990654b120f52efd0.tar.gz
scummvm-rg350-fc02b34215f218d2e0a0f20990654b120f52efd0.tar.bz2
scummvm-rg350-fc02b34215f218d2e0a0f20990654b120f52efd0.zip
SCI: Deduplicate Object::locateVarSelector code
The variable count returned by Object::getVarCount is populated by variable 1 in SCI1.1, so specially reading the variable explicitly for that engine version is not necessary.
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/object.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/engines/sci/engine/object.cpp b/engines/sci/engine/object.cpp
index 177ff9854b..4546e289dd 100644
--- a/engines/sci/engine/object.cpp
+++ b/engines/sci/engine/object.cpp
@@ -116,18 +116,16 @@ const Object *Object::getClass(SegManager *segMan) const {
int Object::locateVarSelector(SegManager *segMan, Selector slc) const {
const Common::Array<uint16> *buf;
- uint varnum = 0;
+ const uint varCount = getVarCount();
if (getSciVersion() <= SCI_VERSION_2_1_LATE) {
const Object *obj = getClass(segMan);
- varnum = getSciVersion() <= SCI_VERSION_1_LATE ? getVarCount() : obj->getVariable(1).toUint16();
buf = &obj->_baseVars;
} else if (getSciVersion() == SCI_VERSION_3) {
- varnum = _variables.size();
buf = &_baseVars;
}
- for (uint i = 0; i < varnum; i++)
+ for (uint i = 0; i < varCount; i++)
if ((*buf)[i] == slc) // Found it?
return i; // report success