Browse Source

engine: client: move scrn cvars to static allocation

pull/2/head
Alibek Omarov 2 years ago
parent
commit
1ee01163b7
  1. 6
      engine/client/cl_demo.c
  2. 2
      engine/client/cl_game.c
  3. 8
      engine/client/cl_parse.c
  4. 4
      engine/client/cl_qparse.c
  5. 72
      engine/client/cl_scrn.c
  6. 4
      engine/client/cl_tent.c
  7. 8
      engine/client/cl_view.c
  8. 14
      engine/client/client.h
  9. 6
      engine/client/console.c
  10. 4
      engine/client/vid_common.c
  11. 6
      engine/common/common.h
  12. 4
      engine/common/net_chan.c

6
engine/client/cl_demo.c

@ -698,7 +698,7 @@ void CL_DemoAborted( void ) @@ -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 ) @@ -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 ) @@ -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 ();

2
engine/client/cl_game.c

@ -458,7 +458,7 @@ void CL_DrawCenterPrint( void ) @@ -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;

8
engine/client/cl_parse.c

@ -974,9 +974,9 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy ) @@ -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 @@ -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 ) @@ -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" );
}
}

4
engine/client/cl_qparse.c

@ -302,9 +302,9 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg ) @@ -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)
}

72
engine/client/cl_scrn.c

@ -20,18 +20,18 @@ GNU General Public License for more details. @@ -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 ) @@ -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 ) @@ -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 ) @@ -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 ) @@ -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 ) @@ -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 @@ -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 ) @@ -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 ) @@ -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 @@ -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 @@ -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 ) @@ -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" );

4
engine/client/cl_tent.c

@ -2843,10 +2843,10 @@ void CL_TestLights( void ) @@ -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++ )

8
engine/client/cl_view.c

@ -39,7 +39,7 @@ void V_CalcViewRect( void ) @@ -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 ) @@ -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 ) @@ -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;

14
engine/client/client.h

@ -668,16 +668,16 @@ extern convar_t cl_showerror; @@ -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; @@ -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;

6
engine/client/console.c

@ -1754,10 +1754,10 @@ void Con_DrawDebug( void ) @@ -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 ) @@ -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;

4
engine/client/vid_common.c

@ -124,11 +124,11 @@ check vid modes and fullscreen @@ -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 )

6
engine/common/common.h

@ -154,11 +154,11 @@ void DBG_AssertFunction( qboolean fExpr, const char* szExpr, const char* szFile, @@ -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;

4
engine/common/net_chan.c

@ -1331,7 +1331,7 @@ void Netchan_UpdateProgress( netchan_t *chan ) @@ -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 ) @@ -1399,7 +1399,7 @@ void Netchan_UpdateProgress( netchan_t *chan )
}
scr_download->value = bestpercent;
scr_download.value = bestpercent;
#endif // XASH_DEDICATED
}

Loading…
Cancel
Save