[Scummvm-cvs-logs] CVS: scummvm/scumm gfx.h,1.77,1.78 gfx.cpp,2.322,2.323 scumm.h,1.495,1.496

Max Horn fingolfin at users.sourceforge.net
Fri Sep 24 15:32:24 CEST 2004


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

Modified Files:
	gfx.h gfx.cpp scumm.h 
Log Message:
Avoid out-of-bounds access in V7_SMOOTH_SCROLLING_HACK mode

Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.h,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- gfx.h	24 Sep 2004 21:38:22 -0000	1.77
+++ gfx.h	24 Sep 2004 22:31:33 -0000	1.78
@@ -272,7 +272,6 @@
 
 public:
 	void init();
-	void updateNumStrips();
 
 	void drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int width, const int height,
 	                int stripnr, int numstrip, byte flag, StripTable *table = 0);

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.322
retrieving revision 2.323
diff -u -d -r2.322 -r2.323
--- gfx.cpp	24 Sep 2004 21:38:22 -0000	2.322
+++ gfx.cpp	24 Sep 2004 22:31:33 -0000	2.323
@@ -232,18 +232,13 @@
 
 	_numStrips = _vm->_screenWidth / 8;
 #ifdef V7_SMOOTH_SCROLLING_HACK
-	if (_vm->_version >= 7)
-		_numStrips += 1;
-	// TODO: Just increasing _numStrips isn't sufficient, and will cause
-	// problems in some cases. For example in In rooms which are *exactly* of
-	// width equal to _screenWidth, we now may cause an out-of-bounds access.
-	// One possible soution might be to replace _numStrips by a method
-	// Gdi::getNumStrips() which then returns the proper value, computed
-	// dynamically.
+	if (_vm->_version >= 7) {
+		//if (_vm->_screenWidth < _vm->virtscr[0].w)
+			_numStrips += 1;
+	}
 #endif
 }
 
-
 void ScummEngine::initVirtScreen(VirtScreenNumber slot, int number, int top, int width, int height, bool twobufs,
 													 bool scrollable) {
 	VirtScreen *vs = &virtscr[slot];
@@ -267,8 +262,9 @@
 	vs->bytesPerPixel = 1;
 	vs->pitch = width;
 #ifdef V7_SMOOTH_SCROLLING_HACK
-	if (_version >= 7)
+	if (_version >= 7) {
 		vs->pitch += 8;
+	}
 #endif
 
 	size = vs->pitch * vs->h;
@@ -1212,7 +1208,7 @@
 		sx = 0;
 	}
 
-	while (numstrip && sx < _numStrips) {
+	while (numstrip && sx < _numStrips && x * 8 < _vm->_roomWidth) {
 		CHECK_HEAP;
 
 		if (y < vs->tdirty[sx])

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.495
retrieving revision 1.496
diff -u -d -r1.495 -r1.496
--- scumm.h	23 Sep 2004 05:02:15 -0000	1.495
+++ scumm.h	24 Sep 2004 22:31:42 -0000	1.496
@@ -900,6 +900,9 @@
 protected:
 	/* Should be in Graphics class? */
 	uint16 _screenB, _screenH;
+#ifdef V7_SMOOTH_SCROLLING_HACK
+public: // HACK HACK HACK
+#endif
 	int _roomHeight, _roomWidth;
 public:
 	int _screenHeight, _screenWidth;





More information about the Scummvm-git-logs mailing list