summaryrefslogtreecommitdiff
path: root/src/gfx.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-10-22 14:24:11 +0000
committerrubidium <rubidium@openttd.org>2009-10-22 14:24:11 +0000
commit0501bd1325339e0579a72e1e1162b2a28f707fed (patch)
treeafa47472f0c3974a498f4c72d725be2adae68250 /src/gfx.cpp
parentc90885a17ed69213a22492d118507318f857f1ae (diff)
downloadopenttd-0501bd1325339e0579a72e1e1162b2a28f707fed.tar.xz
(svn r17842) -Fix: DrawStringMultiLine would in some corner case, top = bottom + 1, draw the string
Diffstat (limited to 'src/gfx.cpp')
-rw-r--r--src/gfx.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp
index 8b9c09360..ab40b9b53 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -791,6 +791,10 @@ int DrawStringMultiLine(int left, int right, int top, int bottom, StringID str,
int maxw = right - left + 1;
int maxh = bottom - top + 1;
+ /* It makes no sense to even try if it can't be drawn anyway, or
+ * do we really want to support fonts of 0 or less pixels high? */
+ if (maxh <= 0) return top;
+
char buffer[DRAW_STRING_BUFFER];
GetString(buffer, str, lastof(buffer));
@@ -800,7 +804,7 @@ int DrawStringMultiLine(int left, int right, int top, int bottom, StringID str,
int mt = GetCharacterHeight((FontSize)GB(tmp, 16, 16));
int total_height = (num + 1) * mt;
- if (maxh != 0 && total_height > maxh) {
+ if (total_height > maxh) {
/* Check there's room enough for at least one line. */
if (maxh < mt) return top;