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 )
cls.demofile = NULL; cls.demofile = NULL;
cls.demonum = -1; 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 ) if( !CL_NextDemo() && !cls.changedemo )
UI_SetActiveMenu( true ); 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 // run demos loop in background mode
Cvar_SetValue( "v_dark", 1.0f ); Cvar_DirectSet( &v_dark, "1" );
cls.demos_pending = false; cls.demos_pending = false;
cls.demonum = 0; cls.demonum = 0;
CL_NextDemo (); CL_NextDemo ();

2
engine/client/cl_game.c

@ -458,7 +458,7 @@ void CL_DrawCenterPrint( void )
if( !clgame.centerPrint.time ) if( !clgame.centerPrint.time )
return; return;
if(( cl.time - clgame.centerPrint.time ) >= scr_centertime->value ) if(( cl.time - clgame.centerPrint.time ) >= scr_centertime.value )
{ {
// time expired // time expired
clgame.centerPrint.time = 0.0f; clgame.centerPrint.time = 0.0f;

8
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" )); 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 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 Cvar_Set( "cl_levelshot_name", "*black" ); // render a black screen
cls.scrshot_request = scrshot_plaque; // request levelshot even if exist (check filetime) cls.scrshot_request = scrshot_plaque; // request levelshot even if exist (check filetime)
} }
@ -1550,7 +1550,7 @@ CL_StartDark
*/ */
static void CL_StartDark( void ) static void CL_StartDark( void )
{ {
if( Cvar_VariableValue( "v_dark" )) if( v_dark.value )
{ {
screenfade_t *sf = &clgame.fade; screenfade_t *sf = &clgame.fade;
float fadetime = 5.0f; float fadetime = 5.0f;
@ -1575,7 +1575,7 @@ static void CL_StartDark( void )
sf->fadeReset += cl.time; sf->fadeReset += cl.time;
sf->fadeEnd += sf->fadeReset; 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 )
else Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", clgame.mapname, refState.wideScreen ? "16x9" : "4x3" )); 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 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 Cvar_Set( "cl_levelshot_name", "*black" ); // render a black screen
cls.scrshot_request = scrshot_plaque; // request levelshot even if exist (check filetime) 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.
#include "input.h" #include "input.h"
#include "library.h" #include "library.h"
convar_t *scr_centertime; CVAR_DEFINE_AUTO( scr_centertime, "2.5", 0, "centerprint hold time" );
convar_t *scr_loading; CVAR_DEFINE_AUTO( scr_loading, "0", 0, "loading bar progress" );
convar_t *scr_download; CVAR_DEFINE_AUTO( scr_download, "-1", 0, "downloading bar progress" );
convar_t *scr_viewsize; CVAR_DEFINE( scr_viewsize, "viewsize", "120", FCVAR_ARCHIVE, "screen size (quake only)" );
convar_t *cl_testlights; CVAR_DEFINE_AUTO( cl_testlights, "0", 0, "test dynamic lights" );
convar_t *cl_allow_levelshots; CVAR_DEFINE( cl_allow_levelshots, "allow_levelshots", "0", FCVAR_ARCHIVE, "allow engine to use indivdual levelshots instead of 'loading' image" );
convar_t *cl_levelshot_name; CVAR_DEFINE_AUTO( cl_levelshot_name, "*black", 0, "contains path to current levelshot" );
static convar_t *cl_envshot_size; static CVAR_DEFINE_AUTO( cl_envshot_size, "256", FCVAR_ARCHIVE, "envshot size of cube side" );
convar_t *v_dark; CVAR_DEFINE_AUTO( v_dark, "0", 0, "starts level from dark screen" );
static convar_t *net_speeds; static CVAR_DEFINE_AUTO( net_speeds, "0", FCVAR_ARCHIVE, "show network packets" );
static convar_t *cl_showfps; static CVAR_DEFINE_AUTO( cl_showfps, "0", FCVAR_ARCHIVE, "show client fps" );
static convar_t *cl_showpos; static CVAR_DEFINE_AUTO( cl_showpos, "0", FCVAR_ARCHIVE, "show local player position and velocity" );
typedef struct typedef struct
{ {
@ -59,7 +59,7 @@ void SCR_DrawFPS( int height )
char fpsstring[64]; char fpsstring[64];
int offset; int offset;
if( cls.state != ca_active || !cl_showfps->value || cl.background ) if( cls.state != ca_active || !cl_showfps.value || cl.background )
return; return;
switch( cls.scrshot_action ) switch( cls.scrshot_action )
@ -95,7 +95,7 @@ void SCR_DrawFPS( int height )
if( curfps < minfps ) minfps = curfps; if( curfps < minfps ) minfps = curfps;
if( curfps > maxfps ) maxfps = 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 ); 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 ); else Q_snprintf( fpsstring, sizeof( fpsstring ), "%4i fps", curfps );
MakeRGBA( color, 255, 255, 255, 255 ); MakeRGBA( color, 255, 255, 255, 255 );
@ -119,7 +119,7 @@ void SCR_DrawPos( void )
cl_entity_t *ent; cl_entity_t *ent;
rgba_t color; rgba_t color;
if( cls.state != ca_active || !cl_showpos->value || cl.background ) if( cls.state != ca_active || !cl_showpos.value || cl.background )
return; return;
ent = CL_GetLocalPlayer(); ent = CL_GetLocalPlayer();
@ -164,7 +164,7 @@ void SCR_NetSpeeds( void )
if( !host.allow_console ) if( !host.allow_console )
return; return;
if( !net_speeds->value || cls.state != ca_active ) if( !net_speeds.value || cls.state != ca_active )
return; return;
// prevent to get too big values at max // prevent to get too big values at max
@ -290,7 +290,7 @@ void SCR_MakeScreenShot( void )
if( cls.envshot_viewsize > 0 ) if( cls.envshot_viewsize > 0 )
viewsize = cls.envshot_viewsize; viewsize = cls.envshot_viewsize;
else viewsize = cl_envshot_size->value; else viewsize = cl_envshot_size.value;
switch( cls.scrshot_action ) switch( cls.scrshot_action )
{ {
@ -344,9 +344,9 @@ SCR_DrawPlaque
*/ */
void SCR_DrawPlaque( void ) 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.GL_SetRenderMode( kRenderNormal );
ref.dllFuncs.R_DrawStretchPic( 0, 0, refState.width, refState.height, 0, 0, 1, 1, levelshot ); ref.dllFuncs.R_DrawStretchPic( 0, 0, refState.width, refState.height, 0, 0, 1, 1, levelshot );
if( !cl.background ) CL_DrawHUD( CL_LOADING ); if( !cl.background ) CL_DrawHUD( CL_LOADING );
@ -442,7 +442,7 @@ void SCR_TileClear( void )
int i, top, bottom, left, right; int i, top, bottom, left, right;
dirty_t clear; dirty_t clear;
if( scr_viewsize->value >= 120 ) if( scr_viewsize.value >= 120 )
return; // full screen rendering return; // full screen rendering
// erase rect will be the union of the past three frames // 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( 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 ); 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 cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE );
} }
else if( FS_FileExists( "gfx/loading.lmp", false )) 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 ); 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 ); 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 ) 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 ) 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; if( scr_init ) return;
scr_centertime = Cvar_Get( "scr_centertime", "2.5", 0, "centerprint hold time" ); Cvar_RegisterVariable( &scr_centertime );
cl_levelshot_name = Cvar_Get( "cl_levelshot_name", "*black", 0, "contains path to current levelshot" ); Cvar_RegisterVariable( &cl_levelshot_name );
cl_allow_levelshots = Cvar_Get( "allow_levelshots", "0", FCVAR_ARCHIVE, "allow engine to use indivdual levelshots instead of 'loading' image" ); Cvar_RegisterVariable( &cl_allow_levelshots );
scr_loading = Cvar_Get( "scr_loading", "0", 0, "loading bar progress" ); Cvar_RegisterVariable( &scr_loading );
scr_download = Cvar_Get( "scr_download", "-1", 0, "downloading bar progress" ); Cvar_RegisterVariable( &scr_download );
cl_testlights = Cvar_Get( "cl_testlights", "0", 0, "test dynamic lights" ); Cvar_RegisterVariable( &cl_testlights );
cl_envshot_size = Cvar_Get( "cl_envshot_size", "256", FCVAR_ARCHIVE, "envshot size of cube side" ); Cvar_RegisterVariable( &cl_envshot_size );
v_dark = Cvar_Get( "v_dark", "0", 0, "starts level from dark screen" ); Cvar_RegisterVariable( &v_dark );
scr_viewsize = Cvar_Get( "viewsize", "120", FCVAR_ARCHIVE, "screen size" ); Cvar_RegisterVariable( &scr_viewsize );
net_speeds = Cvar_Get( "net_speeds", "0", FCVAR_ARCHIVE, "show network packets" ); Cvar_RegisterVariable( &net_speeds );
cl_showfps = Cvar_Get( "cl_showfps", "0", FCVAR_ARCHIVE, "show client fps" ); Cvar_RegisterVariable( &cl_showfps );
cl_showpos = Cvar_Get( "cl_showpos", "0", FCVAR_ARCHIVE, "show local player position and velocity" ); Cvar_RegisterVariable( &cl_showpos );
// register our commands // register our commands
Cmd_AddCommand( "skyname", CL_SetSky_f, "set new skybox by basename" ); 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 )
float f, r; float f, r;
dlight_t *dl; dlight_t *dl;
if( !CVAR_TO_BOOL( cl_testlights )) if( !cl_testlights.value )
return; return;
numLights = bound( 1, cl_testlights->value, MAX_DLIGHTS ); numLights = bound( 1, cl_testlights.value, MAX_DLIGHTS );
AngleVectors( cl.viewangles, forward, right, NULL ); AngleVectors( cl.viewangles, forward, right, NULL );
for( i = 0; i < numLights; i++ ) for( i = 0; i < numLights; i++ )

