[Scummvm-cvs-logs] CVS: scummvm/scumm object.cpp,1.54,1.55 scummvm.cpp,2.37,2.38

Max Horn fingolfin at users.sourceforge.net
Mon Jan 13 07:28:02 CET 2003


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

Modified Files:
	object.cpp scummvm.cpp 
Log Message:
fixed checkRange output; added checkRange call to drawObject; cleanup

Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/object.cpp,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- object.cpp	13 Jan 2003 15:13:24 -0000	1.54
+++ object.cpp	13 Jan 2003 15:27:05 -0000	1.55
@@ -188,41 +188,35 @@
 	byte *ptr;
 	ImageHeader *imhd;
 
-	if (!(_features & GF_SMALL_HEADER)) {
-		if (_features & GF_AFTER_V6) {
-			state = getState(object) - 1;
-			if (state < 0)
-				state = 0;
+	if (_features & GF_AFTER_V6) {
+		state = getState(object) - 1;
+		if (state < 0)
+			state = 0;
 
-			if (od->fl_object_index) {
-				ptr = getResourceAddress(rtFlObject, od->fl_object_index);
-				ptr = findResource(MKID('OBIM'), ptr);
-			} else {
-				ptr = getResourceAddress(rtRoom, _roomResource);
-				ptr += od->OBIMoffset;
-			}
-			assert(ptr);
-			imhd = (ImageHeader *)findResourceData(MKID('IMHD'), ptr);
-			if (_features & GF_AFTER_V8) {
-				x = od->x_pos + (int32)READ_LE_UINT32(&imhd->v8.hotspot[state].x);
-				y = od->y_pos + (int32)READ_LE_UINT32(&imhd->v8.hotspot[state].y);
-			} else if (_features & GF_AFTER_V7) {
-				x = od->x_pos + (int16)READ_LE_UINT16(&imhd->v7.hotspot[state].x);
-				y = od->y_pos + (int16)READ_LE_UINT16(&imhd->v7.hotspot[state].y);
-			} else {
-				x = od->x_pos + (int16)READ_LE_UINT16(&imhd->old.hotspot[state].x);
-				y = od->y_pos + (int16)READ_LE_UINT16(&imhd->old.hotspot[state].y);
-			}
+		if (od->fl_object_index) {
+			ptr = getResourceAddress(rtFlObject, od->fl_object_index);
+			ptr = findResource(MKID('OBIM'), ptr);
 		} else {
-			x = od->walk_x;
-			y = od->walk_y;
+			ptr = getResourceAddress(rtRoom, _roomResource);
+			ptr += od->OBIMoffset;
+		}
+		assert(ptr);
+		imhd = (ImageHeader *)findResourceData(MKID('IMHD'), ptr);
+		if (_features & GF_AFTER_V8) {
+			x = od->x_pos + (int32)READ_LE_UINT32(&imhd->v8.hotspot[state].x);
+			y = od->y_pos + (int32)READ_LE_UINT32(&imhd->v8.hotspot[state].y);
+		} else if (_features & GF_AFTER_V7) {
+			x = od->x_pos + (int16)READ_LE_UINT16(&imhd->v7.hotspot[state].x);
+			y = od->y_pos + (int16)READ_LE_UINT16(&imhd->v7.hotspot[state].y);
+		} else {
+			x = od->x_pos + (int16)READ_LE_UINT16(&imhd->old.hotspot[state].x);
+			y = od->y_pos + (int16)READ_LE_UINT16(&imhd->old.hotspot[state].y);
 		}
-		dir = oldDirToNewDir(od->actordir & 3);
 	} else {
 		x = od->walk_x;
 		y = od->walk_y;
-		dir = oldDirToNewDir(od->actordir & 3);
 	}
+	dir = oldDirToNewDir(od->actordir & 3);
 }
 
 int Scumm::getObjActToObjActDist(int a, int b)
@@ -351,6 +345,8 @@
 
 	if (od->obj_nr == 0)
 		return;
+
+	checkRange(_numGlobalObjects - 1, 0, od->obj_nr, "Object %d out of range in drawObject");
 
 	xpos = od->x_pos >> 3;
 	ypos = od->y_pos;

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.37
retrieving revision 2.38
diff -u -d -r2.37 -r2.38
--- scummvm.cpp	13 Jan 2003 13:37:43 -0000	2.37
+++ scummvm.cpp	13 Jan 2003 15:27:06 -0000	2.38
@@ -370,8 +370,10 @@
 void Scumm::checkRange(int max, int min, int no, const char *str)
 {
 	if (no < min || no > max) {
-		error("Value %d is out of bounds (%d,%d) int script(%d) msg %s", no, min,
-					max, vm.slot[_curExecScript].number, str);
+		char buf[1024];
+		sprintf(buf, str, no);
+		error("Value %d is out of bounds (%d,%d) in script %d (%s)", no, min,
+					max, vm.slot[_curExecScript].number, buf);
 	}
 }
 





More information about the Scummvm-git-logs mailing list