From c2312c37d6e1fc76d24a59541f3304b055d85610 Mon Sep 17 00:00:00 2001 From: maedhros Date: Mon, 26 Mar 2007 08:04:29 +0000 Subject: (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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gfx.cpp b/src/gfx.cpp index ae2bd18f9..8797c7739 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -548,10 +548,11 @@ uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh) mt = GetCharacterHeight((FontSize)GB(tmp, 16, 16)); total_height = (num + 1) * mt; - if (maxh != -1 && total_height > (uint)maxh) { - num = maxh / mt - 1; - if (num < 1) return 0; + 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; total_height = (num + 1) * mt; } -- cgit v1.2.3-70-g09d2