From 7e9d46689ca76d6bf1669ada6344fc724dd683cf Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 24 Feb 2023 19:42:42 +0300 Subject: [PATCH] engine: client: fix multiline CenterPrint --- engine/client/cl_game.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index 09b82230..d95b672d 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -308,10 +308,9 @@ void CL_CenterPrint( const char *text, float y ) { cl_font_t *font = Con_GetCurFont(); - if( !COM_CheckString( text )) + if( !COM_CheckString( text ) || !font || !font->valid ) return; - clgame.centerPrint.lines = 1; clgame.centerPrint.totalWidth = 0; clgame.centerPrint.time = cl.mtime[0]; // allow pause for centerprint Q_strncpy( clgame.centerPrint.message, text, sizeof( clgame.centerPrint.message )); @@ -322,6 +321,10 @@ void CL_CenterPrint( const char *text, float y ) &clgame.centerPrint.totalHeight, FONT_DRAW_HUD | FONT_DRAW_UTF8 ); + if( font->charHeight ) + clgame.centerPrint.lines = clgame.centerPrint.totalHeight / font->charHeight; + else clgame.centerPrint.lines = 1; + clgame.centerPrint.y = CL_AdjustYPos( y, clgame.centerPrint.totalHeight ); }