[Scummvm-cvs-logs] CVS: scummvm/scumm gfx.cpp,2.394,2.395 gfx.h,1.100,1.101

kirben kirben at users.sourceforge.net
Sat Mar 5 16:46:57 CET 2005


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

Modified Files:
	gfx.cpp gfx.h 
Log Message:

Add extra safety checks from original games, to copyVirtScreenBuffers()



Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.394
retrieving revision 2.395
diff -u -d -r2.394 -r2.395
--- gfx.cpp	2 Mar 2005 21:46:45 -0000	2.394
+++ gfx.cpp	6 Mar 2005 00:46:12 -0000	2.395
@@ -1569,11 +1569,36 @@
 	}
 }
 
-void Gdi::copyVirtScreenBuffers(const Common::Rect &rect) {
+void Gdi::copyVirtScreenBuffers(Common::Rect rect) {
+	byte *src, *dst;
+	VirtScreen *vs = &_vm->virtscr[0];
+
+	debug(1,"copyVirtScreenBuffers: Left %d Right %d Top %d Bottom %d", rect.left, rect.right, rect.top, rect.bottom);
+
+	if (rect.top > vs->h || rect.bottom < 0)
+		return;
+
+	if (rect.left > vs->w || rect.right < 0)
+		return;
+
+	rect.left = MAX(0, (int)rect.left);
+	rect.left = MIN((int)rect.left, (int)vs->w - 1);
+
+	rect.right = MAX(0, (int)rect.right);
+	rect.right = MIN((int)rect.right, (int)vs->w);
+
+	rect.top = MAX(0, (int)rect.top);
+	rect.top = MIN((int)rect.top, (int)vs->h - 1);
+
+	rect.bottom = MAX(0, (int)rect.bottom);
+	rect.bottom = MIN((int)rect.bottom, (int)vs->h);
+
 	const int rw = rect.width();
 	const int rh = rect.height();
-	byte *src, *dst;
 	
+	if (rw == 0 || rh == 0)
+		return;
+
 	src = _vm->virtscr[0].getBackPixels(rect.left, rect.top);
 	dst = _vm->virtscr[0].getPixels(rect.left, rect.top);
 	

Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.h,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- gfx.h	20 Feb 2005 00:17:22 -0000	1.100
+++ gfx.h	6 Mar 2005 00:46:13 -0000	1.101
@@ -279,7 +279,7 @@
 	void drawBMAPBg(const byte *ptr, VirtScreen *vs, int startstrip);
 	void drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y, int w, int h);
 	
-	void copyVirtScreenBuffers(const Common::Rect &rect);
+	void copyVirtScreenBuffers(Common::Rect rect);
 
 	void disableZBuffer() { _zbufferDisabled = true; }
 	void enableZBuffer() { _zbufferDisabled = false; }





More information about the Scummvm-git-logs mailing list