8
engine/client/cl_view.c

@ -39,7 +39,7 @@ void V_CalcViewRect( void )
{ {
// intermission is always full screen // intermission is always full screen
if( cl.intermission ) size = 120.0f; if( cl.intermission ) size = 120.0f;
else size = scr_viewsize->value; else size = scr_viewsize.value;
if( size >= 120.0f ) if( size >= 120.0f )
sb_lines = 0; // no status bar at all sb_lines = 0; // no status bar at all
@ -47,12 +47,12 @@ void V_CalcViewRect( void )
sb_lines = 24; // no inventory sb_lines = 24; // no inventory
else sb_lines = 48; else sb_lines = 48;
if( scr_viewsize->value >= 100.0f ) if( scr_viewsize.value >= 100.0f )
{ {
full = true; full = true;
size = 100.0f; size = 100.0f;
} }
else size = scr_viewsize->value; else size = scr_viewsize.value;
if( cl.intermission ) if( cl.intermission )
{ {
@ -144,7 +144,7 @@ void V_SetRefParams( ref_params_t *fd )
VectorCopy( cl.viewangles, fd->cl_viewangles ); VectorCopy( cl.viewangles, fd->cl_viewangles );
fd->health = cl.local.health; fd->health = cl.local.health;
VectorCopy( cl.crosshairangle, fd->crosshairangle ); VectorCopy( cl.crosshairangle, fd->crosshairangle );
fd->viewsize = scr_viewsize->value; fd->viewsize = scr_viewsize.value;
VectorCopy( cl.punchangle, fd->punchangle ); VectorCopy( cl.punchangle, fd->punchangle );
fd->maxclients = cl.maxclients; fd->maxclients = cl.maxclients;

14
engine/client/client.h

@ -668,16 +668,16 @@ extern convar_t cl_showerror;
extern convar_t cl_nosmooth; extern convar_t cl_nosmooth;
extern convar_t cl_smoothtime; extern convar_t cl_smoothtime;
extern convar_t cl_crosshair; extern convar_t cl_crosshair;
extern convar_t *cl_testlights; extern convar_t cl_testlights;
extern convar_t cl_cmdrate; extern convar_t cl_cmdrate;
extern convar_t cl_updaterate; extern convar_t cl_updaterate;
extern convar_t cl_solid_players; extern convar_t cl_solid_players;
extern convar_t cl_idealpitchscale; 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_lightstyle_lerping;
extern convar_t cl_draw_particles; extern convar_t cl_draw_particles;
extern convar_t cl_draw_tracers; 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_draw_beams;
extern convar_t cl_clockreset; extern convar_t cl_clockreset;
extern convar_t cl_fixtimerate; extern convar_t cl_fixtimerate;
@ -690,10 +690,10 @@ extern convar_t cl_charset;
extern convar_t cl_trace_messages; extern convar_t cl_trace_messages;
extern convar_t hud_utf8; extern convar_t hud_utf8;
extern convar_t cl_showevents; extern convar_t cl_showevents;
extern convar_t *scr_centertime; extern convar_t scr_centertime;
extern convar_t *scr_viewsize; extern convar_t scr_viewsize;
extern convar_t *scr_loading; extern convar_t scr_loading;
extern convar_t *v_dark; // start from dark extern convar_t v_dark; // start from dark
extern convar_t *net_graph; extern convar_t *net_graph;
extern convar_t rate; extern convar_t rate;
extern convar_t m_ignore; extern convar_t m_ignore;

6
engine/client/console.c

@ -1754,10 +1754,10 @@ void Con_DrawDebug( void )
string dlstring; string dlstring;
int x, y; 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", 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; x = refState.width - 500;
y = con.curFont->charHeight * 1.05f; y = con.curFont->charHeight * 1.05f;
Con_DrawString( x, y, dlstring, g_color_table[7] ); 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( 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 ) if(( Cvar_VariableInteger( "cl_background" ) || Cvar_VariableInteger( "sv_background" )) && cls.key_dest != key_console )
con.vislines = con.showlines = 0; con.vislines = con.showlines = 0;

4
engine/client/vid_common.c

@ -124,11 +124,11 @@ check vid modes and fullscreen
*/ */
void VID_CheckChanges( void ) void VID_CheckChanges( void )
{ {
if( FBitSet( cl_allow_levelshots->flags, FCVAR_CHANGED )) if( FBitSet( cl_allow_levelshots.flags, FCVAR_CHANGED ))
{ {
//GL_FreeTexture( cls.loadingBar ); //GL_FreeTexture( cls.loadingBar );
SCR_RegisterTextures(); // reload 'lambda' image SCR_RegisterTextures(); // reload 'lambda' image
ClearBits( cl_allow_levelshots->flags, FCVAR_CHANGED ); ClearBits( cl_allow_levelshots.flags, FCVAR_CHANGED );
} }
if( host.renderinfo_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,
#endif #endif
extern convar_t gl_vsync; extern convar_t gl_vsync;
extern convar_t *scr_loading; extern convar_t scr_loading;
extern convar_t *scr_download; extern convar_t scr_download;
extern convar_t *cmd_scripting; extern convar_t *cmd_scripting;
extern convar_t *sv_maxclients; 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_developer;
extern convar_t *host_limitlocal; extern convar_t *host_limitlocal;
extern convar_t *host_framerate; extern convar_t *host_framerate;

4
engine/common/net_chan.c

@ -1331,7 +1331,7 @@ void Netchan_UpdateProgress( netchan_t *chan )
if( host.downloadcount == 0 ) if( host.downloadcount == 0 )
{ {
scr_download->value = -1.0f; scr_download.value = -1.0f;
host.downloadfile[0] = '\0'; 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 #endif // XASH_DEDICATED
} }

Loading…
Cancel
Save