From bd3cab06a37858c2e998fc144920dfe11e5be897 Mon Sep 17 00:00:00 2001 From: TimeServ Date: Fri, 21 Apr 2006 05:23:51 +0000 Subject: [PATCH] probably overdoing the callback thing now but oh well! (changed r_explosionlight, r_stains, r_rocketlight, scr_conalpha) git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2227 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_ents.c | 5 ++--- engine/client/cl_main.c | 2 +- engine/client/cl_tent.c | 24 ++++++++++++------------ engine/client/pr_csqc.c | 6 +++--- engine/client/renderer.c | 4 ++-- engine/common/cvar.c | 15 +++++++++++++++ engine/common/cvar.h | 3 +++ engine/gl/gl_draw.c | 2 +- engine/gl/gl_rsurf.c | 12 ++++++------ engine/sw/r_surf.c | 2 +- engine/sw/sw_draw.c | 4 ++-- 11 files changed, 48 insertions(+), 31 deletions(-) diff --git a/engine/client/cl_ents.c b/engine/client/cl_ents.c index b25ebf2dc..4065ea647 100644 --- a/engine/client/cl_ents.c +++ b/engine/client/cl_ents.c @@ -1801,7 +1801,6 @@ void CL_LinkPacketEntities (void) } } - //dlights are not so customisable. if (r_rocketlight.value) { @@ -1844,7 +1843,7 @@ void CL_LinkPacketEntities (void) dl->die = (float)cl.time; if (model->flags & EF_ROCKET) dl->origin[2] += 1; // is this even necessary - dl->radius = rad * bound(0, r_rocketlight.value, 1); + dl->radius = rad * r_rocketlight.value; VectorCopy(dclr, dl->color); } @@ -2150,7 +2149,7 @@ void CL_LinkPacketEntities (void) dl->die = (float)cl.time; if (model->flags & EF_ROCKET) dl->origin[2] += 1; // is this even necessary - dl->radius = rad * bound(0, r_rocketlight.value, 1); + dl->radius = rad * r_rocketlight.value; VectorCopy(dclr, dl->color); } diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 1bc183dc1..78b9dd144 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -109,7 +109,7 @@ cvar_t cl_chatsound = SCVAR("cl_chatsound","1"); cvar_t cl_enemychatsound = SCVAR("cl_enemychatsound", "misc/talk.wav"); cvar_t cl_teamchatsound = SCVAR("cl_teamchatsound", "misc/talk.wav"); -cvar_t r_rocketlight = SCVAR("r_rocketlight", "1"); +cvar_t r_rocketlight = SCVARC("r_rocketlight", "1", Cvar_Limiter_ZeroToOne_Callback); cvar_t r_lightflicker = SCVAR("r_lightflicker", "1"); cvar_t cl_r2g = SCVAR("cl_r2g", "0"); cvar_t r_powerupglow = SCVAR("r_powerupglow", "1"); diff --git a/engine/client/cl_tent.c b/engine/client/cl_tent.c index 1cad6ebea..500de896e 100644 --- a/engine/client/cl_tent.c +++ b/engine/client/cl_tent.c @@ -174,7 +174,7 @@ sfx_t *cl_sfx_ric3; sfx_t *cl_sfx_r_exp3; cvar_t cl_expsprite = SCVAR("cl_expsprite", "0"); -cvar_t r_explosionlight = SCVAR("r_explosionlight", "1"); +cvar_t r_explosionlight = SCVARC("r_explosionlight", "1", Cvar_Limiter_ZeroToOne_Callback); cvar_t cl_truelightning = SCVARF("cl_truelightning", "0", CVAR_SEMICHEAT); cvar_t cl_beam_trace = SCVAR("cl_beam_trace", "0"); @@ -762,7 +762,7 @@ void CL_ParseTEnt (void) { dl = CL_AllocDlight (0); VectorCopy (pos, dl->origin); - dl->radius = 150 + bound(0, r_explosionlight.value, 1)*200; + dl->radius = 150 + r_explosionlight.value*200; dl->die = cl.time + 1; dl->decay = 300; @@ -802,7 +802,7 @@ void CL_ParseTEnt (void) { dl = CL_AllocDlight (0); VectorCopy (pos, dl->origin); - dl->radius = 150 + bound(0, r_explosionlight.value, 1)*200; + dl->radius = 150 + r_explosionlight.value*200; dl->die = cl.time + 1; dl->decay = 300; @@ -843,7 +843,7 @@ void CL_ParseTEnt (void) { dl = CL_AllocDlight (0); VectorCopy (pos, dl->origin); - dl->radius = 150 + bound(0, r_explosionlight.value, 1)*200; + dl->radius = 150 + r_explosionlight.value*200; dl->die = cl.time + 0.5; dl->decay = 300; @@ -874,7 +874,7 @@ void CL_ParseTEnt (void) dl = CL_AllocDlight (0); VectorCopy (pos, dl->origin); // no point in doing this the fuh/ez way - dl->radius = 500*bound(0, r_explosionlight.value, 1); + dl->radius = 500*r_explosionlight.value; dl->die = cl.time + 1; dl->decay = 500; @@ -1727,7 +1727,7 @@ void CLQ2_ParseTEnt (void) dlight_t *dl; dl = CL_AllocDlight (0); VectorCopy (pos, dl->origin); - dl->radius = 150 * bound(0, r_explosionlight.value, 1); + dl->radius = 150 * r_explosionlight.value; dl->die = cl.time + 0.4; dl->decay = 400; dl->color[0] = 0.2; @@ -1764,7 +1764,7 @@ void CLQ2_ParseTEnt (void) dlight_t *dl; dl = CL_AllocDlight (0); VectorCopy (pos, dl->origin); - dl->radius = 150 + bound(0, r_explosionlight.value, 1)*200; + dl->radius = 150 + r_explosionlight.value*200; dl->die = cl.time + 0.5; dl->decay = 300; dl->color[0] = 0.2; @@ -1859,7 +1859,7 @@ void CLQ2_ParseTEnt (void) dlight_t *dl; dl = CL_AllocDlight (0); VectorCopy (pos, dl->origin); - dl->radius = 150 + bound(0, r_explosionlight.value, 1)*200; + dl->radius = 150 + r_explosionlight.value*200; dl->die = cl.time + 0.5; dl->decay = 300; dl->color[0] = 0.2; @@ -2054,7 +2054,7 @@ void CLQ2_ParseTEnt (void) dlight_t *dl; dl = CL_AllocDlight (0); VectorCopy (pos, dl->origin); - dl->radius = 150 * bound(0, r_explosionlight.value, 1); + dl->radius = 150 * r_explosionlight.value; dl->die = cl.time + 0.4; dl->decay = 400; dl->color[0] = 0.01; @@ -2104,7 +2104,7 @@ void CLQ2_ParseTEnt (void) dlight_t *dl; dl = CL_AllocDlight (0); VectorCopy (pos, dl->origin); - dl->radius = 150 * bound(0, r_explosionlight.value, 1); + dl->radius = 150 * r_explosionlight.value; dl->die = cl.time + 0.4; dl->decay = 400; dl->color[0] = 0.038; @@ -2149,7 +2149,7 @@ void CLQ2_ParseTEnt (void) dlight_t *dl; dl = CL_AllocDlight (0); VectorCopy (pos, dl->origin); - dl->radius = 150 + bound(0, r_explosionlight.value, 1)*200; + dl->radius = 150 + r_explosionlight.value*200; dl->die = cl.time + 0.5; dl->decay = 300; dl->color[0] = 0.2; @@ -2264,7 +2264,7 @@ void CLQ2_ParseTEnt (void) dlight_t *dl; dl = CL_AllocDlight (0); VectorCopy (pos, dl->origin); - dl->radius = 150 * bound(0, r_explosionlight.value, 1); + dl->radius = 150 * r_explosionlight.value; dl->die = cl.time + 0.1; dl->minlight = 250; dl->color[0] = -0.2; diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index d81f6961b..abdcf1497 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -2225,7 +2225,7 @@ static void PF_cl_te_explosion (progfuncs_t *prinst, struct globalvars_s *pr_glo dl = CL_AllocDlight (0); VectorCopy (pos, dl->origin); - dl->radius = 150 + bound(0, r_explosionlight.value, 1)*200; + dl->radius = 150 + r_explosionlight.value*200; dl->die = cl.time + 1; dl->decay = 300; @@ -2316,7 +2316,7 @@ static void PF_cl_te_explosionquad (progfuncs_t *prinst, struct globalvars_s *pr dl = CL_AllocDlight (0); VectorCopy (pos, dl->origin); - dl->radius = 150 + bound(0, r_explosionlight.value, 1)*200; + dl->radius = 150 + r_explosionlight.value*200; dl->die = cl.time + 1; dl->decay = 300; @@ -2427,7 +2427,7 @@ static void PF_cl_te_explosionrgb (progfuncs_t *prinst, struct globalvars_s *pr_ { dl = CL_AllocDlight (0); VectorCopy (org, dl->origin); - dl->radius = 150 + bound(0, r_explosionlight.value, 1)*200; + dl->radius = 150 + r_explosionlight.value*200; dl->die = cl.time + 0.5; dl->decay = 300; diff --git a/engine/client/renderer.c b/engine/client/renderer.c index 47b50a2a6..c345c26ee 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -81,7 +81,7 @@ cvar_t r_sirds = SCVARF("r_sirds", "0", CVAR_SEMICHEAT);//whack in a value of 2 cvar_t r_loadlits = SCVAR("r_loadlit", "1"); -cvar_t r_stains = SCVARF("r_stains", "0.75", CVAR_ARCHIVE); +cvar_t r_stains = SCVARFC("r_stains", "0.75", CVAR_ARCHIVE, Cvar_Limiter_ZeroToOne_Callback); cvar_t r_stainfadetime = SCVAR("r_stainfadetime", "1"); cvar_t r_stainfadeammount = SCVAR("r_stainfadeammount", "1"); @@ -175,7 +175,7 @@ cvar_t scr_sshot_type = SCVAR("scr_sshot_type", "jpg"); cvar_t scr_centersbar = SCVAR("scr_centersbar", "0"); cvar_t scr_consize = SCVAR("scr_consize", "0.5"); -cvar_t scr_conalpha = SCVAR("scr_conalpha", "0.7"); +cvar_t scr_conalpha = SCVARC("scr_conalpha", "0.7", Cvar_Limiter_ZeroToOne_Callback); cvar_t scr_viewsize = SCVARFC("viewsize","100", CVAR_ARCHIVE, SCR_Viewsize_Callback); cvar_t scr_fov = SCVARFC("fov","90", CVAR_ARCHIVE, SCR_Fov_Callback); // 10 - 170 diff --git a/engine/common/cvar.c b/engine/common/cvar.c index fdcb772f5..d7266fbd3 100644 --- a/engine/common/cvar.c +++ b/engine/common/cvar.c @@ -1143,6 +1143,21 @@ void Cvar_ApplyCallbacks(int callbackflag) } } +// standard callbacks +void Cvar_Limiter_ZeroToOne_Callback(struct cvar_s *var, char *oldvalue) +{ + if (var->value > 1) + { + Cvar_ForceSet(var, "1"); + return; + } + else if (var->value < 0) + { + Cvar_ForceSet(var, "0"); + return; + } +} + void Cvar_Shutdown(void) { cvar_t *var; diff --git a/engine/common/cvar.h b/engine/common/cvar.h index f232e9612..319ce233f 100644 --- a/engine/common/cvar.h +++ b/engine/common/cvar.h @@ -143,6 +143,9 @@ void Cvar_ForceCallback(cvar_t *cvar); void Cvar_ApplyCallbacks(int callbackflag); //forces callbacks to be ran for given flags +void Cvar_Limiter_ZeroToOne_Callback(struct cvar_s *var, char *oldvalue); +//cvar callback to limit cvar value to 0 or 1 + float Cvar_VariableValue (const char *var_name); // returns 0 if not defined or non numeric diff --git a/engine/gl/gl_draw.c b/engine/gl/gl_draw.c index bebda6cc3..c02bf5bf5 100644 --- a/engine/gl/gl_draw.c +++ b/engine/gl/gl_draw.c @@ -1864,7 +1864,7 @@ void GLDraw_ConsoleBackground (int lines) } else { - if (scr_conalpha.value <= 0) + if (!scr_conalpha.value) return; a = scr_conalpha.value; diff --git a/engine/gl/gl_rsurf.c b/engine/gl/gl_rsurf.c index d37646978..30d4ab41d 100644 --- a/engine/gl/gl_rsurf.c +++ b/engine/gl/gl_rsurf.c @@ -92,7 +92,7 @@ void GLR_StainSurf (msurface_t *surf, float *parms) mtexinfo_t *tex; stmap *stainbase; - lim = 255 - (bound(0, r_stains.value, 1)*255); + lim = 255 - (r_stains.value*255); #define stain(x) \ change = stainbase[(s)*3+x] + amm*parms[4+x]; \ @@ -309,7 +309,7 @@ void GLR_LessenStains(void) static float time; - if (r_stains.value <= 0) + if (!r_stains.value) return; time += host_frametime; @@ -970,7 +970,7 @@ store: blg = greenblklights; blb = blueblklights; - if (r_stains.value <= 0) + if (!r_stains.value) isstained = false; else isstained = surf->stained; @@ -1128,7 +1128,7 @@ store: blg = greenblklights; blb = blueblklights; - if (r_stains.value <= 0) + if (!r_stains.value) isstained = false; else isstained = surf->stained; @@ -1321,7 +1321,7 @@ store: blg = greenblklights; blb = blueblklights; - if (r_stains.value <= 0) + if (!r_stains.value) isstained = false; else isstained = surf->stained; @@ -1479,7 +1479,7 @@ store: blg = greenblklights; blb = blueblklights; - if (r_stains.value <= 0) + if (!r_stains.value) isstained = false; else isstained = surf->stained; diff --git a/engine/sw/r_surf.c b/engine/sw/r_surf.c index a220e22d2..2c64b3a41 100644 --- a/engine/sw/r_surf.c +++ b/engine/sw/r_surf.c @@ -106,7 +106,7 @@ void SWR_StainSurf (msurface_t *surf, float *parms) stmap *stainbase; - lim = 255 - (bound(0, r_stains.value, 1)*255); + lim = 255 - (r_stains.value*255); smax = (surf->extents[0]>>4)+1; tmax = (surf->extents[1]>>4)+1; diff --git a/engine/sw/sw_draw.c b/engine/sw/sw_draw.c index 32e62629a..657b2c761 100644 --- a/engine/sw/sw_draw.c +++ b/engine/sw/sw_draw.c @@ -2023,7 +2023,7 @@ void SWDraw_ConsoleBackground (int lines) char ver[100]; static char saveback[320*8]; - if (!scr_con_forcedraw && scr_conalpha.value <= 0) + if (!scr_con_forcedraw && !scr_conalpha.value) return; conback = (mpic_t *)SWDraw_SafeCachePic ("gfx/conback.lmp"); @@ -2154,7 +2154,7 @@ void SWDraw_ConsoleBackground (int lines) if (scr_con_forcedraw) alpha = 255; else - alpha = bound(0, scr_conalpha.value*255, 255); + alpha = scr_conalpha.value*255; p24dest = (unsigned int *)vid.conbuffer; dest = (unsigned char *)vid.conbuffer;