[Scummvm-cvs-logs] CVS: scummvm/scumm object.cpp,1.136,1.137

Max Horn fingolfin at users.sourceforge.net
Sun Jul 27 18:10:18 CEST 2003


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

Modified Files:
	object.cpp 
Log Message:
more sanity checks

Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/object.cpp,v
retrieving revision 1.136
retrieving revision 1.137
diff -u -d -r1.136 -r1.137
--- object.cpp	28 Jul 2003 00:33:05 -0000	1.136
+++ object.cpp	28 Jul 2003 01:09:54 -0000	1.137
@@ -223,7 +223,9 @@
  * Returns X, Y and direction in angles
  */
 void Scumm::getObjectXYPos(int object, int &x, int &y, int &dir) {
-	ObjectData &od = _objs[getObjectIndex(object)];
+	int idx = getObjectIndex(object);
+	assert(idx >= 0);
+	ObjectData &od = _objs[idx];
 	int state;
 	const byte *ptr;
 	const ImageHeader *imhd;
@@ -993,7 +995,7 @@
 }
 
 void Scumm::addObjectToInventory(uint obj, uint room) {
-	int i, slot;
+	int idx, slot;
 	uint32 size;
 	const byte *ptr;
 	byte *dst;
@@ -1003,8 +1005,9 @@
 
 	CHECK_HEAP
 	if (whereIsObject(obj) == WIO_FLOBJECT) {
-		i = getObjectIndex(obj);
-		ptr = getResourceAddress(rtFlObject, _objs[i].fl_object_index) + 8;
+		idx = getObjectIndex(obj);
+		assert(idx >= 0);
+		ptr = getResourceAddress(rtFlObject, _objs[idx].fl_object_index) + 8;
 		size = READ_BE_UINT32(ptr + 4);
 	} else {
 		findObjectInRoom(&foir, foCodeHeader, obj, room);
@@ -1399,6 +1402,7 @@
 	}
 	
 	int idx = getObjectIndex(objectNumber);
+	assert(idx >= 0);
 
 	eo = &_blastObjectQueue[_blastObjectQueuePos++];
 	eo->number = objectNumber;





More information about the Scummvm-git-logs mailing list