diff --git a/gfx.c b/gfx.c index 817c381550..9b5f17bf76 100644 --- a/gfx.c +++ b/gfx.c @@ -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 ac298d620a..7aee7faa88 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 d6dacc4542..5fa581367e 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 81a811c958..608b3e9d15 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++) { diff --git a/os2.c b/os2.c index e6a1b86d14..03cbbc5cb1 100644 --- a/os2.c +++ b/os2.c @@ -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); } diff --git a/unix.c b/unix.c index 096bca1e10..328062937e 100644 --- a/unix.c +++ b/unix.c @@ -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); } diff --git a/win32.c b/win32.c index 6b1a2e2e16..a8a1bb1ce6 100644 --- a/win32.c +++ b/win32.c @@ -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); }