From 1ee01163b7018f48e5f7739dd3584df490dc7014 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 19 May 2023 07:02:34 +0300 Subject: [PATCH] engine: client: move scrn cvars to static allocation --- engine/client/cl_demo.c | 6 ++-- engine/client/cl_game.c | 2 +- engine/client/cl_parse.c | 8 ++--- engine/client/cl_qparse.c | 4 +-- engine/client/cl_scrn.c | 72 +++++++++++++++++++------------------- engine/client/cl_tent.c | 4 +-- engine/client/cl_view.c | 8 ++--- engine/client/client.h | 14 ++++---- engine/client/console.c | 6 ++-- engine/client/vid_common.c | 4 +-- engine/common/common.h | 6 ++-- engine/common/net_chan.c | 4 +-- 12 files changed, 69 insertions(+), 69 deletions(-) diff --git a/engine/client/cl_demo.c b/engine/client/cl_demo.c index 7f08a004..b8c0ee5b 100644 --- a/engine/client/cl_demo.c +++ b/engine/client/cl_demo.c @@ -698,7 +698,7 @@ void CL_DemoAborted( void ) cls.demofile = NULL; cls.demonum = -1; - Cvar_SetValue( "v_dark", 0.0f ); + Cvar_DirectSet( &v_dark, "0" ); } /* @@ -716,7 +716,7 @@ void CL_DemoCompleted( void ) if( !CL_NextDemo() && !cls.changedemo ) UI_SetActiveMenu( true ); - Cvar_SetValue( "v_dark", 0.0f ); + Cvar_DirectSet( &v_dark, "0" ); } /* @@ -1306,7 +1306,7 @@ void CL_CheckStartupDemos( void ) } // run demos loop in background mode - Cvar_SetValue( "v_dark", 1.0f ); + Cvar_DirectSet( &v_dark, "1" ); cls.demos_pending = false; cls.demonum = 0; CL_NextDemo (); diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index ee65b136..3207100f 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -458,7 +458,7 @@ void CL_DrawCenterPrint( void ) if( !clgame.centerPrint.time ) return; - if(( cl.time - clgame.centerPrint.time ) >= scr_centertime->value ) + if(( cl.time - clgame.centerPrint.time ) >= scr_centertime.value ) { // time expired clgame.centerPrint.time = 0.0f; diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index 98974eca..60ab2d85 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -974,9 +974,9 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy ) else Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", clgame.mapname, refState.wideScreen ? "16x9" : "4x3" )); Cvar_SetValue( "scr_loading", 0.0f ); // reset progress bar - if(( cl_allow_levelshots->value && !cls.changelevel ) || cl.background ) + if(( cl_allow_levelshots.value && !cls.changelevel ) || cl.background ) { - if( !FS_FileExists( va( "%s.bmp", cl_levelshot_name->string ), true )) + if( !FS_FileExists( va( "%s.bmp", cl_levelshot_name.string ), true )) Cvar_Set( "cl_levelshot_name", "*black" ); // render a black screen cls.scrshot_request = scrshot_plaque; // request levelshot even if exist (check filetime) } @@ -1550,7 +1550,7 @@ CL_StartDark */ static void CL_StartDark( void ) { - if( Cvar_VariableValue( "v_dark" )) + if( v_dark.value ) { screenfade_t *sf = &clgame.fade; float fadetime = 5.0f; @@ -1575,7 +1575,7 @@ static void CL_StartDark( void ) sf->fadeReset += cl.time; sf->fadeEnd += sf->fadeReset; - Cvar_SetValue( "v_dark", 0.0f ); + Cvar_DirectSet( &v_dark, "0" ); } } diff --git a/engine/client/cl_qparse.c b/engine/client/cl_qparse.c index e9da6024..bc6b3b36 100644 --- a/engine/client/cl_qparse.c +++ b/engine/client/cl_qparse.c @@ -302,9 +302,9 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg ) else Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", clgame.mapname, refState.wideScreen ? "16x9" : "4x3" )); Cvar_SetValue( "scr_loading", 0.0f ); // reset progress bar - if(( cl_allow_levelshots->value && !cls.changelevel ) || cl.background ) + if(( cl_allow_levelshots.value && !cls.changelevel ) || cl.background ) { - if( !FS_FileExists( va( "%s.bmp", cl_levelshot_name->string ), true )) + if( !FS_FileExists( va( "%s.bmp", cl_levelshot_name.string ), true )) Cvar_Set( "cl_levelshot_name", "*black" ); // render a black screen cls.scrshot_request = scrshot_plaque; // request levelshot even if exist (check filetime) } diff --git a/engine/client/cl_scrn.c b/engine/client/cl_scrn.c index 11dddbcb..a7d9e0ea 100644 --- a/engine/client/cl_scrn.c +++ b/engine/client/cl_scrn.c @@ -20,18 +20,18 @@ GNU General Public License for more details. #include "input.h" #include "library.h" -convar_t *scr_centertime; -convar_t *scr_loading; -convar_t *scr_download; -convar_t *scr_viewsize; -convar_t *cl_testlights; -convar_t *cl_allow_levelshots; -convar_t *cl_levelshot_name; -static convar_t *cl_envshot_size; -convar_t *v_dark; -static convar_t *net_speeds; -static convar_t *cl_showfps; -static convar_t *cl_showpos; +CVAR_DEFINE_AUTO( scr_centertime, "2.5", 0, "centerprint hold time" ); +CVAR_DEFINE_AUTO( scr_loading, "0", 0, "loading bar progress" ); +CVAR_DEFINE_AUTO( scr_download, "-1", 0, "downloading bar progress" ); +CVAR_DEFINE( scr_viewsize, "viewsize", "120", FCVAR_ARCHIVE, "screen size (quake only)" ); +CVAR_DEFINE_AUTO( cl_testlights, "0", 0, "test dynamic lights" ); +CVAR_DEFINE( cl_allow_levelshots, "allow_levelshots", "0", FCVAR_ARCHIVE, "allow engine to use indivdual levelshots instead of 'loading' image" ); +CVAR_DEFINE_AUTO( cl_levelshot_name, "*black", 0, "contains path to current levelshot" ); +static CVAR_DEFINE_AUTO( cl_envshot_size, "256", FCVAR_ARCHIVE, "envshot size of cube side" ); +CVAR_DEFINE_AUTO( v_dark, "0", 0, "starts level from dark screen" ); +static CVAR_DEFINE_AUTO( net_speeds, "0", FCVAR_ARCHIVE, "show network packets" ); +static CVAR_DEFINE_AUTO( cl_showfps, "0", FCVAR_ARCHIVE, "show client fps" ); +static CVAR_DEFINE_AUTO( cl_showpos, "0", FCVAR_ARCHIVE, "show local player position and velocity" ); typedef struct { @@ -59,7 +59,7 @@ void SCR_DrawFPS( int height ) char fpsstring[64]; int offset; - if( cls.state != ca_active || !cl_showfps->value || cl.background ) + if( cls.state != ca_active || !cl_showfps.value || cl.background ) return; switch( cls.scrshot_action ) @@ -95,7 +95,7 @@ void SCR_DrawFPS( int height ) if( curfps < minfps ) minfps = curfps; if( curfps > maxfps ) maxfps = curfps; - if( cl_showfps->value == 2 ) + if( cl_showfps.value == 2 ) Q_snprintf( fpsstring, sizeof( fpsstring ), "fps: ^1%4i min, ^3%4i cur, ^2%4i max", minfps, curfps, maxfps ); else Q_snprintf( fpsstring, sizeof( fpsstring ), "%4i fps", curfps ); MakeRGBA( color, 255, 255, 255, 255 ); @@ -119,7 +119,7 @@ void SCR_DrawPos( void ) cl_entity_t *ent; rgba_t color; - if( cls.state != ca_active || !cl_showpos->value || cl.background ) + if( cls.state != ca_active || !cl_showpos.value || cl.background ) return; ent = CL_GetLocalPlayer(); @@ -164,7 +164,7 @@ void SCR_NetSpeeds( void ) if( !host.allow_console ) return; - if( !net_speeds->value || cls.state != ca_active ) + if( !net_speeds.value || cls.state != ca_active ) return; // prevent to get too big values at max @@ -290,7 +290,7 @@ void SCR_MakeScreenShot( void ) if( cls.envshot_viewsize > 0 ) viewsize = cls.envshot_viewsize; - else viewsize = cl_envshot_size->value; + else viewsize = cl_envshot_size.value; switch( cls.scrshot_action ) { @@ -344,9 +344,9 @@ SCR_DrawPlaque */ void SCR_DrawPlaque( void ) { - if(( cl_allow_levelshots->value && !cls.changelevel ) || cl.background ) + if(( cl_allow_levelshots.value && !cls.changelevel ) || cl.background ) { - int levelshot = ref.dllFuncs.GL_LoadTexture( cl_levelshot_name->string, NULL, 0, TF_IMAGE ); + int levelshot = ref.dllFuncs.GL_LoadTexture( cl_levelshot_name.string, NULL, 0, TF_IMAGE ); ref.dllFuncs.GL_SetRenderMode( kRenderNormal ); ref.dllFuncs.R_DrawStretchPic( 0, 0, refState.width, refState.height, 0, 0, 1, 1, levelshot ); if( !cl.background ) CL_DrawHUD( CL_LOADING ); @@ -442,7 +442,7 @@ void SCR_TileClear( void ) int i, top, bottom, left, right; dirty_t clear; - if( scr_viewsize->value >= 120 ) + if( scr_viewsize.value >= 120 ) return; // full screen rendering // erase rect will be the union of the past three frames @@ -652,13 +652,13 @@ void SCR_RegisterTextures( void ) if( FS_FileExists( "gfx/lambda.lmp", false )) { - if( cl_allow_levelshots->value ) + if( cl_allow_levelshots.value ) cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE ); else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE ); } else if( FS_FileExists( "gfx/loading.lmp", false )) { - if( cl_allow_levelshots->value ) + if( cl_allow_levelshots.value ) cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE ); else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE ); } @@ -675,7 +675,7 @@ Keybinding command */ void SCR_SizeUp_f( void ) { - Cvar_SetValue( "viewsize", Q_min( scr_viewsize->value + 10, 120 )); + Cvar_SetValue( "viewsize", Q_min( scr_viewsize.value + 10, 120 )); } @@ -688,7 +688,7 @@ Keybinding command */ void SCR_SizeDown_f( void ) { - Cvar_SetValue( "viewsize", Q_max( scr_viewsize->value - 10, 30 )); + Cvar_SetValue( "viewsize", Q_max( scr_viewsize.value - 10, 30 )); } /* @@ -737,18 +737,18 @@ void SCR_Init( void ) { if( scr_init ) return; - scr_centertime = Cvar_Get( "scr_centertime", "2.5", 0, "centerprint hold time" ); - cl_levelshot_name = Cvar_Get( "cl_levelshot_name", "*black", 0, "contains path to current levelshot" ); - cl_allow_levelshots = Cvar_Get( "allow_levelshots", "0", FCVAR_ARCHIVE, "allow engine to use indivdual levelshots instead of 'loading' image" ); - scr_loading = Cvar_Get( "scr_loading", "0", 0, "loading bar progress" ); - scr_download = Cvar_Get( "scr_download", "-1", 0, "downloading bar progress" ); - cl_testlights = Cvar_Get( "cl_testlights", "0", 0, "test dynamic lights" ); - cl_envshot_size = Cvar_Get( "cl_envshot_size", "256", FCVAR_ARCHIVE, "envshot size of cube side" ); - v_dark = Cvar_Get( "v_dark", "0", 0, "starts level from dark screen" ); - scr_viewsize = Cvar_Get( "viewsize", "120", FCVAR_ARCHIVE, "screen size" ); - net_speeds = Cvar_Get( "net_speeds", "0", FCVAR_ARCHIVE, "show network packets" ); - cl_showfps = Cvar_Get( "cl_showfps", "0", FCVAR_ARCHIVE, "show client fps" ); - cl_showpos = Cvar_Get( "cl_showpos", "0", FCVAR_ARCHIVE, "show local player position and velocity" ); + Cvar_RegisterVariable( &scr_centertime ); + Cvar_RegisterVariable( &cl_levelshot_name ); + Cvar_RegisterVariable( &cl_allow_levelshots ); + Cvar_RegisterVariable( &scr_loading ); + Cvar_RegisterVariable( &scr_download ); + Cvar_RegisterVariable( &cl_testlights ); + Cvar_RegisterVariable( &cl_envshot_size ); + Cvar_RegisterVariable( &v_dark ); + Cvar_RegisterVariable( &scr_viewsize ); + Cvar_RegisterVariable( &net_speeds ); + Cvar_RegisterVariable( &cl_showfps ); + Cvar_RegisterVariable( &cl_showpos ); // register our commands Cmd_AddCommand( "skyname", CL_SetSky_f, "set new skybox by basename" ); diff --git a/engine/client/cl_tent.c b/engine/client/cl_tent.c index 110318ff..300160aa 100644 --- a/engine/client/cl_tent.c +++ b/engine/client/cl_tent.c @@ -2843,10 +2843,10 @@ void CL_TestLights( void ) float f, r; dlight_t *dl; - if( !CVAR_TO_BOOL( cl_testlights )) + if( !cl_testlights.value ) return; - numLights = bound( 1, cl_testlights->value, MAX_DLIGHTS ); + numLights = bound( 1, cl_testlights.value, MAX_DLIGHTS ); AngleVectors( cl.viewangles, forward, right, NULL ); for( i = 0; i < numLights; i++ ) diff --git a/engine/client/cl_view.c b/engine/client/cl_view.c index 4b195168..9600c6f5 100644 --- a/engine/client/cl_view.c +++ b/engine/client/cl_view.c @@ -39,7 +39,7 @@ void V_CalcViewRect( void ) { // intermission is always full screen if( cl.intermission ) size = 120.0f; - else size = scr_viewsize->value; + else size = scr_viewsize.value; if( size >= 120.0f ) sb_lines = 0; // no status bar at all @@ -47,12 +47,12 @@ void V_CalcViewRect( void ) sb_lines = 24; // no inventory else sb_lines = 48; - if( scr_viewsize->value >= 100.0f ) + if( scr_viewsize.value >= 100.0f ) { full = true; size = 100.0f; } - else size = scr_viewsize->value; + else size = scr_viewsize.value; if( cl.intermission ) { @@ -144,7 +144,7 @@ void V_SetRefParams( ref_params_t *fd ) VectorCopy( cl.viewangles, fd->cl_viewangles ); fd->health = cl.local.health; VectorCopy( cl.crosshairangle, fd->crosshairangle ); - fd->viewsize = scr_viewsize->value; + fd->viewsize = scr_viewsize.value; VectorCopy( cl.punchangle, fd->punchangle ); fd->maxclients = cl.maxclients; diff --git a/engine/client/client.h b/engine/client/client.h index 333a05ad..b4975b36 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -668,16 +668,16 @@ extern convar_t cl_showerror; extern convar_t cl_nosmooth; extern convar_t cl_smoothtime; extern convar_t cl_crosshair; -extern convar_t *cl_testlights; +extern convar_t cl_testlights; extern convar_t cl_cmdrate; extern convar_t cl_updaterate; extern convar_t cl_solid_players; extern convar_t cl_idealpitchscale; -extern convar_t *cl_allow_levelshots; +extern convar_t cl_allow_levelshots; extern convar_t cl_lightstyle_lerping; extern convar_t cl_draw_particles; extern convar_t cl_draw_tracers; -extern convar_t *cl_levelshot_name; +extern convar_t cl_levelshot_name; extern convar_t cl_draw_beams; extern convar_t cl_clockreset; extern convar_t cl_fixtimerate; @@ -690,10 +690,10 @@ extern convar_t cl_charset; extern convar_t cl_trace_messages; extern convar_t hud_utf8; extern convar_t cl_showevents; -extern convar_t *scr_centertime; -extern convar_t *scr_viewsize; -extern convar_t *scr_loading; -extern convar_t *v_dark; // start from dark +extern convar_t scr_centertime; +extern convar_t scr_viewsize; +extern convar_t scr_loading; +extern convar_t v_dark; // start from dark extern convar_t *net_graph; extern convar_t rate; extern convar_t m_ignore; diff --git a/engine/client/console.c b/engine/client/console.c index 1585740e..e5633e6a 100644 --- a/engine/client/console.c +++ b/engine/client/console.c @@ -1754,10 +1754,10 @@ void Con_DrawDebug( void ) string dlstring; int x, y; - if( scr_download->value != -1.0f ) + if( scr_download.value != -1.0f ) { Q_snprintf( dlstring, sizeof( dlstring ), "Downloading [%d remaining]: ^2%s^7 %5.1f%% time %.f secs", - host.downloadcount, host.downloadfile, scr_download->value, Sys_DoubleTime() - timeStart ); + host.downloadcount, host.downloadfile, scr_download.value, Sys_DoubleTime() - timeStart ); x = refState.width - 500; y = con.curFont->charHeight * 1.05f; Con_DrawString( x, y, dlstring, g_color_table[7] ); @@ -1981,7 +1981,7 @@ void Con_DrawConsole( void ) if( cls.state == ca_connecting || cls.state == ca_connected ) { - if( !cl_allow_levelshots->value ) + if( !cl_allow_levelshots.value ) { if(( Cvar_VariableInteger( "cl_background" ) || Cvar_VariableInteger( "sv_background" )) && cls.key_dest != key_console ) con.vislines = con.showlines = 0; diff --git a/engine/client/vid_common.c b/engine/client/vid_common.c index 2cab21ea..db679020 100644 --- a/engine/client/vid_common.c +++ b/engine/client/vid_common.c @@ -124,11 +124,11 @@ check vid modes and fullscreen */ void VID_CheckChanges( void ) { - if( FBitSet( cl_allow_levelshots->flags, FCVAR_CHANGED )) + if( FBitSet( cl_allow_levelshots.flags, FCVAR_CHANGED )) { //GL_FreeTexture( cls.loadingBar ); SCR_RegisterTextures(); // reload 'lambda' image - ClearBits( cl_allow_levelshots->flags, FCVAR_CHANGED ); + ClearBits( cl_allow_levelshots.flags, FCVAR_CHANGED ); } if( host.renderinfo_changed ) diff --git a/engine/common/common.h b/engine/common/common.h index 92123280..61e39ef8 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -154,11 +154,11 @@ void DBG_AssertFunction( qboolean fExpr, const char* szExpr, const char* szFile, #endif extern convar_t gl_vsync; -extern convar_t *scr_loading; -extern convar_t *scr_download; +extern convar_t scr_loading; +extern convar_t scr_download; extern convar_t *cmd_scripting; extern convar_t *sv_maxclients; -extern convar_t *cl_allow_levelshots; +extern convar_t cl_allow_levelshots; extern convar_t host_developer; extern convar_t *host_limitlocal; extern convar_t *host_framerate; diff --git a/engine/common/net_chan.c b/engine/common/net_chan.c index aec27f75..00dde888 100644 --- a/engine/common/net_chan.c +++ b/engine/common/net_chan.c @@ -1331,7 +1331,7 @@ void Netchan_UpdateProgress( netchan_t *chan ) if( host.downloadcount == 0 ) { - scr_download->value = -1.0f; + scr_download.value = -1.0f; host.downloadfile[0] = '\0'; } @@ -1399,7 +1399,7 @@ void Netchan_UpdateProgress( netchan_t *chan ) } - scr_download->value = bestpercent; + scr_download.value = bestpercent; #endif // XASH_DEDICATED }