From 71b841adeba37bfe780f69ff9ed54e9b9fe1d370 Mon Sep 17 00:00:00 2001 From: Jeff Teunissen Date: Mon, 25 Sep 2000 06:36:50 +0000 Subject: [PATCH] Cvar audit; These files set cvars improperly, by changing their values without using Cvar_SetValue (). --- source/cd_linux.c | 12 ++++-------- source/cd_sdl.c | 14 +++++--------- source/cl_parse.c | 2 +- source/gl_rmain.c | 4 ++-- source/gl_rsurf.c | 4 ++-- source/gl_screen.c | 14 ++++---------- source/in_x11.c | 2 +- source/net_chan.c | 2 +- source/r_main.c | 4 ++-- source/r_misc.c | 42 ++++++++++++++++++------------------------ source/skin.c | 2 +- source/sv_ccmds.c | 1 + source/vid_mgl.c | 25 +++++++++---------------- source/vid_svgalib.c | 10 +++++----- 14 files changed, 56 insertions(+), 82 deletions(-) diff --git a/source/cd_linux.c b/source/cd_linux.c index 1102359..1c9a51a 100644 --- a/source/cd_linux.c +++ b/source/cd_linux.c @@ -346,17 +346,13 @@ void CDAudio_Update(void) if (!enabled) return; - if (bgmvolume->value != cdvolume) - { - if (cdvolume) - { + if (bgmvolume->value != cdvolume) { + if (cdvolume) { Cvar_SetValue (bgmvolume, 0.0); cdvolume = bgmvolume->value; CDAudio_Pause (); - } - else - { - bgmvolume->value = 1.0; + } else { + Cvar_SetValue (bgmvolume, 1.0); cdvolume = bgmvolume->value; CDAudio_Resume (); } diff --git a/source/cd_sdl.c b/source/cd_sdl.c index ed404e7..ea4bab3 100644 --- a/source/cd_sdl.c +++ b/source/cd_sdl.c @@ -130,16 +130,12 @@ void CDAudio_Resume() void CDAudio_Update() { if(!cd_id || !enabled) return; - if(bgmvolume->value != cdvolume) - { - if(cdvolume) - { - bgmvolume->value = 0.0; + if(bgmvolume->value != cdvolume) { + if(cdvolume) { + Cvar_SetValue (bgmvolume, 0.0); CDAudio_Pause(); - } - else - { - bgmvolume->value = 1.0; + } else { + Cvar_SetValue (bgmvolume, 1.0); CDAudio_Resume(); } cdvolume = bgmvolume->value; diff --git a/source/cl_parse.c b/source/cl_parse.c index 2207409..328a408 100644 --- a/source/cl_parse.c +++ b/source/cl_parse.c @@ -1105,7 +1105,7 @@ void CL_MuzzleFlash (void) } -#define SHOWNET(x) if(cl_shownet->value==2)Con_Printf ("%3i:%s\n", msg_readcount-1, x); +#define SHOWNET(x) if (cl_shownet->value == 2) Con_Printf ("%3i:%s\n", msg_readcount-1, x); /* ===================== CL_ParseServerMessage diff --git a/source/gl_rmain.c b/source/gl_rmain.c index 42df92d..e54d12e 100644 --- a/source/gl_rmain.c +++ b/source/gl_rmain.c @@ -834,8 +834,8 @@ R_SetupFrame static void R_SetupFrame (void) { // don't allow cheats in multiplayer - r_fullbright->value = 0; - r_lightmap->value = 0; + Cvar_SetValue (r_fullbright, 0); + Cvar_SetValue (r_lightmap, 0); if (!atoi(Info_ValueForKey(cl.serverinfo, "watervis"))) Cvar_SetValue(r_wateralpha, 1); diff --git a/source/gl_rsurf.c b/source/gl_rsurf.c index 21f960b..3b6575c 100644 --- a/source/gl_rsurf.c +++ b/source/gl_rsurf.c @@ -812,7 +812,7 @@ void R_DrawBrushModel (entity_t *e) // LordHavoc: anyone without multitexture won't want texsort 0 anyway... if (!gl_mtexable) - gl_texsort->value = 1; + Cvar_SetValue (gl_texsort, 1); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); @@ -997,7 +997,7 @@ void R_DrawWorld (void) // LordHavoc: anyone without multitexture won't want texsort 0 anyway... if (!gl_mtexable) - gl_texsort->value = 1; + Cvar_SetValue (gl_texsort, 1); glColor3f (1.0, 1.0, 1.0); memset (lightmap_polys, 0, sizeof(lightmap_polys)); diff --git a/source/gl_screen.c b/source/gl_screen.c index e979169..4fa014f 100644 --- a/source/gl_screen.c +++ b/source/gl_screen.c @@ -310,16 +310,10 @@ static void SCR_CalcRefdef (void) //======================================== // bound viewsize - if (scr_viewsize->value < 30) - Cvar_Set (scr_viewsize,"30"); - if (scr_viewsize->value > 120) - Cvar_Set (scr_viewsize,"120"); + Cvar_SetValue (scr_viewsize, bound (30, scr_viewsize->value, 120); // bound field of view - if (scr_fov->value < 10) - Cvar_Set (scr_fov,"10"); - if (scr_fov->value > 170) - Cvar_Set (scr_fov,"170"); + Cvar_Set (scr_fov, bound (10, scr_fov->value, 170); // intermission is always full screen if (cl.intermission) @@ -1240,7 +1234,7 @@ void SCR_UpdateScreen (void) // also makes polyblend apply to whole screen glDisable(GL_TEXTURE_2D); glEnable(GL_BLEND); - brightness->value = bound(1, brightness->value, 5); + Cvar_SetValue (brightness, bound (1, brightness->value, 5)); if (lighthalf) // LordHavoc: render was done at half brightness f = brightness->value * 2; else @@ -1264,7 +1258,7 @@ void SCR_UpdateScreen (void) glEnd (); } glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - contrast->value = bound(0.1, contrast->value, 1.0); + Cvar_SetValue (contrast, bound (0.1, contrast->value, 1)); if ((gl_polyblend->value && v_blend[3]) || contrast->value < 1) { glBegin (GL_QUADS); diff --git a/source/in_x11.c b/source/in_x11.c index e50c650..16398c8 100644 --- a/source/in_x11.c +++ b/source/in_x11.c @@ -376,7 +376,7 @@ static void IN_ExtraOptionCmd(int option_cursor) { switch (option_cursor) { case 1: // _windowed_mouse - _windowed_mouse->value = !_windowed_mouse->value; + Cvar_SetValue (_windowed_mouse, !_windowed_mouse->value); break; } } diff --git a/source/net_chan.c b/source/net_chan.c index 514ac9e..72660dc 100644 --- a/source/net_chan.c +++ b/source/net_chan.c @@ -127,7 +127,7 @@ void Netchan_Init (void) showpackets = Cvar_Get("showpackets", "0", CVAR_NONE, "None"); showdrop = Cvar_Get("showdrop", "0", CVAR_NONE, "None"); qport = Cvar_Get("qport", "0", CVAR_NONE, "None"); - qport->value = port; + Cvar_SetValue (qport, port); } /* diff --git a/source/r_main.c b/source/r_main.c index 218d72a..4cc8f2a 100644 --- a/source/r_main.c +++ b/source/r_main.c @@ -244,8 +244,8 @@ void R_Init (void) r_aliastransadj = Cvar_Get("r_aliastransadj", "100", CVAR_NONE, "None"); gl_flashblend = Cvar_Get("gl_flashblend", "0", CVAR_NONE, "None"); // FIXME: remove this! --KB - r_maxedges->value = (float)NUMSTACKEDGES; - r_maxsurfs->value = (float)NUMSTACKSURFACES; + Cvar_SetValue (r_maxedges, (float)NUMSTACKEDGES); + Cvar_SetValue (r_maxsurfs, (float)NUMSTACKSURFACES); view_clipplanes[0].leftedge = true; view_clipplanes[1].rightedge = true; diff --git a/source/r_misc.c b/source/r_misc.c index 114d343..2bdccf8 100644 --- a/source/r_misc.c +++ b/source/r_misc.c @@ -479,14 +479,13 @@ void R_SetupFrame (void) vrect_t vrect; float w, h; -// don't allow cheats in multiplayer -r_draworder->value = 0; -r_fullbright->value = 0; -r_ambient->value = 0; -r_drawflat->value = 0; + // don't allow cheats in multiplayer + Cvar_SetValue(r_draworder, 0); + Cvar_SetValue(r_fullbright, 0); + Cvar_SetValue(r_ambient, 0); + Cvar_SetValue(r_drawflat, 0); - if (r_numsurfs->value) - { + if (r_numsurfs->value) { if ((surface_p - surfaces) > r_maxsurfsseen) r_maxsurfsseen = surface_p - surfaces; @@ -494,8 +493,7 @@ r_drawflat->value = 0; surf_max - surfaces, r_maxsurfsseen); } - if (r_numedges->value) - { + if (r_numedges->value) { edgecount = edge_p - r_edges; if (edgecount > r_maxedgesseen) @@ -505,13 +503,9 @@ r_drawflat->value = 0; r_numallocatededges, r_maxedgesseen); } - r_refdef.ambientlight = r_ambient->value; + r_refdef.ambientlight = max(r_ambient->value, 0); - if (r_refdef.ambientlight < 0) - r_refdef.ambientlight = 0; - -// if (!sv.active) - r_draworder->value = 0; // don't let cheaters look behind walls + Cvar_SetValue(r_draworder, 0); R_CheckVariables (); @@ -521,23 +515,23 @@ r_drawflat->value = 0; numbtofpolys = 0; -// debugging + // debugging #if 0 -r_refdef.vieworg[0]= 80; -r_refdef.vieworg[1]= 64; -r_refdef.vieworg[2]= 40; -r_refdef.viewangles[0]= 0; -r_refdef.viewangles[1]= 46.763641357; -r_refdef.viewangles[2]= 0; + r_refdef.vieworg[0] = 80; + r_refdef.vieworg[1] = 64; + r_refdef.vieworg[2] = 40; + r_refdef.viewangles[0] = 0; + r_refdef.viewangles[1] = 46.763641357; + r_refdef.viewangles[2] = 0; #endif -// build the transformation matrix for the given view angles + // build the transformation matrix for the given view angles VectorCopy (r_refdef.vieworg, modelorg); VectorCopy (r_refdef.vieworg, r_origin); AngleVectors (r_refdef.viewangles, vpn, vright, vup); -// current viewleaf + // current viewleaf r_oldviewleaf = r_viewleaf; r_viewleaf = Mod_PointInLeaf (r_origin, cl.worldmodel); diff --git a/source/skin.c b/source/skin.c index 843e923..c3bca89 100644 --- a/source/skin.c +++ b/source/skin.c @@ -122,7 +122,7 @@ byte *Skin_Cache (skin_t *skin) if (cls.downloadtype == dl_skin) return NULL; // use base until downloaded - if (noskins->value==1) // JACK: So NOSKINS > 1 will show skins, but + if (noskins->value == 1) // JACK: So NOSKINS > 1 will show skins, but return NULL; // not download new ones. if (skin->failedload) diff --git a/source/sv_ccmds.c b/source/sv_ccmds.c index db58220..b7ef10d 100644 --- a/source/sv_ccmds.c +++ b/source/sv_ccmds.c @@ -594,6 +594,7 @@ void SV_Serverinfo_f (void) } Info_SetValueForKey (svs.info, Cmd_Argv(1), Cmd_Argv(2), MAX_SERVERINFO_STRING); + // FIXME This sucks. // if this is a cvar, change it too var = Cvar_FindVar (Cmd_Argv(1)); if (var) diff --git a/source/vid_mgl.c b/source/vid_mgl.c index 379f5aa..b661d93 100644 --- a/source/vid_mgl.c +++ b/source/vid_mgl.c @@ -1096,20 +1096,16 @@ void VID_CheckModedescFixup (int mode) { int x, y, stretch; - if (mode == MODE_SETTABLE_WINDOW) - { - modelist[mode].stretched = (int)vid_stretch_by_2->value; + if (mode == MODE_SETTABLE_WINDOW) { + modelist[mode].stretched = (int) vid_stretch_by_2->value; stretch = modelist[mode].stretched; - if (vid_config_x->value < (320 << stretch)) - vid_config_x->value = 320 << stretch; + Cvar_SetValue (vid_config_x, max (vid_config_x, 320 << stretch)); + Cvar_SetValue (vid_config_y, max (vid_config_y, 200 << stretch)); - if (vid_config_y->value < (200 << stretch)) - vid_config_y->value = 200 << stretch; - - x = (int)vid_config_x->value; - y = (int)vid_config_y->value; - snprintf (modelist[mode].modedesc, sizeof(modelist[mode].modedesc), "%dx%d", x, y); + x = (int) vid_config_x->value; + y = (int) vid_config_y->value; + snprintf (modelist[mode].modedesc, sizeof(modelist[mode].modedesc), "%dx%d", x, y); modelist[mode].width = x; modelist[mode].height = y; } @@ -1134,12 +1130,9 @@ char *VID_GetModeDescriptionMemCheck (int mode) pv = VID_GetModePtr (mode); pinfo = pv->modedesc; - if (VID_CheckAdequateMem (pv->width, pv->height)) - { + if (VID_CheckAdequateMem (pv->width, pv->height)) { return pinfo; - } - else - { + } else { return NULL; } } diff --git a/source/vid_svgalib.c b/source/vid_svgalib.c index b760450..1392ac8 100644 --- a/source/vid_svgalib.c +++ b/source/vid_svgalib.c @@ -405,22 +405,22 @@ VID_SetPalette(byte *palette) int -VID_SetMode(int modenum, unsigned char *palette) +VID_SetMode (int modenum, unsigned char *palette) { int bsize, zsize, tsize; int err; - if ((modenum >= num_modes) || (modenum < 0) || !modes[modenum].width){ - vid_mode->value = (float)current_mode; + if ((modenum >= num_modes) || (modenum < 0) || !modes[modenum].width) { + Cvar_SetValue(vid_mode, current_mode); Con_Printf("No such video mode: %d\n",modenum); return 0; } - vid_mode->value = (float)modenum; + Cvar_SetValue (vid_mode, modenum); - current_mode=modenum; + current_mode = modenum; vid.width = modes[current_mode].width; vid.height = modes[current_mode].height;