(svn r9472) -Fix (r9449): num is the number of newlines in the string, not the number of lines. Also allow for maxh being negative.
authormaedhros
Mon, 26 Mar 2007 08:04:29 +0000
changeset 6382 08cb3e868ca8
parent 6381 9f359ab30db9
child 6383 ec677b36d183
(svn r9472) -Fix (r9449): num is the number of newlines in the string, not the number of lines. Also allow for maxh being negative.
src/gfx.cpp
--- a/src/gfx.cpp	Mon Mar 26 00:01:42 2007 +0000
+++ b/src/gfx.cpp	Mon Mar 26 08:04:29 2007 +0000
@@ -548,10 +548,11 @@
 	mt = GetCharacterHeight((FontSize)GB(tmp, 16, 16));
 	total_height = (num + 1) * mt;
 
-	if (maxh != -1 && total_height > (uint)maxh) {
+	if (maxh != -1 && (int)total_height > maxh) {
+		/* Check there's room enough for at least one line. */
+		if (maxh < mt) return 0;
+
 		num = maxh / mt - 1;
-		if (num < 1) return 0;
-
 		total_height = (num + 1) * mt;
 	}