[Scummvm-cvs-logs] CVS: scummvm/scumm wiz_he.cpp,2.15,2.16

Gregory Montoir cyx at users.sourceforge.net
Tue Mar 8 12:28:02 CET 2005


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18855/scumm

Modified Files:
	wiz_he.cpp 
Log Message:
corrections

Index: wiz_he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/wiz_he.cpp,v
retrieving revision 2.15
retrieving revision 2.16
diff -u -d -r2.15 -r2.16
--- wiz_he.cpp	5 Mar 2005 02:56:51 -0000	2.15
+++ wiz_he.cpp	8 Mar 2005 20:27:33 -0000	2.16
@@ -410,101 +410,88 @@
 }
 
 int Wiz::isWizPixelNonTransparent(const uint8 *data, int x, int y, int w, int h) {
-	int ret = 0;
+	if (x < 0 || x >= w || y < 0 || y >= h) {
+		return 0;
+	}
 	while (y != 0) {
 		data += READ_LE_UINT16(data) + 2;
 		--y;
 	}
 	uint16 off = READ_LE_UINT16(data); data += 2;
-	if (off != 0) {
-		if (x == 0) {
-			ret = (~*data) & 1;			
+	if (off == 0) {
+		return 0;
+	}
+	while (x > 0) {
+		uint8 code = *data++;
+		if (code & 1) {
+			code >>= 1;
+			if (code > x) {
+				return 0;
+			}
+			x -= code;
+		} else if (code & 2) {
+			code = (code >> 2) + 1;
+			if (code > x) {
+				return 1;
+			}
+			x -= code;
+			++data;
 		} else {
-			do {
-				uint8 code = *data++;
-				if (code & 1) {
-					code >>= 1;
-					if (code > x) {
-						ret = 0;
-						break;
-					}
-					x -= code;
-				} else if (code & 2) {
-					code = (code >> 2) + 1;
-					if (code > x) {
-						ret = 1;
-						break;
-					}
-					x -= code;
-					++data;
-				} else {
-					code = (code >> 2) + 1;
-					if (code > x) {
-						ret = 1;
-						break;
-					}
-					x -= code;
-					data += code;
-				}				
-			} while (x > 0);
+			code = (code >> 2) + 1;
+			if (code > x) {
+				return 1;
+			}
+			x -= code;
+			data += code;
 		}
 	}
-	return ret;
+	return (~data[0]) & 1;
 }
 
 uint8 Wiz::getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 color) {
-	uint8 c = color;
-	if (x >= 0 && x < w && y >= 0 && y < h) {
-		while (y != 0) {
-			data += READ_LE_UINT16(data) + 2;
-			--y;
-		}
-		uint16 off = READ_LE_UINT16(data); data += 2;
-		if (off != 0) {
-			if (x == 0) {
-				c = (*data & 1) ? color : *data;
-			} else {
-				do {
-					uint8 code = *data++;
-					if (code & 1) {
-						code >>= 1;
-						if (code > x) {
-							c = color;
-							break;
-						}
-						x -= code;
-					} else if (code & 2) {
-						code = (code >> 2) + 1;
-						if (code > x) {
-							c = *data;
-							break;
-						}
-						x -= code;
-						++data;
-					} else {
-						code = (code >> 2) + 1;
-						if (code > x) {
-							c = *(data + x);
-							break;
-						}
-						x -= code;
-						data += code;
-					}				
-				} while (x > 0);
+	if (x < 0 || x >= w || y < 0 || y >= h) {
+		return color;
+	}
+	while (y != 0) {
+		data += READ_LE_UINT16(data) + 2;
+		--y;
+	}
+	uint16 off = READ_LE_UINT16(data); data += 2;
+	if (off == 0) {
+		return color;
+	}
+	while (x > 0) {
+		uint8 code = *data++;
+		if (code & 1) {
+			code >>= 1;
+			if (code > x) {
+				return color;
 			}
+			x -= code;
+		} else if (code & 2) {
+			code = (code >> 2) + 1;
+			if (code > x) {
+				return data[0];
+			}
+			x -= code;
+			++data;
+		} else {
+			code = (code >> 2) + 1;
+			if (code > x) {
+				return data[x];
+			}
+			x -= code;
+			data += code;
 		}
 	}
-	return c;
+	return (data[0] & 1) ? color : data[1];
 }
 
 uint8 Wiz::getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 color) {
-	uint8 c;
-	if (x >= 0 && x < w && y >= 0 && y < h) {
-		c = data[y * w + x];
-	} else {
-		c = color;
+	if (x < 0 || x >= w || y < 0 || y >= h) {
+		return color;
 	}
-	return c;
+	return data[y * w + x];
 }
 
 void Wiz::computeWizHistogram(uint32 *histogram, const uint8 *data, const Common::Rect *srcRect) {





More information about the Scummvm-git-logs mailing list