From a19d34035db7c33e271b07da36e8a729ab2589ec Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 3 Feb 2023 17:49:06 +0300 Subject: [PATCH] engine: client: font: do not use OpenFile on WADs >_< --- engine/client/cl_font.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/engine/client/cl_font.c b/engine/client/cl_font.c index 3445f40d..d0f24dd2 100644 --- a/engine/client/cl_font.c +++ b/engine/client/cl_font.c @@ -79,24 +79,26 @@ qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float sc qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float scale, int rendermode, uint texFlags ) { + fs_offset_t length; qfont_t src; - file_t *fd; + byte *pfile; int font_width, i; if( font->valid ) return true; - fd = g_fsapi.Open( fontname, "r", false ); - if( !fd ) + pfile = g_fsapi.LoadFile( fontname, &length, false ); + if( !pfile ) return false; - if( g_fsapi.Read( fd, &src, sizeof( qfont_t )) != sizeof( qfont_t )) + if( length < sizeof( src )) { - g_fsapi.Close( fd ); + Mem_Free( pfile ); return false; } - g_fsapi.Close( fd ); + memcpy( &src, pfile, sizeof( src )); + Mem_Free( pfile ); font->hFontTexture = CL_LoadFontTexture( fontname, texFlags, &font_width ); if( !font->hFontTexture )