From c6c0a9dd1abed7dc998563bbcd69e3b7b41b7aa1 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 20 Aug 2019 16:33:39 -0700 Subject: [PATCH] Old string drawing functions are dumb --- src/m_menu.c | 64 ++------------------------------------------------- src/v_video.c | 12 +++++----- 2 files changed, 8 insertions(+), 68 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 5f71c7837..b41d8bbcb 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8147,72 +8147,12 @@ static void M_DrawSetupChoosePlayerMenu(void) } // Character description - // No, I can't use strtok. - // Put two line break characters next to each other to see why. { - char *text = char_notes; - char *first_token = text; - char *last_token = strchr(text, '\n'); INT32 x = 146; INT32 y = my + 9; - INT32 flags = V_ALLOWLOWERCASE; + INT32 flags = V_ALLOWLOWERCASE|V_RETURN8; - // No line breaks? - // Draw entire string - if (!last_token) - V_DrawString(x, y, flags, char_notes); - // Split string by the line break character - else - { - char *string = NULL; - INT32 len; - while (true) - { - // There are still lines left do draw - if (last_token) - { - size_t shift = 0; - // Free this line - if (string) - Z_Free(string); - // Find string length, do a malloc... - len = (last_token-first_token)+1; - string = ZZ_Alloc(len); - // Copy the line - strncpy(string, first_token, len-1); - string[len-1] = '\0'; - // Don't leave a line break character - // at the start of the string! - if ((strlen(string) >= 2) && (string[0] == '\n') && (string[1] != '\n')) - shift++; - // Then draw it - V_DrawString(x, y, flags, string+shift); - } - // No line break character was found - else - { - // Don't leave a line break character - // at the start of the string! - if ((strlen(first_token) >= 2) && (first_token[0] == '\n') && (first_token[1] != '\n')) - first_token++; - V_DrawString(x, y, flags, first_token); - break; - } - - // Next line - y += 8; // V_RETURN8 - if ((last_token-text)+1 >= strlen(text)) - last_token = NULL; - else - { - first_token = last_token; - last_token = strchr(first_token+1, '\n'); - } - } - // Free this line - if (string) - Z_Free(string); - } + V_DrawString(x, y, flags, char_notes); } // Name tags! diff --git a/src/v_video.c b/src/v_video.c index 2ec06a787..996c159bf 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2184,7 +2184,7 @@ void V_DrawString(INT32 x, INT32 y, INT32 option, const char *string) w = SHORT(hu_font[c]->width) * dupx; if (cx > scrwidth) - break; + continue; if (cx+left + w < 0) //left boundary check { cx += w; @@ -2298,7 +2298,7 @@ void V_DrawSmallString(INT32 x, INT32 y, INT32 option, const char *string) w = SHORT(hu_font[c]->width) * dupx / 2; if (cx > scrwidth) - break; + continue; if (cx+left + w < 0) //left boundary check { cx += w; @@ -2403,7 +2403,7 @@ void V_DrawThinString(INT32 x, INT32 y, INT32 option, const char *string) w = (SHORT(tny_font[c]->width) * dupx); if (cx > scrwidth) - break; + continue; if (cx+left + w < 0) //left boundary check { cx += w; @@ -2501,7 +2501,7 @@ void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) w = SHORT(hu_font[c]->width) * dupx; if ((cx>>FRACBITS) > scrwidth) - break; + continue; if ((cx>>FRACBITS)+left + w < 0) //left boundary check { cx += w<width) * dupx; if ((cx>>FRACBITS) > scrwidth) - break; + continue; V_DrawSciencePatch(cx, cy, option, cred_font[c], FRACUNIT); cx += w<width) * dupx; if (cx > scrwidth) - break; + continue; if (cx+left + w < 0) //left boundary check { cx += w;