From 0ce82b0859ea70097100879385bfc216d9cfdb72 Mon Sep 17 00:00:00 2001 From: spherallic Date: Mon, 6 Mar 2023 22:09:43 +0100 Subject: [PATCH] A bit more chat-related cleanup --- src/hu_stuff.c | 112 ++++++++++++++++++------------------------------- 1 file changed, 41 insertions(+), 71 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 0392dae26..a3d56a9a5 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1221,32 +1221,25 @@ static void HU_drawMiniChat(void) for (; i>0; i--) { char *msg = V_ChatWordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i-1]); - size_t j = 0; - while(msg[j]) // iterate through msg + for(size_t j = 0; msg[j]; j++) // iterate through msg { if (msg[j] < FONTSTART) // don't draw { if (msg[j] == '\n') // get back down. { - ++j; msglines++; dx = 0; - continue; - } - else if (msg[j] & 0x80) // stolen from video.c, nice. - { - ++j; - continue; } } - j++; - - dx += charwidth; - if (dx >= boxw) + else { - dx = 0; - msglines++; + dx += charwidth; + if (dx >= boxw) + { + dx = 0; + msglines++; + } } } dx = dy = 0; @@ -1259,49 +1252,38 @@ static void HU_drawMiniChat(void) y = chaty - charheight*(msglines+1); dx = dy = i = 0; - for (; i<=(chat_nummsg_min-1); i++) // iterate through our hot messages + for (; i < chat_nummsg_min; i++) // iterate through our hot messages { - INT32 clrflag = 0; INT32 timer = ((cv_chattime.value*TICRATE)-chat_timers[i]) - cv_chattime.value*TICRATE+9; // see below... INT32 transflag = (timer >= 0 && timer <= 9) ? (timer*V_10TRANS) : 0; // you can make bad jokes out of this one. - size_t j = 0; char *msg = V_ChatWordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i]); // get the current message, and word wrap it. UINT8 *colormap = NULL; - while(msg[j]) // iterate through msg + for(size_t j = 0; msg[j]; j++) // iterate through msg { if (msg[j] < FONTSTART) // don't draw { if (msg[j] == '\n') // get back down. { - ++j; dy += charheight; dx = 0; - continue; } - else if (msg[j] & 0x80) // stolen from video.c, nice. - { - clrflag = ((msg[j] & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK; - colormap = V_GetStringColormap(clrflag); - ++j; - continue; - } - - ++j; + else if (msg[j] & 0x80) // get colormap + colormap = V_GetStringColormap(((msg[j] & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK); } else { if (cv_chatbacktint.value) // on request of wolfy V_DrawFillConsoleMap(x + dx + 2, y+dy, charwidth, charheight, 239|V_SNAPTOBOTTOM|V_SNAPTOLEFT); - V_DrawChatCharacter(x + dx + 2, y+dy, msg[j++] |V_SNAPTOBOTTOM|V_SNAPTOLEFT|transflag, true, colormap); - } + V_DrawChatCharacter(x + dx + 2, y+dy, msg[j] |V_SNAPTOBOTTOM|V_SNAPTOLEFT|transflag, true, colormap); - dx += charwidth; - if (dx >= boxw) - { - dx = 0; - dy += charheight; + dx += charwidth; + if (dx >= boxw) + { + dx = 0; + dy += charheight; + } } } dy += charheight; @@ -1357,38 +1339,31 @@ static void HU_drawChatLog(INT32 offset) for (i=0; i= chat_topy) && (y+dy < (chat_bottomy))) - V_DrawChatCharacter(x + dx + 2, y+dy+2, msg[j] |V_SNAPTOBOTTOM|V_SNAPTOLEFT, true, colormap); - - j++; - dx += charwidth; - if (dx >= boxw-charwidth-2 && i= FONTSTART) // end of message shouldn't count, nor should invisible characters!!!! + else { - dx = 0; - dy += charheight; + if ((y+dy+2 >= chat_topy) && (y+dy < (chat_bottomy))) + V_DrawChatCharacter(x + dx + 2, y+dy+2, msg[j] |V_SNAPTOBOTTOM|V_SNAPTOLEFT, true, colormap); + + dx += charwidth; + if (dx >= boxw-charwidth-2 && i= 10) && (i <= 19)))) continue; - else if ((n == 2) && !(w_chat[3] == '0')) - if (!((i == 2) || ((i >= 20) && (i <= 29)))) continue; - else if ((n == 3) && !(w_chat[3] == '0')) - if (!((i == 3) || ((i >= 30) && (i <= 31)))) continue; + if ((n == 0) && !(w_chat[4] == '0') && (!(i<10))) + continue; + else if ((n == 1) && !(w_chat[3] == '0') && (!((i == 1) || ((i >= 10) && (i <= 19))))) + continue; + else if ((n == 2) && !(w_chat[3] == '0') && (!((i == 2) || ((i >= 20) && (i <= 29))))) + continue; + else if ((n == 3) && !(w_chat[3] == '0') && (!((i == 3) || ((i >= 30) && (i <= 31))))) + continue; else // general case. if (i != n) continue; } @@ -1646,9 +1619,6 @@ static void HU_DrawChat_Old(void) y += charheight; } } - - if (hu_tick < 4) - V_DrawCharacter(HU_INPUTX + c, y, '_' | cv_constextsize.value |V_NOSCALESTART|t, true); } #endif