From 42e55b33772e51d4d89434cb0047e8b9bb4bc10f Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Sat, 24 Dec 2011 14:04:01 +0000 Subject: [PATCH] changed cvar callback functions to accept a cvar_t pointer arg. I may have a use for that later. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@545 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/cvar.c | 2 +- Quake/cvar.h | 2 +- Quake/gl_rmisc.c | 41 ++++++++++++++--------------------------- Quake/gl_screen.c | 2 +- Quake/gl_texmgr.c | 2 +- Quake/gl_vidnt.c | 6 +++--- Quake/gl_vidsdl.c | 4 ++-- Quake/host.c | 10 +++++----- Quake/r_part.c | 2 +- 9 files changed, 29 insertions(+), 42 deletions(-) diff --git a/Quake/cvar.c b/Quake/cvar.c index 13923d1c..ac9f3bf1 100644 --- a/Quake/cvar.c +++ b/Quake/cvar.c @@ -353,7 +353,7 @@ void Cvar_Set (const char *var_name, const char *value) //johnfitz if(var->callback && changed) - var->callback(); + var->callback(var); //johnfitz } diff --git a/Quake/cvar.h b/Quake/cvar.h index f34c4c75..42ebb5c9 100644 --- a/Quake/cvar.h +++ b/Quake/cvar.h @@ -58,7 +58,7 @@ Cvars are restricted from having the same names as commands to keep this interface from being ambiguous. */ -typedef void (*cvarcallback_t) (void); +typedef void (*cvarcallback_t) (struct cvar_s *); typedef struct cvar_s { diff --git a/Quake/gl_rmisc.c b/Quake/gl_rmisc.c index 0b9cf8ad..e6595310 100644 --- a/Quake/gl_rmisc.c +++ b/Quake/gl_rmisc.c @@ -53,14 +53,13 @@ extern cvar_t gl_subdivide_size; //johnfitz -- moved here from gl_model.c extern gltexture_t *playertextures[MAX_SCOREBOARD]; //johnfitz -void R_NoLerpList_f (void); //johnfitz /* ==================== GL_Overbright_f -- johnfitz ==================== */ -void GL_Overbright_f (void) +static void GL_Overbright_f (cvar_t *var) { R_RebuildAllLightmaps (); } @@ -70,7 +69,7 @@ void GL_Overbright_f (void) GL_Fullbrights_f -- johnfitz ==================== */ -void GL_Fullbrights_f (void) +static void GL_Fullbrights_f (cvar_t *var) { TexMgr_ReloadNobrightImages (); } @@ -80,7 +79,7 @@ void GL_Fullbrights_f (void) R_SetClearColor_f -- johnfitz ==================== */ -void R_SetClearColor_f (void) +static void R_SetClearColor_f (cvar_t *var) { byte *rgb; int s; @@ -95,21 +94,22 @@ void R_SetClearColor_f (void) R_Novis_f -- johnfitz ==================== */ -void R_Novis_f (void) +static void R_VisChanged (cvar_t *var) { extern int vis_changed; vis_changed = 1; } /* -==================== -R_OldSkyLeaf_f -- johnfitz -==================== +=============== +R_NoLerpList_f -- johnfitz -- called when r_nolerp_list cvar changes +=============== */ -void R_OldSkyLeaf_f (void) +static void R_NoLerpList_f (cvar_t *var) { - extern int vis_changed; - vis_changed = 1; + int i; + for (i=0; i < MAX_MODELS; i++) + Mod_SetExtraFlags (cl.model_precache[i]); } /* @@ -207,7 +207,7 @@ void R_Init (void) Cvar_RegisterVariable (&r_shadows, NULL); Cvar_RegisterVariable (&r_wateralpha, NULL); Cvar_RegisterVariable (&r_dynamic, NULL); - Cvar_RegisterVariable (&r_novis, R_Novis_f); + Cvar_RegisterVariable (&r_novis, R_VisChanged); Cvar_RegisterVariable (&r_speeds, NULL); Cvar_RegisterVariable (&gl_finish, NULL); @@ -229,7 +229,7 @@ void R_Init (void) Cvar_RegisterVariable (&r_waterwarp, NULL); Cvar_RegisterVariable (&r_drawflat, NULL); Cvar_RegisterVariable (&r_flatlightstyles, NULL); - Cvar_RegisterVariable (&r_oldskyleaf, R_OldSkyLeaf_f); + Cvar_RegisterVariable (&r_oldskyleaf, R_VisChanged); Cvar_RegisterVariable (&r_drawworld, NULL); Cvar_RegisterVariable (&r_showtris, NULL); Cvar_RegisterVariable (&r_showbboxes, NULL); @@ -247,25 +247,12 @@ void R_Init (void) Cvar_RegisterVariable (&gl_subdivide_size, NULL); //johnfitz -- moved here from gl_model.c R_InitParticles (); - R_SetClearColor_f (); //johnfitz + R_SetClearColor_f (&r_clearcolor); //johnfitz Sky_Init (); //johnfitz Fog_Init (); //johnfitz } -/* -=============== -R_NoLerpList_f -- johnfitz -- called when r_nolerp_list cvar changes -=============== -*/ -void R_NoLerpList_f (void) -{ - int i; - - for (i=0; i < MAX_MODELS; i++) - Mod_SetExtraFlags (cl.model_precache[i]); -} - /* =============== R_TranslatePlayerSkin -- johnfitz -- rewritten. also, only handles new colors, not new skins diff --git a/Quake/gl_screen.c b/Quake/gl_screen.c index 2748ca36..72e05c9c 100644 --- a/Quake/gl_screen.c +++ b/Quake/gl_screen.c @@ -340,7 +340,7 @@ void SCR_SizeDown_f (void) SCR_Conwidth_f -- johnfitz -- called when scr_conwidth or scr_conscale changes ================== */ -void SCR_Conwidth_f (void) +void SCR_Conwidth_f (cvar_t *var) { vid.conwidth = (scr_conwidth.value > 0) ? (int)scr_conwidth.value : (scr_conscale.value > 0) ? (int)(vid.width/scr_conscale.value) : vid.width; vid.conwidth = CLAMP (320, vid.conwidth, vid.width); diff --git a/Quake/gl_texmgr.c b/Quake/gl_texmgr.c index b13017fd..a84cde38 100644 --- a/Quake/gl_texmgr.c +++ b/Quake/gl_texmgr.c @@ -181,7 +181,7 @@ TexMgr_Anisotropy_f -- called when gl_texture_anisotropy changes FIXME: this is getting called twice (becuase of the recursive Cvar_SetValue call) =============== */ -void TexMgr_Anisotropy_f (void) +void TexMgr_Anisotropy_f (cvar_t *var) { extern float gl_max_anisotropy; gltexture_t *glt; diff --git a/Quake/gl_vidnt.c b/Quake/gl_vidnt.c index 80bb8347..27c441e3 100644 --- a/Quake/gl_vidnt.c +++ b/Quake/gl_vidnt.c @@ -237,7 +237,7 @@ void VID_Gamma_Shutdown (void) VID_Gamma_f -- callback when the cvar changes ================ */ -void VID_Gamma_f (void) +void VID_Gamma_f (cvar_t *var) { static float oldgamma; int i; @@ -627,7 +627,7 @@ int VID_SetMode (int modenum) VID_Vsync_f -- johnfitz =============== */ -void VID_Vsync_f (void) +void VID_Vsync_f (cvar_t *var) { if (gl_swap_control) { @@ -790,7 +790,7 @@ void VID_Restart (void) vid_canalttab = true; //swapcontrol settings were lost when previous window was destroyed - VID_Vsync_f (); + VID_Vsync_f (&vid_vsync); //warpimages needs to be recalculated TexMgr_RecalcWarpImageSize (); diff --git a/Quake/gl_vidsdl.c b/Quake/gl_vidsdl.c index 26dfd3d0..8f16a5ff 100644 --- a/Quake/gl_vidsdl.c +++ b/Quake/gl_vidsdl.c @@ -201,7 +201,7 @@ void VID_Gamma_Shutdown (void) VID_Gamma_f -- callback when the cvar changes ================ */ -void VID_Gamma_f (void) +void VID_Gamma_f (cvar_t *var) { static float oldgamma; int i; @@ -352,7 +352,7 @@ int VID_SetMode (int modenum) VID_Changed_f -- kristian -- notify us that a value has changed that requires a vid_restart =================== */ -void VID_Changed_f (void) +static void VID_Changed_f (cvar_t *var) { vid_changed = true; } diff --git a/Quake/host.c b/Quake/host.c index e02a54e5..a59c171e 100644 --- a/Quake/host.c +++ b/Quake/host.c @@ -91,7 +91,7 @@ overflowtimes_t dev_overflows; //this stores the last time overflow messages wer Max_Edicts_f -- johnfitz ================ */ -static void Max_Edicts_f (void) +static void Max_Edicts_f (cvar_t *var) { static float oldval = DEF_EDICTS; //must match the default value for max_edicts @@ -106,15 +106,15 @@ static void Max_Edicts_f (void) } // 1999-09-06 deathmatch/coop not at the same time fix by Maddes -static void Callback_Deathmatch (void) +static void Callback_Deathmatch (cvar_t *var) { - if (deathmatch.value) + if (var->value) Cvar_Set ("coop", "0"); } -static void Callback_Coop (void) +static void Callback_Coop (cvar_t *var) { - if (coop.value) + if (var->value) Cvar_Set ("deathmatch", "0"); } diff --git a/Quake/r_part.c b/Quake/r_part.c index d70e28eb..a2e15dae 100644 --- a/Quake/r_part.c +++ b/Quake/r_part.c @@ -122,7 +122,7 @@ void R_InitParticleTextures (void) R_SetParticleTexture_f -- johnfitz =============== */ -void R_SetParticleTexture_f (void) +static void R_SetParticleTexture_f (cvar_t *var) { switch ((int)(r_particles.value)) {