diff options
author | tron <tron@openttd.org> | 2005-02-07 12:32:35 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-02-07 12:32:35 +0000 |
commit | b1baa4ed8bdfa43d5476da039afd71a424e56c7f (patch) | |
tree | be7740f774b1ed3f982c4e22c30d2277fa57e228 /gfx.c | |
parent | f8d97a5f616c5e303b2822316fcef409baee6195 (diff) | |
download | openttd-b1baa4ed8bdfa43d5476da039afd71a424e56c7f.tar.xz |
(svn r1840) Repel str_buffr and use local buffers where possible
Diffstat (limited to 'gfx.c')
-rw-r--r-- | gfx.c | 38 |
1 files changed, 20 insertions, 18 deletions
@@ -258,29 +258,31 @@ enum { /* returns right coordinate */ int DrawString(int x, int y, uint16 str, uint16 color) { - GetString(str_buffr, str); - assert(strlen(str_buffr) < sizeof(str_buffr) - 1); - return DoDrawString(str_buffr, x, y, color); + char buffer[512]; + + GetString(buffer, str); + return DoDrawString(buffer, x, y, color); } void DrawStringRightAligned(int x, int y, uint16 str, uint16 color) { - GetString(str_buffr, str); - assert(strlen(str_buffr) < sizeof(str_buffr) - 1); - DoDrawString(str_buffr, x - GetStringWidth(str_buffr), y, color); + char buffer[512]; + + GetString(buffer, str); + DoDrawString(buffer, x - GetStringWidth(buffer), y, color); } int DrawStringCentered(int x, int y, uint16 str, uint16 color) { + char buffer[512]; int w; - GetString(str_buffr, str); - assert(strlen(str_buffr) < sizeof(str_buffr) - 1); + GetString(buffer, str); - w = GetStringWidth(str_buffr); - DoDrawString(str_buffr, x - (w>>1), y, color); + w = GetStringWidth(buffer); + DoDrawString(buffer, x - w / 2, y, color); return w; } @@ -334,15 +336,15 @@ static uint32 FormatStringLinebreaks(char *str, int maxw) void DrawStringMultiCenter(int x, int y, uint16 str, int maxw) { + char buffer[512]; uint32 tmp; int num, w, mt, t; const char *src; byte c; - GetString(str_buffr, str); - assert(strlen(str_buffr) < sizeof(str_buffr) - 1); + GetString(buffer, str); - tmp = FormatStringLinebreaks(str_buffr, maxw); + tmp = FormatStringLinebreaks(buffer, maxw); num = (uint16)tmp; t = tmp >> 16; @@ -354,7 +356,7 @@ void DrawStringMultiCenter(int x, int y, uint16 str, int maxw) y -= (mt >> 1) * num; - src = str_buffr; + src = buffer; for(;;) { w = GetStringWidth(src); @@ -380,15 +382,15 @@ void DrawStringMultiCenter(int x, int y, uint16 str, int maxw) } void DrawStringMultiLine(int x, int y, uint16 str, int maxw) { + char buffer[512]; uint32 tmp; int num, w, mt, t; const char *src; byte c; - GetString(str_buffr, str); - assert(strlen(str_buffr) < sizeof(str_buffr) - 1); + GetString(buffer, str); - tmp = FormatStringLinebreaks(str_buffr, maxw); + tmp = FormatStringLinebreaks(buffer, maxw); num = (uint16)tmp; t = tmp >> 16; mt = 10; @@ -397,7 +399,7 @@ void DrawStringMultiLine(int x, int y, uint16 str, int maxw) { if (t != 244) mt = 18; } - src = str_buffr; + src = buffer; for(;;) { w = GetStringWidth(src); |