From fd63018fb58420d072317d85d69bb8f2205b83f1 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 4 Feb 2023 20:58:33 +0300 Subject: [PATCH] engine: client: make client string drawing functions ignore linefeeds --- engine/client/cl_font.c | 7 +++++-- engine/client/cl_game.c | 12 ++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/engine/client/cl_font.c b/engine/client/cl_font.c index 67837b5d..a75fc3cf 100644 --- a/engine/client/cl_font.c +++ b/engine/client/cl_font.c @@ -270,8 +270,11 @@ void CL_DrawStringLen( cl_font_t *font, const char *s, int *width, int *height, // but high chances somebody's relying on this s++; draw_len = 0; - if( height ) - *height += font->charHeight; + if( !FBitSet( flags, FONT_DRAW_NOLF )) + { + if( height ) + *height += font->charHeight; + } } if( IsColorString( s )) diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index a1549f4a..e305f2ba 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -1895,7 +1895,8 @@ void GAME_EXPORT pfnDrawConsoleStringLen( const char *pText, int *length, int *h { cl_font_t *font = Con_GetFont( con_fontsize->value ); - CL_DrawStringLen( font, pText, length, height, FONT_DRAW_UTF8 | FONT_DRAW_HUD ); + if( height ) *height = font->charHeight; + CL_DrawStringLen( font, pText, length, NULL, FONT_DRAW_UTF8 | FONT_DRAW_HUD ); } /* @@ -2841,7 +2842,7 @@ pfnDrawString static int GAME_EXPORT pfnDrawString( int x, int y, const char *str, int r, int g, int b ) { rgba_t color = { r, g, b, 255 }; - int flags = FONT_DRAW_HUD; + int flags = FONT_DRAW_HUD | FONT_DRAW_NOLF; if( hud_utf8->value ) SetBits( flags, FONT_DRAW_UTF8 ); @@ -2858,16 +2859,15 @@ pfnDrawStringReverse static int GAME_EXPORT pfnDrawStringReverse( int x, int y, const char *str, int r, int g, int b ) { rgba_t color = { r, g, b, 255 }; - int flags = FONT_DRAW_HUD; - int width, height; + int flags = FONT_DRAW_HUD | FONT_DRAW_NOLF; + int width; if( hud_utf8->value ) SetBits( flags, FONT_DRAW_UTF8 ); - CL_DrawStringLen( &cls.creditsFont, str, &width, &height, flags ); + CL_DrawStringLen( &cls.creditsFont, str, &width, NULL, flags ); x -= width; - y -= height; return CL_DrawString( x, y, str, color, &cls.creditsFont, flags ); }