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 | 701a32d048f15abe6178032af4a8932b468c2e27 (patch) | |
tree | be7740f774b1ed3f982c4e22c30d2277fa57e228 | |
parent | 7d56d1d84167e3bd1f9c8e0c6fff8412734adce9 (diff) | |
download | openttd-701a32d048f15abe6178032af4a8932b468c2e27.tar.xz |
(svn r1840) Repel str_buffr and use local buffers where possible
-rw-r--r-- | gfx.c | 38 | ||||
-rw-r--r-- | main_gui.c | 6 | ||||
-rw-r--r-- | misc_gui.c | 6 | ||||
-rw-r--r-- | news_gui.c | 6 | ||||
-rw-r--r-- | os2.c | 3 | ||||
-rw-r--r-- | unix.c | 3 | ||||
-rw-r--r-- | win32.c | 3 |
7 files changed, 35 insertions, 30 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); diff --git a/main_gui.c b/main_gui.c index ac298d620..7aee7faa8 100644 --- a/main_gui.c +++ b/main_gui.c @@ -2101,6 +2101,7 @@ extern GetNewsStringCallbackProc * const _get_news_string_callback[]; static bool DrawScrollingStatusText(NewsItem *ni, int pos) { + char buf[512]; StringID str; const char *s; char *d; @@ -2115,10 +2116,9 @@ static bool DrawScrollingStatusText(NewsItem *ni, int pos) str = ni->string_id; } - GetString(str_buffr, str); - assert(strlen(str_buffr) < sizeof(str_buffr) - 1); + GetString(buf, str); - s = str_buffr; + s = buf; d = buffer; for(;;s++) { diff --git a/misc_gui.c b/misc_gui.c index d6dacc454..5fa581367 100644 --- a/misc_gui.c +++ b/misc_gui.c @@ -631,6 +631,7 @@ static void TooltipsWndProc(Window *w, WindowEvent *e) void GuiShowTooltips(StringID string_id) { + char buffer[512]; Window *w; int right,bottom; int x,y; @@ -645,10 +646,9 @@ void GuiShowTooltips(StringID string_id) DeleteWindow(w); } - GetString(str_buffr, string_id); - assert(strlen(str_buffr) < sizeof(str_buffr) - 1); + GetString(buffer, string_id); - right = GetStringWidth(str_buffr) + 4; + right = GetStringWidth(buffer) + 4; bottom = 14; if (right > 200) { diff --git a/news_gui.c b/news_gui.c index 81a811c95..608b3e9d1 100644 --- a/news_gui.c +++ b/news_gui.c @@ -505,6 +505,7 @@ static byte getNews(byte i) // cut string after len pixels static void GetNewsString(NewsItem *ni, char *buffer, uint max) { + char buf[512]; StringID str; const char *s; char *d; @@ -517,10 +518,9 @@ static void GetNewsString(NewsItem *ni, char *buffer, uint max) str = ni->string_id; } - GetString(str_buffr, str); - assert(strlen(str_buffr) < sizeof(str_buffr) - 1); + GetString(buf, str); - s = str_buffr; + s = buf; d = buffer; for (;; s++) { @@ -405,7 +405,8 @@ void FiosMakeSavegameName(char *buf, const char *name) void FiosDelete(const char *name) { - char *path = str_buffr; + char path[512]; + FiosMakeSavegameName(path, name); unlink(path); } @@ -327,7 +327,8 @@ void FiosMakeSavegameName(char *buf, const char *name) void FiosDelete(const char *name) { - char *path = str_buffr; + char path[512]; + FiosMakeSavegameName(path, name); unlink(path); } @@ -1811,7 +1811,8 @@ void FiosMakeSavegameName(char *buf, const char *name) void FiosDelete(const char *name) { - char *path = str_buffr; + char path[512]; + FiosMakeSavegameName(path, name); DeleteFile(path); } |