summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormaedhros <maedhros@openttd.org>2007-03-26 08:04:29 +0000
committermaedhros <maedhros@openttd.org>2007-03-26 08:04:29 +0000
commitc2312c37d6e1fc76d24a59541f3304b055d85610 (patch)
treed5366723f248b481d999e2e80183bb6cffd437c5 /src
parentfea5d98518629ece54c57a70d37aa08ad6de0148 (diff)
downloadopenttd-c2312c37d6e1fc76d24a59541f3304b055d85610.tar.xz
(svn r9472) -Fix (r9449): num is the number of newlines in the string, not the number of lines. Also allow for maxh being negative.
Diffstat (limited to 'src')
-rw-r--r--src/gfx.cpp7
1 files changed, 4 insertions, 3 deletions
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;
}