From 9040c34f48a87ca5e80f68a7640101e1cc72564b Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Sun, 18 Dec 2022 22:55:53 +0500 Subject: [PATCH] ref: gl: replace va function calls. --- ref/gl/gl_alias.c | 4 +++- ref/gl/gl_opengl.c | 11 ++++++++--- ref/gl/gl_sprite.c | 4 +++- ref/gl/gl_warp.c | 6 +++--- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/ref/gl/gl_alias.c b/ref/gl/gl_alias.c index d9766755..71069a50 100644 --- a/ref/gl/gl_alias.c +++ b/ref/gl/gl_alias.c @@ -627,6 +627,7 @@ void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded ) daliasframetype_t *pframetype; daliasskintype_t *pskintype; int i, j, size; + char poolname[MAX_VA_STRING]; if( loaded ) *loaded = false; pinmodel = (daliashdr_t *)buffer; @@ -641,7 +642,8 @@ void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded ) if( pinmodel->numverts <= 0 || pinmodel->numtris <= 0 || pinmodel->numframes <= 0 ) return; // how to possible is make that? - mod->mempool = Mem_AllocPool( va( "^2%s^7", mod->name )); + Q_snprintf( poolname, sizeof( poolname ), "^2%s^7", mod->name ); + mod->mempool = Mem_AllocPool( poolname ); // allocate space for a working header, plus all the data except the frames, // skin and group info diff --git a/ref/gl/gl_opengl.c b/ref/gl/gl_opengl.c index 2beed166..d16738fd 100644 --- a/ref/gl/gl_opengl.c +++ b/ref/gl/gl_opengl.c @@ -335,6 +335,7 @@ qboolean GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char const dllfunc_t *func; cvar_t *parm = NULL; const char *extensions_string; + char desc[MAX_VA_STRING]; gEngfuncs.Con_Reportf( "GL_CheckExtension: %s ", name ); GL_SetExtension( r_ext, true ); @@ -342,7 +343,8 @@ qboolean GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char if( cvarname ) { // system config disable extensions - parm = gEngfuncs.Cvar_Get( cvarname, "1", FCVAR_GLCONFIG|FCVAR_READ_ONLY, va( CVAR_GLCONFIG_DESCRIPTION, name )); + Q_snprintf( desc, sizeof( desc ), CVAR_GLCONFIG_DESCRIPTION, name ); + parm = gEngfuncs.Cvar_Get( cvarname, "1", FCVAR_GLCONFIG|FCVAR_READ_ONLY, desc ); } if(( parm && !CVAR_TO_BOOL( parm )) || ( !CVAR_TO_BOOL( gl_extensions ) && r_ext != GL_OPENGL_110 )) @@ -763,6 +765,8 @@ void GL_InitExtensionsBigGL( void ) void GL_InitExtensions( void ) { + char value[MAX_VA_STRING]; + GL_OnContextCreated(); // initialize gl extensions @@ -803,8 +807,9 @@ void GL_InitExtensions( void ) if( GL_Support( GL_TEXTURE_2D_RECT_EXT )) pglGetIntegerv( GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &glConfig.max_2d_rectangle_size ); - gEngfuncs.Cvar_Get( "gl_max_size", va( "%i", glConfig.max_2d_texture_size ), 0, "opengl texture max dims" ); - gEngfuncs.Cvar_Set( "gl_anisotropy", va( "%f", bound( 0, gl_texture_anisotropy->value, glConfig.max_texture_anisotropy ))); + Q_snprintf( value, sizeof( value ), "%i", glConfig.max_2d_texture_size ); + gEngfuncs.Cvar_Get( "gl_max_size", value, 0, "opengl texture max dims" ); + gEngfuncs.Cvar_SetValue( "gl_anisotropy", bound( 0, gl_texture_anisotropy->value, glConfig.max_texture_anisotropy )); if( GL_Support( GL_TEXTURE_COMPRESSION_EXT )) gEngfuncs.Image_AddCmdFlags( IL_DDS_HARDWARE ); diff --git a/ref/gl/gl_sprite.c b/ref/gl/gl_sprite.c index 006fe135..7ed990f4 100644 --- a/ref/gl/gl_sprite.c +++ b/ref/gl/gl_sprite.c @@ -242,6 +242,7 @@ void Mod_LoadMapSprite( model_t *mod, const void *buffer, size_t size, qboolean int linedelta, numframes; mspriteframe_t *pspriteframe; msprite_t *psprite; + char poolname[MAX_VA_STRING]; if( loaded ) *loaded = false; Q_snprintf( texname, sizeof( texname ), "#%s", mod->name ); @@ -275,7 +276,8 @@ void Mod_LoadMapSprite( model_t *mod, const void *buffer, size_t size, qboolean // determine how many frames we needs numframes = (pix->width * pix->height) / (w * h); - mod->mempool = Mem_AllocPool( va( "^2%s^7", mod->name )); + Q_snprintf( poolname, sizeof( poolname ), "^2%s^7", mod->name ); + mod->mempool = Mem_AllocPool( poolname ); psprite = Mem_Calloc( mod->mempool, sizeof( msprite_t ) + ( numframes - 1 ) * sizeof( psprite->frames )); mod->cache.data = psprite; // make link to extradata diff --git a/ref/gl/gl_warp.c b/ref/gl/gl_warp.c index 3144324d..5bb9703d 100644 --- a/ref/gl/gl_warp.c +++ b/ref/gl/gl_warp.c @@ -64,7 +64,7 @@ static qboolean CheckSkybox( const char *name, char out[6][MAX_STRING] ) { const char *skybox_ext[3] = { "dds", "tga", "bmp" }; int i, j, num_checked_sides; - const char *sidename; + char sidename[MAX_VA_STRING]; // search for skybox images for( i = 0; i < 3; i++ ) @@ -74,7 +74,7 @@ static qboolean CheckSkybox( const char *name, char out[6][MAX_STRING] ) for( j = 0; j < 6; j++ ) { // build side name - sidename = va( "%s%s.%s", name, r_skyBoxSuffix[j], skybox_ext[i] ); + Q_snprintf( sidename, sizeof( sidename ), "%s%s.%s", name, r_skyBoxSuffix[j], skybox_ext[i] ); if( gEngfuncs.fsapi->FileExists( sidename, false )) { Q_strncpy( out[j], sidename, sizeof( out[j] )); @@ -90,7 +90,7 @@ static qboolean CheckSkybox( const char *name, char out[6][MAX_STRING] ) for( j = 0; j < 6; j++ ) { // build side name - sidename = va( "%s_%s.%s", name, r_skyBoxSuffix[j], skybox_ext[i] ); + Q_snprintf( sidename, sizeof( sidename ), "%s_%s.%s", name, r_skyBoxSuffix[j], skybox_ext[i] ); if( gEngfuncs.fsapi->FileExists( sidename, false )) { Q_strncpy( out[j], sidename, sizeof( out[j] ));