[Scummvm-git-logs] scummvm master -> 519719db497d5f96567ccc8b794922dedf6409dd

csnover csnover at users.noreply.github.com
Tue Apr 25 04:46:38 CEST 2017


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
e15a4c806a SCI: Use the var count from the instance's class in SCI1.1-2.1 when looking up selectors
519719db49 SCI: Add var count sanity checking to object initialization


Commit: e15a4c806a92403a3cf060bc369542b04bdeae15
    https://github.com/scummvm/scummvm/commit/e15a4c806a92403a3cf060bc369542b04bdeae15
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-04-24T21:39:30-05:00

Commit Message:
SCI: Use the var count from the instance's class in SCI1.1-2.1 when looking up selectors

At least some versions of Island of Dr Brain have a bMessager
instance in script 0 with a var count greater than that of its
class. This probably should never happen since it means the
object has a variable with no corresponding selector.

The next commit adds some extra sanity checking code to object
initialization, to warn on any other games where this happens.

Changed paths:
    engines/sci/engine/object.cpp


diff --git a/engines/sci/engine/object.cpp b/engines/sci/engine/object.cpp
index 2875c8b..a09d530 100644
--- a/engines/sci/engine/object.cpp
+++ b/engines/sci/engine/object.cpp
@@ -122,13 +122,19 @@ const Object *Object::getClass(SegManager *segMan) const {
 
 int Object::locateVarSelector(SegManager *segMan, Selector slc) const {
 	const Common::Array<uint16> *buf;
-	const uint varCount = getVarCount();
+	uint varCount;
 
-	if (getSciVersion() <= SCI_VERSION_2_1_LATE) {
+#ifdef ENABLE_SCI32
+	if (getSciVersion() == SCI_VERSION_3) {
+		buf = &_baseVars;
+		varCount = getVarCount();
+	} else {
+#else
+	{
+#endif
 		const Object *obj = getClass(segMan);
 		buf = &obj->_baseVars;
-	} else if (getSciVersion() == SCI_VERSION_3) {
-		buf = &_baseVars;
+		varCount = obj->getVarCount();
 	}
 
 	for (uint i = 0; i < varCount; i++)


Commit: 519719db497d5f96567ccc8b794922dedf6409dd
    https://github.com/scummvm/scummvm/commit/519719db497d5f96567ccc8b794922dedf6409dd
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-04-24T21:45:49-05:00

Commit Message:
SCI: Add var count sanity checking to object initialization

Changed paths:
    engines/sci/engine/script.cpp


diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp
index d35cb5b..8cf6ad0 100644
--- a/engines/sci/engine/script.cpp
+++ b/engines/sci/engine/script.cpp
@@ -1063,6 +1063,7 @@ void Script::initializeObjectsSci0(SegManager *segMan, SegmentId segmentId) {
 
 void Script::initializeObjectsSci11(SegManager *segMan, SegmentId segmentId) {
 	SciSpan<const byte> seeker = _heap.subspan(4 + _heap.getUint16SEAt(2) * 2);
+	Common::Array<reg_t> mismatchedVarCountObjects;
 
 	while (seeker.getUint16SEAt(0) == SCRIPT_OBJECT_MAGIC_NUMBER) {
 		reg_t reg = make_reg(segmentId, seeker - *_buf);
@@ -1086,6 +1087,16 @@ void Script::initializeObjectsSci11(SegManager *segMan, SegmentId segmentId) {
 			reg_t classObject = obj->getSuperClassSelector();
 			const Object *classObj = segMan->getObject(classObject);
 			obj->setPropDictSelector(classObj->getPropDictSelector());
+
+			// At least some versions of Island of Dr Brain have a bMessager
+			// instance in script 0 with a var count greater than that of its
+			// class; warn about this here to see if it shows up in any other
+			// games
+			if (obj->getVarCount() != classObj->getVarCount()) {
+				// Warnings have to be deferred until after relocation for the
+				// object name to be resolvable
+				mismatchedVarCountObjects.push_back(reg);
+			}
 		}
 
 		// Set the -classScript- selector to the script number.
@@ -1100,6 +1111,21 @@ void Script::initializeObjectsSci11(SegManager *segMan, SegmentId segmentId) {
 	}
 
 	relocateSci0Sci21(make_reg(segmentId, _heap.getUint16SEAt(0)));
+
+	for (uint i = 0; i < mismatchedVarCountObjects.size(); ++i) {
+		const reg_t pos = mismatchedVarCountObjects[i];
+		const Object *obj = segMan->getObject(pos);
+		reg_t classObject = obj->getSuperClassSelector();
+		const Object *classObj = segMan->getObject(classObject);
+
+		warning("Object %04x:%04x (%s) from %s declares %d variables, "
+				"but its class declares %d variables",
+				PRINT_REG(pos),
+				segMan->getObjectName(pos),
+				_buf->name().c_str(),
+				obj->getVarCount(),
+				classObj->getVarCount());
+	}
 }
 
 #ifdef ENABLE_SCI32





More information about the Scummvm-git-logs mailing list