[Scummvm-cvs-logs] CVS: scummvm/scumm object.cpp,1.102,1.103 script.cpp,1.100,1.101 script_v2.cpp,2.110,2.111

Max Horn fingolfin at users.sourceforge.net
Thu May 22 08:28:13 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv19948

Modified Files:
	object.cpp script.cpp script_v2.cpp 
Log Message:
restricted getObjectIndex to only search thru _objs, not _inventory(to avoid future confusion), this might cause regressions, though; fixed o2_getObjPreposition; adapted some code to the changed getObjectIndex

Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/object.cpp,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -d -r1.102 -r1.103
--- object.cpp	21 May 2003 18:09:46 -0000	1.102
+++ object.cpp	22 May 2003 15:27:44 -0000	1.103
@@ -129,7 +129,21 @@
 	if (object < 1)
 		return -1;
 
-	/* OF_OWNER_ROOM should be 0xFF for full throttle, else 0xF */
+#if 1
+	for (i = (_numLocalObjects-1); i > 0; i--) {
+		if (_objs[i].obj_nr == object)
+			return i;
+	}
+	return -1;
+#else
+	// FIXME: this function searches thru the _inventory. Yet almost all
+	// functions calling it assumg the index will always be into _objs.
+	// For script_v2.cpp this already caused some hard to track buglets.
+	// Maybe it also causes problems in other places. The question is,
+	// under which cirumstances would the _inventory result ever be
+	// useful for us?
+
+	// OF_OWNER_ROOM should be 0xFF for full throttle, else 0xF
 	if (_objectOwnerTable[object] != OF_OWNER_ROOM) {
 		for (i = 0; i < _maxInventoryItems; i++)
 			if (_inventory[i] == object)
@@ -142,6 +156,7 @@
 		}
 		return -1;
 	}
+#endif
 }
 
 int Scumm::whereIsObject(int object) {

Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script.cpp,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- script.cpp	22 May 2003 14:10:17 -0000	1.100
+++ script.cpp	22 May 2003 15:27:44 -0000	1.101
@@ -344,7 +344,9 @@
 	ss = &vm.slot[_currentScript];
 	switch (ss->where) {
 	case WIO_INVENTORY:					/* inventory script * */
-		idx = getObjectIndex(ss->number);
+		for (idx = 0; idx < _maxInventoryItems; idx++)
+			if (_inventory[idx] == ss->number)
+				break;
 		_scriptOrgPointer = getResourceAddress(rtInventory, idx);
 		assert(idx < _maxInventoryItems);
 		_lastCodePtr = &_baseInventoryItems[idx];

Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v2.cpp,v
retrieving revision 2.110
retrieving revision 2.111
diff -u -d -r2.110 -r2.111
--- script_v2.cpp	22 May 2003 14:22:35 -0000	2.110
+++ script_v2.cpp	22 May 2003 15:27:44 -0000	2.111
@@ -517,8 +517,10 @@
 	int unk = fetchScriptByte();
 
 	if (whereIsObject(obj) != WIO_NOT_FOUND) {
-		ObjectData *od = &_objs[getObjectIndex(obj)];
-		od->walk_y = (unk << 5) | (od->walk_y & 0x1F);
+		// FIXME: this might not work properly the moment we save and restore the game.
+		byte *ptr = getOBCDFromObject(obj) + 12;
+		*ptr &= 0x1F;
+		*ptr |= unk << 5;
 	}
 }
 
@@ -527,8 +529,8 @@
 	int obj = getVarOrDirectWord(0x80);
 
 	if (whereIsObject(obj) != WIO_NOT_FOUND) {
-		ObjectData *od = &_objs[getObjectIndex(obj)];
-		setResult(od->walk_y >> 5);
+		byte *ptr = getOBCDFromObject(obj) + 12;
+		setResult(*ptr >> 5);
 	} else {
 		setResult(0xFF);
 	}





More information about the Scummvm-git-logs mailing list