[Scummvm-cvs-logs] CVS: scummvm/graphics scummfont.cpp,1.2,1.3

Gregory Montoir cyx at users.sourceforge.net
Sun Dec 19 16:38:00 CET 2004


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

Modified Files:
	scummfont.cpp 
Log Message:
added coordinates clipping to ScummFont::drawChar(), this should make valgrind happy when displaying the about window.

Index: scummfont.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/graphics/scummfont.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- scummfont.cpp	16 Apr 2004 12:12:37 -0000	1.2
+++ scummfont.cpp	20 Dec 2004 00:37:20 -0000	1.3
@@ -62,16 +62,20 @@
 }
 
 //void ScummFont::drawChar(byte chr, int xx, int yy, OverlayColor color) {
-void ScummFont::drawChar(const Surface *dst, byte chr, int x, int y, uint32 color) const {
+void ScummFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 color) const {
 	assert(dst != 0);
-	byte *ptr = (byte *)dst->pixels + x * dst->bytesPerPixel + y * dst->pitch;
+	byte *ptr = (byte *)dst->getBasePtr(tx, ty);
 
 	const byte *tmp = guifont + 6 + guifont[4] + chr * 8;
 	uint buffer = 0;
 	uint mask = 0;
 
-	for (y = 0; y < 8; y++) {
-		for (x = 0; x < 8; x++) {
+	for (int y = 0; y < 8; y++) {
+		if (ty + y < 0 || ty + y >= dst->h)
+			continue;
+		for (int x = 0; x < 8; x++) {
+			if (tx + x < 0 || tx + x >= dst->w)
+				continue;
 			unsigned char c;
 			mask >>= 1;
 			if (mask == 0) {





More information about the Scummvm-git-logs mailing list