From 4e485d16fa5442282a6816a9a0d4dcfec8dc427e Mon Sep 17 00:00:00 2001 From: sezero Date: Wed, 28 Dec 2011 22:01:33 +0000 Subject: [PATCH] * first shot at cvar flag system and cvar layer clean-ups : - removed the archive and server members of cvar_t structure which are now represented by the CVAR_ARCHIVE, CVAR_NOTIFY and CVAR_SERVERINFO flags. - added new Cvar_SetROM and Cvar_SetValueROM functions to set vars marked as CVAR_ROM (read-only vars) programaticaly - added Cvar_SetCallback() as a new function to assign (or remove) a callback function to a cvar. - changed Cvar_RegisterVariable() to only accept a var pointer as in original quake - moved notification handling from Cvar_Set() to callbacks. - changed Cvar_Set() so that it doesn't reallocate the var's string buffer if nothing is changed, nor does it run the var's callback. - changed the 'registered' and 'cmdline' cvars to be read-only so that the users can't change it using the console. (and with 'registered' flagged as CVAR_ROM, the 'static_registered' thing is no longer required) - added comment that sending cmdline upon CCREQ_RULE_INFO is evil... - more to follow later. git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@566 af15c1b1-3010-417e-b628-4374ebc0bcbd --- quakespasm/Quake/bgmusic.c | 4 +- quakespasm/Quake/chase.c | 16 +++--- quakespasm/Quake/cl_input.c | 16 +++--- quakespasm/Quake/cl_main.c | 68 ++++++++++++------------ quakespasm/Quake/common.c | 18 +++---- quakespasm/Quake/console.c | 8 +-- quakespasm/Quake/cvar.c | 76 +++++++++++++++++++++------ quakespasm/Quake/cvar.h | 36 ++++++++++--- quakespasm/Quake/gl_draw.c | 4 +- quakespasm/Quake/gl_fog.c | 4 +- quakespasm/Quake/gl_model.c | 6 +-- quakespasm/Quake/gl_rmain.c | 72 +++++++++++++------------- quakespasm/Quake/gl_rmisc.c | 84 ++++++++++++++++-------------- quakespasm/Quake/gl_screen.c | 74 +++++++++++++------------- quakespasm/Quake/gl_sky.c | 16 +++--- quakespasm/Quake/gl_texmgr.c | 13 ++--- quakespasm/Quake/gl_vidnt.c | 34 ++++++------ quakespasm/Quake/gl_vidsdl.c | 38 ++++++++------ quakespasm/Quake/gl_warp.c | 10 ++-- quakespasm/Quake/host.c | 90 ++++++++++++++++++-------------- quakespasm/Quake/in_sdl.c | 2 +- quakespasm/Quake/net_dgrm.c | 2 +- quakespasm/Quake/net_main.c | 8 +-- quakespasm/Quake/pr_cmds.c | 2 +- quakespasm/Quake/pr_edict.c | 44 ++++++++-------- quakespasm/Quake/quakedef.h | 1 + quakespasm/Quake/r_part.c | 9 ++-- quakespasm/Quake/snd_dma.c | 44 ++++++++-------- quakespasm/Quake/sv_main.c | 27 +++++----- quakespasm/Quake/sv_phys.c | 12 ++--- quakespasm/Quake/sv_user.c | 10 ++-- quakespasm/Quake/sys_sdl_unix.c | 2 +- quakespasm/Quake/sys_sdl_win.c | 2 +- quakespasm/Quake/view.c | 92 ++++++++++++++++----------------- 34 files changed, 519 insertions(+), 425 deletions(-) diff --git a/quakespasm/Quake/bgmusic.c b/quakespasm/Quake/bgmusic.c index 6d535a33..19f18087 100644 --- a/quakespasm/Quake/bgmusic.c +++ b/quakespasm/Quake/bgmusic.c @@ -29,7 +29,7 @@ #define MUSIC_DIRNAME "music" qboolean bgmloop; -cvar_t bgm_extmusic = {"bgm_extmusic", "1", true}; +cvar_t bgm_extmusic = {"bgm_extmusic", "1", CVAR_ARCHIVE}; static qboolean no_extmusic= false; static float old_volume = -1.0f; @@ -121,7 +121,7 @@ qboolean BGM_Init (void) music_handler_t *handlers = NULL; int i; - Cvar_RegisterVariable(&bgm_extmusic, NULL); + Cvar_RegisterVariable(&bgm_extmusic); Cmd_AddCommand("music", BGM_Play_f); Cmd_AddCommand("music_pause", BGM_Pause_f); Cmd_AddCommand("music_resume", BGM_Resume_f); diff --git a/quakespasm/Quake/chase.c b/quakespasm/Quake/chase.c index de5570b5..5f4165cc 100644 --- a/quakespasm/Quake/chase.c +++ b/quakespasm/Quake/chase.c @@ -22,10 +22,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" -cvar_t chase_back = {"chase_back", "100"}; -cvar_t chase_up = {"chase_up", "16"}; -cvar_t chase_right = {"chase_right", "0"}; -cvar_t chase_active = {"chase_active", "0"}; +cvar_t chase_back = {"chase_back", "100", CVAR_NONE}; +cvar_t chase_up = {"chase_up", "16", CVAR_NONE}; +cvar_t chase_right = {"chase_right", "0", CVAR_NONE}; +cvar_t chase_active = {"chase_active", "0", CVAR_NONE}; /* ============== @@ -34,10 +34,10 @@ Chase_Init */ void Chase_Init (void) { - Cvar_RegisterVariable (&chase_back, NULL); - Cvar_RegisterVariable (&chase_up, NULL); - Cvar_RegisterVariable (&chase_right, NULL); - Cvar_RegisterVariable (&chase_active, NULL); + Cvar_RegisterVariable (&chase_back); + Cvar_RegisterVariable (&chase_up); + Cvar_RegisterVariable (&chase_right); + Cvar_RegisterVariable (&chase_active); } /* diff --git a/quakespasm/Quake/cl_input.c b/quakespasm/Quake/cl_input.c index 41f0d969..174b61c0 100644 --- a/quakespasm/Quake/cl_input.c +++ b/quakespasm/Quake/cl_input.c @@ -221,17 +221,17 @@ float CL_KeyState (kbutton_t *key) //========================================================================== -cvar_t cl_upspeed = {"cl_upspeed","200"}; -cvar_t cl_forwardspeed = {"cl_forwardspeed","200", true}; -cvar_t cl_backspeed = {"cl_backspeed","200", true}; -cvar_t cl_sidespeed = {"cl_sidespeed","350"}; +cvar_t cl_upspeed = {"cl_upspeed","200",CVAR_NONE}; +cvar_t cl_forwardspeed = {"cl_forwardspeed","200", CVAR_ARCHIVE}; +cvar_t cl_backspeed = {"cl_backspeed","200", CVAR_ARCHIVE}; +cvar_t cl_sidespeed = {"cl_sidespeed","350",CVAR_NONE}; -cvar_t cl_movespeedkey = {"cl_movespeedkey","2.0"}; +cvar_t cl_movespeedkey = {"cl_movespeedkey","2.0",CVAR_NONE}; -cvar_t cl_yawspeed = {"cl_yawspeed","140"}; -cvar_t cl_pitchspeed = {"cl_pitchspeed","150"}; +cvar_t cl_yawspeed = {"cl_yawspeed","140",CVAR_NONE}; +cvar_t cl_pitchspeed = {"cl_pitchspeed","150",CVAR_NONE}; -cvar_t cl_anglespeedkey = {"cl_anglespeedkey","1.5"}; +cvar_t cl_anglespeedkey = {"cl_anglespeedkey","1.5",CVAR_NONE}; /* diff --git a/quakespasm/Quake/cl_main.c b/quakespasm/Quake/cl_main.c index 4b89f498..24db8ef5 100644 --- a/quakespasm/Quake/cl_main.c +++ b/quakespasm/Quake/cl_main.c @@ -27,23 +27,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // references them even when on a unix system. // these two are not intended to be set directly -cvar_t cl_name = {"_cl_name", "player", true}; -cvar_t cl_color = {"_cl_color", "0", true}; +cvar_t cl_name = {"_cl_name", "player", CVAR_ARCHIVE}; +cvar_t cl_color = {"_cl_color", "0", CVAR_ARCHIVE}; -cvar_t cl_shownet = {"cl_shownet","0"}; // can be 0, 1, or 2 -cvar_t cl_nolerp = {"cl_nolerp","0"}; +cvar_t cl_shownet = {"cl_shownet","0",CVAR_NONE}; // can be 0, 1, or 2 +cvar_t cl_nolerp = {"cl_nolerp","0",CVAR_NONE}; -cvar_t lookspring = {"lookspring","0", true}; -cvar_t lookstrafe = {"lookstrafe","0", true}; -cvar_t sensitivity = {"sensitivity","3", true}; +cvar_t lookspring = {"lookspring","0", CVAR_ARCHIVE}; +cvar_t lookstrafe = {"lookstrafe","0", CVAR_ARCHIVE}; +cvar_t sensitivity = {"sensitivity","3", CVAR_ARCHIVE}; -cvar_t m_pitch = {"m_pitch","0.022", true}; -cvar_t m_yaw = {"m_yaw","0.022", true}; -cvar_t m_forward = {"m_forward","1", true}; -cvar_t m_side = {"m_side","0.8", true}; +cvar_t m_pitch = {"m_pitch","0.022", CVAR_ARCHIVE}; +cvar_t m_yaw = {"m_yaw","0.022", CVAR_ARCHIVE}; +cvar_t m_forward = {"m_forward","1", CVAR_ARCHIVE}; +cvar_t m_side = {"m_side","0.8", CVAR_ARCHIVE}; -cvar_t cl_maxpitch = {"cl_maxpitch", "90", true}; //johnfitz -- variable pitch clamping -cvar_t cl_minpitch = {"cl_minpitch", "-90", true}; //johnfitz -- variable pitch clamping +cvar_t cl_maxpitch = {"cl_maxpitch", "90", CVAR_ARCHIVE}; //johnfitz -- variable pitch clamping +cvar_t cl_minpitch = {"cl_minpitch", "-90", CVAR_ARCHIVE}; //johnfitz -- variable pitch clamping client_static_t cls; client_state_t cl; @@ -775,29 +775,29 @@ void CL_Init (void) CL_InitInput (); CL_InitTEnts (); - Cvar_RegisterVariable (&cl_name, NULL); - Cvar_RegisterVariable (&cl_color, NULL); - Cvar_RegisterVariable (&cl_upspeed, NULL); - Cvar_RegisterVariable (&cl_forwardspeed, NULL); - Cvar_RegisterVariable (&cl_backspeed, NULL); - Cvar_RegisterVariable (&cl_sidespeed, NULL); - Cvar_RegisterVariable (&cl_movespeedkey, NULL); - Cvar_RegisterVariable (&cl_yawspeed, NULL); - Cvar_RegisterVariable (&cl_pitchspeed, NULL); - Cvar_RegisterVariable (&cl_anglespeedkey, NULL); - Cvar_RegisterVariable (&cl_shownet, NULL); - Cvar_RegisterVariable (&cl_nolerp, NULL); - Cvar_RegisterVariable (&lookspring, NULL); - Cvar_RegisterVariable (&lookstrafe, NULL); - Cvar_RegisterVariable (&sensitivity, NULL); + Cvar_RegisterVariable (&cl_name); + Cvar_RegisterVariable (&cl_color); + Cvar_RegisterVariable (&cl_upspeed); + Cvar_RegisterVariable (&cl_forwardspeed); + Cvar_RegisterVariable (&cl_backspeed); + Cvar_RegisterVariable (&cl_sidespeed); + Cvar_RegisterVariable (&cl_movespeedkey); + Cvar_RegisterVariable (&cl_yawspeed); + Cvar_RegisterVariable (&cl_pitchspeed); + Cvar_RegisterVariable (&cl_anglespeedkey); + Cvar_RegisterVariable (&cl_shownet); + Cvar_RegisterVariable (&cl_nolerp); + Cvar_RegisterVariable (&lookspring); + Cvar_RegisterVariable (&lookstrafe); + Cvar_RegisterVariable (&sensitivity); - Cvar_RegisterVariable (&m_pitch, NULL); - Cvar_RegisterVariable (&m_yaw, NULL); - Cvar_RegisterVariable (&m_forward, NULL); - Cvar_RegisterVariable (&m_side, NULL); + Cvar_RegisterVariable (&m_pitch); + Cvar_RegisterVariable (&m_yaw); + Cvar_RegisterVariable (&m_forward); + Cvar_RegisterVariable (&m_side); - Cvar_RegisterVariable (&cl_maxpitch, NULL); //johnfitz -- variable pitch clamping - Cvar_RegisterVariable (&cl_minpitch, NULL); //johnfitz -- variable pitch clamping + Cvar_RegisterVariable (&cl_maxpitch); //johnfitz -- variable pitch clamping + Cvar_RegisterVariable (&cl_minpitch); //johnfitz -- variable pitch clamping Cmd_AddCommand ("entities", CL_PrintEntities_f); Cmd_AddCommand ("disconnect", CL_Disconnect_f); diff --git a/quakespasm/Quake/common.c b/quakespasm/Quake/common.c index a5d7f5f3..0fe16083 100644 --- a/quakespasm/Quake/common.c +++ b/quakespasm/Quake/common.c @@ -28,15 +28,13 @@ static char argvdummy[] = " "; int safemode; -cvar_t registered = {"registered","0"}; -cvar_t cmdline = {"cmdline","", false, true}; +cvar_t registered = {"registered","0",CVAR_ROM}; +cvar_t cmdline = {"cmdline","",CVAR_ROM|CVAR_SERVERINFO}; /* sending cmdline upon CCREQ_RULE_INFO is evil... */ qboolean com_modified; // set true if using non-id files int com_nummissionpacks; //johnfitz -int static_registered = 1; // only for startup check, then set - qboolean fitzmode; void COM_InitFilesystem (void); @@ -1155,7 +1153,6 @@ void COM_CheckRegistered (void) int i; COM_OpenFile("gfx/pop.lmp", &h, NULL); - static_registered = 0; if (h == -1) { @@ -1175,9 +1172,8 @@ void COM_CheckRegistered (void) if (pop[i] != (unsigned short)BigShort (check[i])) Sys_Error ("Corrupted data file."); - Cvar_Set ("cmdline", com_cmdline+1); //johnfitz -- eliminate leading space - Cvar_Set ("registered", "1"); - static_registered = 1; + Cvar_SetROM ("cmdline", com_cmdline+1); //johnfitz -- eliminate leading space + Cvar_SetROM ("registered", "1"); Con_Printf ("Playing registered version.\n"); } @@ -1300,8 +1296,8 @@ void COM_Init (void) if (COM_CheckParm("-fitz")) fitzmode = true; - Cvar_RegisterVariable (®istered, NULL); - Cvar_RegisterVariable (&cmdline, NULL); + Cvar_RegisterVariable (®istered); + Cvar_RegisterVariable (&cmdline); Cmd_AddCommand ("path", COM_Path_f); COM_InitFilesystem (); COM_CheckRegistered (); @@ -1569,7 +1565,7 @@ static int COM_FindFile (const char *filename, int *handle, FILE **file, } else /* check a file in the directory tree */ { - if (!static_registered) + if (!registered.value) { /* if not a registered version, don't ever go beyond base */ if ( strchr (filename, '/') || strchr (filename,'\\')) continue; diff --git a/quakespasm/Quake/console.c b/quakespasm/Quake/console.c index b4b62934..bc4c5897 100644 --- a/quakespasm/Quake/console.c +++ b/quakespasm/Quake/console.c @@ -47,8 +47,8 @@ int con_current; // where next message will be printed int con_x; // offset in current line for next print char *con_text = NULL; -cvar_t con_notifytime = {"con_notifytime","3"}; //seconds -cvar_t con_logcenterprint = {"con_logcenterprint", "1"}; //johnfitz +cvar_t con_notifytime = {"con_notifytime","3",CVAR_NONE}; //seconds +cvar_t con_logcenterprint = {"con_logcenterprint", "1", CVAR_NONE}; //johnfitz char con_lastcenterstring[1024]; //johnfitz @@ -355,8 +355,8 @@ void Con_Init (void) // // register our commands // - Cvar_RegisterVariable (&con_notifytime, NULL); - Cvar_RegisterVariable (&con_logcenterprint, NULL); //johnfitz + Cvar_RegisterVariable (&con_notifytime); + Cvar_RegisterVariable (&con_logcenterprint); //johnfitz Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f); Cmd_AddCommand ("messagemode", Con_MessageMode_f); diff --git a/quakespasm/Quake/cvar.c b/quakespasm/Quake/cvar.c index ac9f3bf1..0404ee6c 100644 --- a/quakespasm/Quake/cvar.c +++ b/quakespasm/Quake/cvar.c @@ -63,8 +63,8 @@ void Cvar_List_f (void) continue; } Con_SafePrintf ("%s%s %s \"%s\"\n", - cvar->archive ? "*" : " ", - cvar->server ? "s" : " ", + (cvar->flags & CVAR_ARCHIVE) ? "*" : " ", + (cvar->flags & CVAR_NOTIFY) ? "s" : " ", cvar->name, cvar->string); count++; @@ -321,7 +321,6 @@ Cvar_Set void Cvar_Set (const char *var_name, const char *value) { cvar_t *var; - qboolean changed; var = Cvar_FindVar (var_name); if (!var) @@ -330,7 +329,12 @@ void Cvar_Set (const char *var_name, const char *value) return; } - changed = Q_strcmp(var->string, value); + if (var->flags & (CVAR_ROM|CVAR_LOCKED)) + return; // cvar is marked read-only or locked temporarily + + if (!strcmp(var->string, value)) + return; // no change + var->flags |= CVAR_CHANGED; Z_Free ((void *)var->string); // free the old value string @@ -345,16 +349,8 @@ void Cvar_Set (const char *var_name, const char *value) } //johnfitz - if (var->server && changed) - { - if (sv.active) - SV_BroadcastPrintf ("\"%s\" changed to \"%s\"\n", var->name, var->string); - } - - //johnfitz - if(var->callback && changed) + if(var->callback) var->callback(var); - //johnfitz } /* @@ -370,6 +366,38 @@ void Cvar_SetValue (const char *var_name, const float value) Cvar_Set (var_name, val); } +/* +============ +Cvar_SetROM +============ +*/ +void Cvar_SetROM (const char *var_name, const char *value) +{ + cvar_t *var = Cvar_FindVar (var_name); + if (var) + { + var->flags &= ~CVAR_ROM; + Cvar_Set (var_name, value); + var->flags |= CVAR_ROM; + } +} + +/* +============ +Cvar_SetValueROM +============ +*/ +void Cvar_SetValueROM (const char *var_name, const float value) +{ + cvar_t *var = Cvar_FindVar (var_name); + if (var) + { + var->flags &= ~CVAR_ROM; + Cvar_SetValue (var_name, value); + var->flags |= CVAR_ROM; + } +} + /* ============ Cvar_RegisterVariable @@ -377,7 +405,7 @@ Cvar_RegisterVariable Adds a freestanding variable to the variable list. ============ */ -void Cvar_RegisterVariable (cvar_t *variable, cvarcallback_t function) +void Cvar_RegisterVariable (cvar_t *variable) { cvar_t *cursor,*prev; //johnfitz -- sorted list insert @@ -425,7 +453,23 @@ void Cvar_RegisterVariable (cvar_t *variable, cvarcallback_t function) } //johnfitz - variable->callback = function; //johnfitz + if (!(variable->flags & CVAR_CALLBACK)) + variable->callback = NULL; +} + +/* +============ +Cvar_SetCallback + +Set a callback function to the var +============ +*/ +void Cvar_SetCallback (cvar_t *var, cvarcallback_t func) +{ + var->callback = func; + if (func) + var->flags |= CVAR_CALLBACK; + else var->flags &= ~CVAR_CALLBACK; } /* @@ -469,7 +513,7 @@ void Cvar_WriteVariables (FILE *f) cvar_t *var; for (var = cvar_vars ; var ; var = var->next) - if (var->archive) + if (var->flags & CVAR_ARCHIVE) fprintf (f, "%s \"%s\"\n", var->name, var->string); } diff --git a/quakespasm/Quake/cvar.h b/quakespasm/Quake/cvar.h index 42ebb5c9..b1ed14c7 100644 --- a/quakespasm/Quake/cvar.h +++ b/quakespasm/Quake/cvar.h @@ -58,30 +58,50 @@ Cvars are restricted from having the same names as commands to keep this interface from being ambiguous. */ +#define CVAR_NONE 0 +#define CVAR_ARCHIVE (1U << 0) // if set, causes it to be saved to config +#define CVAR_NOTIFY (1U << 1) // changes will be broadcasted to all players (H2) +#define CVAR_SERVERINFO (1U << 2) // added to serverinfo will be sent to clients (net_dgrm.c, qwsv) +#define CVAR_USERINFO (1U << 3) // added to userinfo, will be sent to server (qwcl) +#define CVAR_CHANGED (1U << 4) +#define CVAR_ROM (1U << 6) +#define CVAR_LOCKED (1U << 8) // locked temporarily +#define CVAR_REGISTERED (1U << 10) // the var is added to the list of variables +#define CVAR_CALLBACK (1U << 16) // var has a callback + + typedef void (*cvarcallback_t) (struct cvar_s *); typedef struct cvar_s { const char *name; const char *string; - qboolean archive; // set to true to cause it to be saved to vars.rc - qboolean server; // notifies players when changed - float value; - struct cvar_s *next; + unsigned int flags; + float value; + struct cvar_s *next; const char *default_string; //johnfitz -- remember defaults for reset function - cvarcallback_t callback; //johnfitz + cvarcallback_t callback; //johnfitz } cvar_t; -void Cvar_RegisterVariable (cvar_t *variable, cvarcallback_t function); //johnfitz -- cvar callback +void Cvar_SetCallback (cvar_t *var, cvarcallback_t func); +// set a callback function to the var + +void Cvar_RegisterVariable (cvar_t *variable); // registers a cvar that allready has the name, string, and optionally the // archive elements set. -void Cvar_Set (const char *var_name, const char *value); +void Cvar_Set (const char *var_name, const char *value); // equivelant to " " typed at the console void Cvar_SetValue (const char *var_name, const float value); // expands value to a string and calls Cvar_Set +void Cvar_SetROM (const char *var_name, const char *value); +// sets a CVAR_ROM variable from within the engine + +void Cvar_SetValueROM (const char *var_name, const float value); +// sets a CVAR_ROM variable from within the engine + float Cvar_VariableValue (const char *var_name); // returns 0 if not defined or non numeric @@ -97,7 +117,7 @@ qboolean Cvar_Command (void); // command. Returns true if the command was a variable reference that // was handled. (print or change) -void Cvar_WriteVariables (FILE *f); +void Cvar_WriteVariables (FILE *f); // Writes lines containing "set variable value" for all variables // with the archive flag set to true. diff --git a/quakespasm/Quake/gl_draw.c b/quakespasm/Quake/gl_draw.c index 2d4ce312..fe31f60b 100644 --- a/quakespasm/Quake/gl_draw.c +++ b/quakespasm/Quake/gl_draw.c @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //extern unsigned char d_15to8table[65536]; //johnfitz -- never used -cvar_t scr_conalpha = {"scr_conalpha", "0.5",true}; //johnfitz +cvar_t scr_conalpha = {"scr_conalpha", "0.5", CVAR_ARCHIVE}; //johnfitz qpic_t *draw_disc; qpic_t *draw_backtile; @@ -458,7 +458,7 @@ Draw_Init -- johnfitz -- rewritten */ void Draw_Init (void) { - Cvar_RegisterVariable (&scr_conalpha, NULL); + Cvar_RegisterVariable (&scr_conalpha); // clear scrap and allocate gltextures memset(&scrap_allocated, 0, sizeof(scrap_allocated)); diff --git a/quakespasm/Quake/gl_fog.c b/quakespasm/Quake/gl_fog.c index 4909e6fa..503cca1d 100644 --- a/quakespasm/Quake/gl_fog.c +++ b/quakespasm/Quake/gl_fog.c @@ -339,7 +339,7 @@ void Fog_StopAdditive (void) // //============================================================================== -cvar_t r_vfog = {"r_vfog", "1"}; +cvar_t r_vfog = {"r_vfog", "1", CVAR_NONE}; void Fog_DrawVFog (void){} void Fog_MarkModels (void){} @@ -374,7 +374,7 @@ void Fog_Init (void) { Cmd_AddCommand ("fog",Fog_FogCommand_f); - //Cvar_RegisterVariable (&r_vfog, NULL); + //Cvar_RegisterVariable (&r_vfog); //set up global fog fog_density = 0.0; diff --git a/quakespasm/Quake/gl_model.c b/quakespasm/Quake/gl_model.c index eb5fe89e..443fc8eb 100644 --- a/quakespasm/Quake/gl_model.c +++ b/quakespasm/Quake/gl_model.c @@ -34,7 +34,7 @@ void Mod_LoadBrushModel (model_t *mod, void *buffer); void Mod_LoadAliasModel (model_t *mod, void *buffer); model_t *Mod_LoadModel (model_t *mod, qboolean crash); -cvar_t external_ents = {"external_ents", "1", true}; +cvar_t external_ents = {"external_ents", "1", CVAR_ARCHIVE}; byte mod_novis[MAX_MAP_LEAFS/8]; @@ -52,8 +52,8 @@ Mod_Init */ void Mod_Init (void) { - Cvar_RegisterVariable (&gl_subdivide_size, NULL); - Cvar_RegisterVariable (&external_ents, NULL); + Cvar_RegisterVariable (&gl_subdivide_size); + Cvar_RegisterVariable (&external_ents); memset (mod_novis, 0xff, sizeof(mod_novis)); diff --git a/quakespasm/Quake/gl_rmain.c b/quakespasm/Quake/gl_rmain.c index 6dfc2627..b64c72f7 100644 --- a/quakespasm/Quake/gl_rmain.c +++ b/quakespasm/Quake/gl_rmain.c @@ -62,48 +62,48 @@ mleaf_t *r_viewleaf, *r_oldviewleaf; int d_lightstylevalue[256]; // 8.8 fraction of base light value -cvar_t r_norefresh = {"r_norefresh","0"}; -cvar_t r_drawentities = {"r_drawentities","1"}; -cvar_t r_drawviewmodel = {"r_drawviewmodel","1"}; -cvar_t r_speeds = {"r_speeds","0"}; -cvar_t r_fullbright = {"r_fullbright","0"}; -cvar_t r_lightmap = {"r_lightmap","0"}; -cvar_t r_shadows = {"r_shadows","0",true}; -cvar_t r_wateralpha = {"r_wateralpha","1",true}; -cvar_t r_dynamic = {"r_dynamic","1",true}; -cvar_t r_novis = {"r_novis","0",true}; +cvar_t r_norefresh = {"r_norefresh","0",CVAR_NONE}; +cvar_t r_drawentities = {"r_drawentities","1",CVAR_NONE}; +cvar_t r_drawviewmodel = {"r_drawviewmodel","1",CVAR_NONE}; +cvar_t r_speeds = {"r_speeds","0",CVAR_NONE}; +cvar_t r_fullbright = {"r_fullbright","0",CVAR_NONE}; +cvar_t r_lightmap = {"r_lightmap","0",CVAR_NONE}; +cvar_t r_shadows = {"r_shadows","0",CVAR_ARCHIVE}; +cvar_t r_wateralpha = {"r_wateralpha","1",CVAR_ARCHIVE}; +cvar_t r_dynamic = {"r_dynamic","1",CVAR_ARCHIVE}; +cvar_t r_novis = {"r_novis","0",CVAR_ARCHIVE}; -cvar_t gl_finish = {"gl_finish","0"}; -cvar_t gl_clear = {"gl_clear","0"}; -cvar_t gl_cull = {"gl_cull","1"}; -cvar_t gl_smoothmodels = {"gl_smoothmodels","1"}; -cvar_t gl_affinemodels = {"gl_affinemodels","0"}; -cvar_t gl_polyblend = {"gl_polyblend","1"}; -cvar_t gl_flashblend = {"gl_flashblend","0",true}; -cvar_t gl_playermip = {"gl_playermip","0"}; -cvar_t gl_nocolors = {"gl_nocolors","0"}; +cvar_t gl_finish = {"gl_finish","0",CVAR_NONE}; +cvar_t gl_clear = {"gl_clear","0",CVAR_NONE}; +cvar_t gl_cull = {"gl_cull","1",CVAR_NONE}; +cvar_t gl_smoothmodels = {"gl_smoothmodels","1",CVAR_NONE}; +cvar_t gl_affinemodels = {"gl_affinemodels","0",CVAR_NONE}; +cvar_t gl_polyblend = {"gl_polyblend","1",CVAR_NONE}; +cvar_t gl_flashblend = {"gl_flashblend","0",CVAR_ARCHIVE}; +cvar_t gl_playermip = {"gl_playermip","0",CVAR_NONE}; +cvar_t gl_nocolors = {"gl_nocolors","0",CVAR_NONE}; //johnfitz -- new cvars -cvar_t r_stereo = {"r_stereo","0"}; -cvar_t r_stereodepth = {"r_stereodepth","128"}; -cvar_t r_clearcolor = {"r_clearcolor","2", true}; -cvar_t r_drawflat = {"r_drawflat","0"}; -cvar_t r_flatlightstyles = {"r_flatlightstyles", "0"}; -cvar_t gl_fullbrights = {"gl_fullbrights", "1", true}; -cvar_t gl_farclip = {"gl_farclip", "16384", true}; -cvar_t gl_overbright = {"gl_overbright", "1", true}; -cvar_t gl_overbright_models = {"gl_overbright_models", "1", true}; -cvar_t r_oldskyleaf = {"r_oldskyleaf", "0"}; -cvar_t r_drawworld = {"r_drawworld", "1"}; -cvar_t r_showtris = {"r_showtris", "0"}; -cvar_t r_showbboxes = {"r_showbboxes", "0"}; -cvar_t r_lerpmodels = {"r_lerpmodels", "1"}; -cvar_t r_lerpmove = {"r_lerpmove", "1"}; -cvar_t r_nolerp_list = {"r_nolerp_list", "progs/flame.mdl,progs/flame2.mdl,progs/braztall.mdl,progs/brazshrt.mdl,progs/longtrch.mdl,progs/flame_pyre.mdl,progs/v_saw.mdl,progs/v_xfist.mdl,progs/h2stuff/newfire.mdl"}; +cvar_t r_stereo = {"r_stereo","0",CVAR_NONE}; +cvar_t r_stereodepth = {"r_stereodepth","128",CVAR_NONE}; +cvar_t r_clearcolor = {"r_clearcolor","2",CVAR_ARCHIVE}; +cvar_t r_drawflat = {"r_drawflat","0",CVAR_NONE}; +cvar_t r_flatlightstyles = {"r_flatlightstyles", "0", CVAR_NONE}; +cvar_t gl_fullbrights = {"gl_fullbrights", "1", CVAR_ARCHIVE}; +cvar_t gl_farclip = {"gl_farclip", "16384", CVAR_ARCHIVE}; +cvar_t gl_overbright = {"gl_overbright", "1", CVAR_ARCHIVE}; +cvar_t gl_overbright_models = {"gl_overbright_models", "1", CVAR_ARCHIVE}; +cvar_t r_oldskyleaf = {"r_oldskyleaf", "0", CVAR_NONE}; +cvar_t r_drawworld = {"r_drawworld", "1", CVAR_NONE}; +cvar_t r_showtris = {"r_showtris", "0", CVAR_NONE}; +cvar_t r_showbboxes = {"r_showbboxes", "0", CVAR_NONE}; +cvar_t r_lerpmodels = {"r_lerpmodels", "1", CVAR_NONE}; +cvar_t r_lerpmove = {"r_lerpmove", "1", CVAR_NONE}; +cvar_t r_nolerp_list = {"r_nolerp_list", "progs/flame.mdl,progs/flame2.mdl,progs/braztall.mdl,progs/brazshrt.mdl,progs/longtrch.mdl,progs/flame_pyre.mdl,progs/v_saw.mdl,progs/v_xfist.mdl,progs/h2stuff/newfire.mdl", CVAR_NONE}; extern cvar_t r_vfog; //johnfitz -cvar_t gl_zfix = {"gl_zfix", "1", true}; // QuakeSpasm z-fighting fix +cvar_t gl_zfix = {"gl_zfix", "1", CVAR_ARCHIVE}; // QuakeSpasm z-fighting fix qboolean r_drawflat_cheatsafe, r_fullbright_cheatsafe, r_lightmap_cheatsafe, r_drawworld_cheatsafe; //johnfitz diff --git a/quakespasm/Quake/gl_rmisc.c b/quakespasm/Quake/gl_rmisc.c index cd43a325..dd56b3cd 100644 --- a/quakespasm/Quake/gl_rmisc.c +++ b/quakespasm/Quake/gl_rmisc.c @@ -195,50 +195,56 @@ void R_Init (void) Cmd_AddCommand ("envmap", R_Envmap_f); Cmd_AddCommand ("pointfile", R_ReadPointFile_f); - Cvar_RegisterVariable (&r_norefresh, NULL); - Cvar_RegisterVariable (&r_lightmap, NULL); - Cvar_RegisterVariable (&r_fullbright, NULL); - Cvar_RegisterVariable (&r_drawentities, NULL); - Cvar_RegisterVariable (&r_drawviewmodel, NULL); - Cvar_RegisterVariable (&r_shadows, NULL); - Cvar_RegisterVariable (&r_wateralpha, NULL); - Cvar_RegisterVariable (&r_dynamic, NULL); - Cvar_RegisterVariable (&r_novis, R_VisChanged); - Cvar_RegisterVariable (&r_speeds, NULL); + Cvar_RegisterVariable (&r_norefresh); + Cvar_RegisterVariable (&r_lightmap); + Cvar_RegisterVariable (&r_fullbright); + Cvar_RegisterVariable (&r_drawentities); + Cvar_RegisterVariable (&r_drawviewmodel); + Cvar_RegisterVariable (&r_shadows); + Cvar_RegisterVariable (&r_wateralpha); + Cvar_RegisterVariable (&r_dynamic); + Cvar_RegisterVariable (&r_novis); + Cvar_SetCallback (&r_novis, R_VisChanged); + Cvar_RegisterVariable (&r_speeds); - Cvar_RegisterVariable (&gl_finish, NULL); - Cvar_RegisterVariable (&gl_clear, NULL); - Cvar_RegisterVariable (&gl_cull, NULL); - Cvar_RegisterVariable (&gl_smoothmodels, NULL); - Cvar_RegisterVariable (&gl_affinemodels, NULL); - Cvar_RegisterVariable (&gl_polyblend, NULL); - Cvar_RegisterVariable (&gl_flashblend, NULL); - Cvar_RegisterVariable (&gl_playermip, NULL); - Cvar_RegisterVariable (&gl_nocolors, NULL); + Cvar_RegisterVariable (&gl_finish); + Cvar_RegisterVariable (&gl_clear); + Cvar_RegisterVariable (&gl_cull); + Cvar_RegisterVariable (&gl_smoothmodels); + Cvar_RegisterVariable (&gl_affinemodels); + Cvar_RegisterVariable (&gl_polyblend); + Cvar_RegisterVariable (&gl_flashblend); + Cvar_RegisterVariable (&gl_playermip); + Cvar_RegisterVariable (&gl_nocolors); //johnfitz -- new cvars - Cvar_RegisterVariable (&r_stereo, NULL); - Cvar_RegisterVariable (&r_stereodepth, NULL); - Cvar_RegisterVariable (&r_clearcolor, R_SetClearColor_f); - Cvar_RegisterVariable (&r_waterquality, NULL); - Cvar_RegisterVariable (&r_oldwater, NULL); - Cvar_RegisterVariable (&r_waterwarp, NULL); - Cvar_RegisterVariable (&r_drawflat, NULL); - Cvar_RegisterVariable (&r_flatlightstyles, NULL); - Cvar_RegisterVariable (&r_oldskyleaf, R_VisChanged); - Cvar_RegisterVariable (&r_drawworld, NULL); - Cvar_RegisterVariable (&r_showtris, NULL); - Cvar_RegisterVariable (&r_showbboxes, NULL); - Cvar_RegisterVariable (&gl_farclip, NULL); - Cvar_RegisterVariable (&gl_fullbrights, GL_Fullbrights_f); - Cvar_RegisterVariable (&gl_overbright, GL_Overbright_f); - Cvar_RegisterVariable (&gl_overbright_models, NULL); - Cvar_RegisterVariable (&r_lerpmodels, NULL); - Cvar_RegisterVariable (&r_lerpmove, NULL); - Cvar_RegisterVariable (&r_nolerp_list, R_NoLerpList_f); + Cvar_RegisterVariable (&r_stereo); + Cvar_RegisterVariable (&r_stereodepth); + Cvar_RegisterVariable (&r_clearcolor); + Cvar_SetCallback (&r_clearcolor, R_SetClearColor_f); + Cvar_RegisterVariable (&r_waterquality); + Cvar_RegisterVariable (&r_oldwater); + Cvar_RegisterVariable (&r_waterwarp); + Cvar_RegisterVariable (&r_drawflat); + Cvar_RegisterVariable (&r_flatlightstyles); + Cvar_RegisterVariable (&r_oldskyleaf); + Cvar_SetCallback (&r_oldskyleaf, R_VisChanged); + Cvar_RegisterVariable (&r_drawworld); + Cvar_RegisterVariable (&r_showtris); + Cvar_RegisterVariable (&r_showbboxes); + Cvar_RegisterVariable (&gl_farclip); + Cvar_RegisterVariable (&gl_fullbrights); + Cvar_RegisterVariable (&gl_overbright); + Cvar_SetCallback (&gl_fullbrights, GL_Fullbrights_f); + Cvar_SetCallback (&gl_overbright, GL_Overbright_f); + Cvar_RegisterVariable (&gl_overbright_models); + Cvar_RegisterVariable (&r_lerpmodels); + Cvar_RegisterVariable (&r_lerpmove); + Cvar_RegisterVariable (&r_nolerp_list); + Cvar_SetCallback (&r_nolerp_list, R_NoLerpList_f); //johnfitz - Cvar_RegisterVariable (&gl_zfix, NULL); // QuakeSpasm z-fighting fix + Cvar_RegisterVariable (&gl_zfix); // QuakeSpasm z-fighting fix R_InitParticles (); R_SetClearColor_f (&r_clearcolor); //johnfitz diff --git a/quakespasm/Quake/gl_screen.c b/quakespasm/Quake/gl_screen.c index ff720931..c57895d4 100644 --- a/quakespasm/Quake/gl_screen.c +++ b/quakespasm/Quake/gl_screen.c @@ -80,26 +80,26 @@ float scr_conlines; // lines of console to display float oldscreensize, oldfov, oldsbarscale, oldsbaralpha; //johnfitz -- added oldsbarscale and oldsbaralpha //johnfitz -- new cvars -cvar_t scr_menuscale = {"scr_menuscale", "1", true}; -cvar_t scr_sbarscale = {"scr_sbarscale", "1", true}; -cvar_t scr_sbaralpha = {"scr_sbaralpha", "0.95", true}; -cvar_t scr_conwidth = {"scr_conwidth", "0", true}; -cvar_t scr_conscale = {"scr_conscale", "1", true}; -cvar_t scr_scale = {"scr_scale", "1", true}; -cvar_t scr_crosshairscale = {"scr_crosshairscale", "1", true}; -cvar_t scr_showfps = {"scr_showfps", "0"}; -cvar_t scr_clock = {"scr_clock", "0"}; +cvar_t scr_menuscale = {"scr_menuscale", "1", CVAR_ARCHIVE}; +cvar_t scr_sbarscale = {"scr_sbarscale", "1", CVAR_ARCHIVE}; +cvar_t scr_sbaralpha = {"scr_sbaralpha", "0.95", CVAR_ARCHIVE}; +cvar_t scr_conwidth = {"scr_conwidth", "0", CVAR_ARCHIVE}; +cvar_t scr_conscale = {"scr_conscale", "1", CVAR_ARCHIVE}; +cvar_t scr_scale = {"scr_scale", "1", CVAR_ARCHIVE}; +cvar_t scr_crosshairscale = {"scr_crosshairscale", "1", CVAR_ARCHIVE}; +cvar_t scr_showfps = {"scr_showfps", "0", CVAR_NONE}; +cvar_t scr_clock = {"scr_clock", "0", CVAR_NONE}; //johnfitz -cvar_t scr_viewsize = {"viewsize","100", true}; -cvar_t scr_fov = {"fov","90"}; // 10 - 170 -cvar_t scr_conspeed = {"scr_conspeed","500",true}; -cvar_t scr_centertime = {"scr_centertime","2"}; -cvar_t scr_showram = {"showram","1"}; -cvar_t scr_showturtle = {"showturtle","0"}; -cvar_t scr_showpause = {"showpause","1"}; -cvar_t scr_printspeed = {"scr_printspeed","8"}; -cvar_t gl_triplebuffer = {"gl_triplebuffer", "1", true }; +cvar_t scr_viewsize = {"viewsize","100", CVAR_ARCHIVE}; +cvar_t scr_fov = {"fov","90",CVAR_NONE}; // 10 - 170 +cvar_t scr_conspeed = {"scr_conspeed","500",CVAR_ARCHIVE}; +cvar_t scr_centertime = {"scr_centertime","2",CVAR_NONE}; +cvar_t scr_showram = {"showram","1",CVAR_NONE}; +cvar_t scr_showturtle = {"showturtle","0",CVAR_NONE}; +cvar_t scr_showpause = {"showpause","1",CVAR_NONE}; +cvar_t scr_printspeed = {"scr_printspeed","8",CVAR_NONE}; +cvar_t gl_triplebuffer = {"gl_triplebuffer", "1", CVAR_ARCHIVE}; extern cvar_t crosshair; @@ -369,26 +369,28 @@ SCR_Init void SCR_Init (void) { //johnfitz -- new cvars - Cvar_RegisterVariable (&scr_menuscale, NULL); - Cvar_RegisterVariable (&scr_sbarscale, NULL); - Cvar_RegisterVariable (&scr_sbaralpha, NULL); - Cvar_RegisterVariable (&scr_conwidth, &SCR_Conwidth_f); - Cvar_RegisterVariable (&scr_conscale, &SCR_Conwidth_f); - Cvar_RegisterVariable (&scr_scale, NULL); - Cvar_RegisterVariable (&scr_crosshairscale, NULL); - Cvar_RegisterVariable (&scr_showfps, NULL); - Cvar_RegisterVariable (&scr_clock, NULL); + Cvar_RegisterVariable (&scr_menuscale); + Cvar_RegisterVariable (&scr_sbarscale); + Cvar_RegisterVariable (&scr_sbaralpha); + Cvar_RegisterVariable (&scr_conwidth); + Cvar_RegisterVariable (&scr_conscale); + Cvar_SetCallback (&scr_conwidth, &SCR_Conwidth_f); + Cvar_SetCallback (&scr_conscale, &SCR_Conwidth_f); + Cvar_RegisterVariable (&scr_scale); + Cvar_RegisterVariable (&scr_crosshairscale); + Cvar_RegisterVariable (&scr_showfps); + Cvar_RegisterVariable (&scr_clock); //johnfitz - Cvar_RegisterVariable (&scr_fov, NULL); - Cvar_RegisterVariable (&scr_viewsize, NULL); - Cvar_RegisterVariable (&scr_conspeed, NULL); - Cvar_RegisterVariable (&scr_showram, NULL); - Cvar_RegisterVariable (&scr_showturtle, NULL); - Cvar_RegisterVariable (&scr_showpause, NULL); - Cvar_RegisterVariable (&scr_centertime, NULL); - Cvar_RegisterVariable (&scr_printspeed, NULL); - Cvar_RegisterVariable (&gl_triplebuffer, NULL); + Cvar_RegisterVariable (&scr_fov); + Cvar_RegisterVariable (&scr_viewsize); + Cvar_RegisterVariable (&scr_conspeed); + Cvar_RegisterVariable (&scr_showram); + Cvar_RegisterVariable (&scr_showturtle); + Cvar_RegisterVariable (&scr_showpause); + Cvar_RegisterVariable (&scr_centertime); + Cvar_RegisterVariable (&scr_printspeed); + Cvar_RegisterVariable (&gl_triplebuffer); Cmd_AddCommand ("screenshot",SCR_ScreenShot_f); Cmd_AddCommand ("sizeup",SCR_SizeUp_f); diff --git a/quakespasm/Quake/gl_sky.c b/quakespasm/Quake/gl_sky.c index a01780c5..86f0bf68 100644 --- a/quakespasm/Quake/gl_sky.c +++ b/quakespasm/Quake/gl_sky.c @@ -40,10 +40,10 @@ gltexture_t *skybox_textures[6]; gltexture_t *solidskytexture, *alphaskytexture; extern cvar_t gl_farclip; -cvar_t r_fastsky = {"r_fastsky", "0"}; -cvar_t r_sky_quality = {"r_sky_quality", "12"}; -cvar_t r_skyalpha = {"r_skyalpha", "1"}; -cvar_t r_skyfog = {"r_skyfog","0.5"}; +cvar_t r_fastsky = {"r_fastsky", "0", CVAR_NONE}; +cvar_t r_sky_quality = {"r_sky_quality", "12", CVAR_NONE}; +cvar_t r_skyalpha = {"r_skyalpha", "1", CVAR_NONE}; +cvar_t r_skyfog = {"r_skyfog","0.5",CVAR_NONE}; int skytexorder[6] = {0,2,1,3,4,5}; //for skybox @@ -295,10 +295,10 @@ void Sky_Init (void) { int i; - Cvar_RegisterVariable (&r_fastsky, NULL); - Cvar_RegisterVariable (&r_sky_quality, NULL); - Cvar_RegisterVariable (&r_skyalpha, NULL); - Cvar_RegisterVariable (&r_skyfog, NULL); + Cvar_RegisterVariable (&r_fastsky); + Cvar_RegisterVariable (&r_sky_quality); + Cvar_RegisterVariable (&r_skyalpha); + Cvar_RegisterVariable (&r_skyfog); Cmd_AddCommand ("sky",Sky_SkyCommand_f); diff --git a/quakespasm/Quake/gl_texmgr.c b/quakespasm/Quake/gl_texmgr.c index 738b52b2..3125370a 100644 --- a/quakespasm/Quake/gl_texmgr.c +++ b/quakespasm/Quake/gl_texmgr.c @@ -25,9 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern qboolean gl_anisotropy_able; -cvar_t gl_texture_anisotropy = {"gl_texture_anisotropy", "1", true}; -cvar_t gl_max_size = {"gl_max_size", "0"}; -cvar_t gl_picmip = {"gl_picmip", "0"}; +cvar_t gl_texture_anisotropy = {"gl_texture_anisotropy", "1", CVAR_ARCHIVE}; +cvar_t gl_max_size = {"gl_max_size", "0", CVAR_NONE}; +cvar_t gl_picmip = {"gl_picmip", "0", CVAR_NONE}; GLint gl_hardware_maxsize; const int gl_solid_format = 3; const int gl_alpha_format = 4; @@ -580,9 +580,10 @@ void TexMgr_Init (void) // palette TexMgr_LoadPalette (); - Cvar_RegisterVariable (&gl_max_size, NULL); - Cvar_RegisterVariable (&gl_picmip, NULL); - Cvar_RegisterVariable (&gl_texture_anisotropy, &TexMgr_Anisotropy_f); + Cvar_RegisterVariable (&gl_max_size); + Cvar_RegisterVariable (&gl_picmip); + Cvar_RegisterVariable (&gl_texture_anisotropy); + Cvar_SetCallback(&gl_texture_anisotropy, &TexMgr_Anisotropy_f); Cmd_AddCommand ("gl_texturemode", &TexMgr_TextureMode_f); Cmd_AddCommand ("gl_describetexturemodes", &TexMgr_DescribeTextureModes_f); Cmd_AddCommand ("imagelist", &TexMgr_Imagelist_f); diff --git a/quakespasm/Quake/gl_vidnt.c b/quakespasm/Quake/gl_vidnt.c index 27c441e3..beda2bdb 100644 --- a/quakespasm/Quake/gl_vidnt.c +++ b/quakespasm/Quake/gl_vidnt.c @@ -153,16 +153,16 @@ void GL_SetupState (void); //johnfitz //==================================== //johnfitz -- new cvars -cvar_t vid_fullscreen = {"vid_fullscreen", "1", true}; -cvar_t vid_width = {"vid_width", "640", true}; -cvar_t vid_height = {"vid_height", "480", true}; -cvar_t vid_bpp = {"vid_bpp", "16", true}; -cvar_t vid_refreshrate = {"vid_refreshrate", "60", true}; -cvar_t vid_vsync = {"vid_vsync", "0", true}; +cvar_t vid_fullscreen = {"vid_fullscreen", "1", CVAR_ARCHIVE}; +cvar_t vid_width = {"vid_width", "640", CVAR_ARCHIVE}; +cvar_t vid_height = {"vid_height", "480", CVAR_ARCHIVE}; +cvar_t vid_bpp = {"vid_bpp", "16", CVAR_ARCHIVE}; +cvar_t vid_refreshrate = {"vid_refreshrate", "60", CVAR_ARCHIVE}; +cvar_t vid_vsync = {"vid_vsync", "0", CVAR_ARCHIVE}; //johnfitz -cvar_t _windowed_mouse = {"_windowed_mouse","1", true}; -cvar_t vid_gamma = {"gamma", "1", true}; //johnfitz -- moved here from view.c +cvar_t _windowed_mouse = {"_windowed_mouse","1", CVAR_ARCHIVE}; +cvar_t vid_gamma = {"gamma", "1", CVAR_ARCHIVE}; //johnfitz -- moved here from view.c int window_center_x, window_center_y, window_x, window_y, window_width, window_height; RECT window_rect; @@ -277,7 +277,8 @@ void VID_Gamma_Init (void) if (GetDeviceGammaRamp (maindc, vid_systemgammaramp)) vid_gammaworks = true; - Cvar_RegisterVariable (&vid_gamma, VID_Gamma_f); + Cvar_RegisterVariable (&vid_gamma); + Cvar_SetCallback (&vid_gamma, VID_Gamma_f); } //========================================================================== @@ -1177,7 +1178,8 @@ void GL_Init (void) Cmd_AddCommand ("gl_info", GL_Info_f); //johnfitz - Cvar_RegisterVariable (&vid_vsync, VID_Vsync_f); //johnfitz + Cvar_RegisterVariable (&vid_vsync); //johnfitz + Cvar_SetCallback (&vid_vsync, VID_Vsync_f); if (strnicmp(gl_renderer,"PowerVR",7)==0) fullsbardraw = true; @@ -2070,12 +2072,12 @@ void VID_Init (void) memset(&devmode, 0, sizeof(devmode)); - Cvar_RegisterVariable (&vid_fullscreen, NULL); //johnfitz - Cvar_RegisterVariable (&vid_width, NULL); //johnfitz - Cvar_RegisterVariable (&vid_height, NULL); //johnfitz - Cvar_RegisterVariable (&vid_bpp, NULL); //johnfitz - Cvar_RegisterVariable (&vid_refreshrate, NULL); //johnfitz - Cvar_RegisterVariable (&_windowed_mouse, NULL); + Cvar_RegisterVariable (&vid_fullscreen); //johnfitz + Cvar_RegisterVariable (&vid_width); //johnfitz + Cvar_RegisterVariable (&vid_height); //johnfitz + Cvar_RegisterVariable (&vid_bpp); //johnfitz + Cvar_RegisterVariable (&vid_refreshrate); //johnfitz + Cvar_RegisterVariable (&_windowed_mouse); Cmd_AddCommand ("vid_unlock", VID_Unlock); //johnfitz Cmd_AddCommand ("vid_restart", VID_Restart); //johnfitz diff --git a/quakespasm/Quake/gl_vidsdl.c b/quakespasm/Quake/gl_vidsdl.c index 8f16a5ff..42cdd72e 100644 --- a/quakespasm/Quake/gl_vidsdl.c +++ b/quakespasm/Quake/gl_vidsdl.c @@ -135,16 +135,16 @@ void GL_SetupState (void); //johnfitz //==================================== //johnfitz -- new cvars -cvar_t vid_fullscreen = {"vid_fullscreen", "0", true}; // QuakeSpasm, was "1" -cvar_t vid_width = {"vid_width", "800", true}; // QuakeSpasm, was 640 -cvar_t vid_height = {"vid_height", "600", true}; // QuakeSpasm, was 480 -cvar_t vid_bpp = {"vid_bpp", "16", true}; -//cvar_t vid_refreshrate = {"vid_refreshrate", "60", true}; -cvar_t vid_vsync = {"vid_vsync", "0", true}; +cvar_t vid_fullscreen = {"vid_fullscreen", "0", CVAR_ARCHIVE}; // QuakeSpasm, was "1" +cvar_t vid_width = {"vid_width", "800", CVAR_ARCHIVE}; // QuakeSpasm, was 640 +cvar_t vid_height = {"vid_height", "600", CVAR_ARCHIVE}; // QuakeSpasm, was 480 +cvar_t vid_bpp = {"vid_bpp", "16", CVAR_ARCHIVE}; +//cvar_t vid_refreshrate = {"vid_refreshrate", "60", CVAR_ARCHIVE}; +cvar_t vid_vsync = {"vid_vsync", "0", CVAR_ARCHIVE}; //johnfitz -cvar_t _windowed_mouse = {"_windowed_mouse","1", true}; -cvar_t vid_gamma = {"gamma", "1", true}; //johnfitz -- moved here from view.c +cvar_t _windowed_mouse = {"_windowed_mouse","1", CVAR_ARCHIVE}; +cvar_t vid_gamma = {"gamma", "1", CVAR_ARCHIVE}; //johnfitz -- moved here from view.c //========================================================================== // @@ -234,7 +234,8 @@ void VID_Gamma_Init (void) if (SDL_GetGammaRamp (&vid_sysgamma_red[0], &vid_sysgamma_green[0], &vid_sysgamma_blue[0]) != -1) vid_gammaworks = true; - Cvar_RegisterVariable (&vid_gamma, VID_Gamma_f); + Cvar_RegisterVariable (&vid_gamma); + Cvar_SetCallback (&vid_gamma, VID_Gamma_f); } /* @@ -758,7 +759,8 @@ void GL_Init (void) Cmd_AddCommand ("gl_info", GL_Info_f); //johnfitz - Cvar_RegisterVariable (&vid_vsync, VID_Changed_f); //johnfitz + Cvar_RegisterVariable (&vid_vsync); //johnfitz + Cvar_SetCallback (&vid_vsync, VID_Changed_f); if (SDL_strncasecmp(gl_renderer,"PowerVR",7)==0) fullsbardraw = true; @@ -1149,12 +1151,16 @@ void VID_Init (void) "vid_bpp" }; #define num_readvars ( sizeof(read_vars)/sizeof(read_vars[0]) ) - Cvar_RegisterVariable (&vid_fullscreen, VID_Changed_f); //johnfitz - Cvar_RegisterVariable (&vid_width, VID_Changed_f); //johnfitz - Cvar_RegisterVariable (&vid_height, VID_Changed_f); //johnfitz - Cvar_RegisterVariable (&vid_bpp, VID_Changed_f); //johnfitz - //Cvar_RegisterVariable (&vid_refreshrate, NULL); //johnfitz - Cvar_RegisterVariable (&_windowed_mouse, NULL); + Cvar_RegisterVariable (&vid_fullscreen); //johnfitz + Cvar_RegisterVariable (&vid_width); //johnfitz + Cvar_RegisterVariable (&vid_height); //johnfitz + Cvar_RegisterVariable (&vid_bpp); //johnfitz + Cvar_SetCallback (&vid_fullscreen, VID_Changed_f); + Cvar_SetCallback (&vid_width, VID_Changed_f); + Cvar_SetCallback (&vid_height, VID_Changed_f); + Cvar_SetCallback (&vid_bpp, VID_Changed_f); + //Cvar_RegisterVariable (&vid_refreshrate); //johnfitz + Cvar_RegisterVariable (&_windowed_mouse); Cmd_AddCommand ("vid_unlock", VID_Unlock); //johnfitz Cmd_AddCommand ("vid_restart", VID_Restart); //johnfitz diff --git a/quakespasm/Quake/gl_warp.c b/quakespasm/Quake/gl_warp.c index 1741a5a2..27decada 100644 --- a/quakespasm/Quake/gl_warp.c +++ b/quakespasm/Quake/gl_warp.c @@ -23,9 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern cvar_t r_drawflat; -cvar_t r_oldwater = {"r_oldwater", "1"}; -cvar_t r_waterquality = {"r_waterquality", "8"}; -cvar_t r_waterwarp = {"r_waterwarp", "1"}; +cvar_t r_oldwater = {"r_oldwater", "1", CVAR_NONE}; +cvar_t r_waterquality = {"r_waterquality", "8", CVAR_NONE}; +cvar_t r_waterwarp = {"r_waterwarp", "1", CVAR_NONE}; int gl_warpimagesize; @@ -33,7 +33,7 @@ float load_subdivide_size; //johnfitz -- remember what subdivide_size value was float turbsin[] = { - #include "gl_warp_sin.h" +#include "gl_warp_sin.h" }; #define WARPCALC(s,t) ((s + turbsin[(int)((t*2)+(cl.time*(128.0/M_PI))) & 255]) * (1.0/64)) //johnfitz -- correct warp @@ -49,7 +49,7 @@ extern model_t *loadmodel; msurface_t *warpface; -cvar_t gl_subdivide_size = {"gl_subdivide_size", "128", true}; +cvar_t gl_subdivide_size = {"gl_subdivide_size", "128", CVAR_ARCHIVE}; void BoundPoly (int numverts, float *verts, vec3_t mins, vec3_t maxs) { diff --git a/quakespasm/Quake/host.c b/quakespasm/Quake/host.c index aa4ce42c..7d9c161a 100644 --- a/quakespasm/Quake/host.c +++ b/quakespasm/Quake/host.c @@ -57,31 +57,31 @@ jmp_buf host_abortserver; byte *host_colormap; -cvar_t host_framerate = {"host_framerate","0"}; // set for slow motion -cvar_t host_speeds = {"host_speeds","0"}; // set for running times -cvar_t host_maxfps = {"host_maxfps", "72", true}; //johnfitz -cvar_t host_timescale = {"host_timescale", "0"}; //johnfitz -cvar_t max_edicts = {"max_edicts", STR(DEF_EDICTS), true}; //johnfitz +cvar_t host_framerate = {"host_framerate","0",CVAR_NONE}; // set for slow motion +cvar_t host_speeds = {"host_speeds","0",CVAR_NONE}; // set for running times +cvar_t host_maxfps = {"host_maxfps", "72", CVAR_ARCHIVE}; //johnfitz +cvar_t host_timescale = {"host_timescale", "0", CVAR_NONE}; //johnfitz +cvar_t max_edicts = {"max_edicts", STR(DEF_EDICTS), CVAR_ARCHIVE}; //johnfitz -cvar_t sys_ticrate = {"sys_ticrate","0.05"}; // dedicated server -cvar_t serverprofile = {"serverprofile","0"}; +cvar_t sys_ticrate = {"sys_ticrate","0.05",CVAR_NONE}; // dedicated server +cvar_t serverprofile = {"serverprofile","0",CVAR_NONE}; -cvar_t fraglimit = {"fraglimit","0",false,true}; -cvar_t timelimit = {"timelimit","0",false,true}; -cvar_t teamplay = {"teamplay","0",false,true}; -cvar_t samelevel = {"samelevel","0"}; -cvar_t noexit = {"noexit","0",false,true}; -cvar_t skill = {"skill","1"}; // 0 - 3 -cvar_t deathmatch = {"deathmatch","0"}; // 0, 1, or 2 -cvar_t coop = {"coop","0"}; // 0 or 1 +cvar_t fraglimit = {"fraglimit","0",CVAR_NOTIFY|CVAR_SERVERINFO}; +cvar_t timelimit = {"timelimit","0",CVAR_NOTIFY|CVAR_SERVERINFO}; +cvar_t teamplay = {"teamplay","0",CVAR_NOTIFY|CVAR_SERVERINFO}; +cvar_t samelevel = {"samelevel","0",CVAR_NONE}; +cvar_t noexit = {"noexit","0",CVAR_NOTIFY|CVAR_SERVERINFO}; +cvar_t skill = {"skill","1",CVAR_NONE}; // 0 - 3 +cvar_t deathmatch = {"deathmatch","0",CVAR_NONE}; // 0, 1, or 2 +cvar_t coop = {"coop","0",CVAR_NONE}; // 0 or 1 -cvar_t pausable = {"pausable","1"}; +cvar_t pausable = {"pausable","1",CVAR_NONE}; -cvar_t developer = {"developer","0"}; +cvar_t developer = {"developer","0",CVAR_NONE}; -cvar_t temp1 = {"temp1","0"}; +cvar_t temp1 = {"temp1","0",CVAR_NONE}; -cvar_t devstats = {"devstats","0"}; //johnfitz -- track developer statistics that vary every frame +cvar_t devstats = {"devstats","0",CVAR_NONE}; //johnfitz -- track developer statistics that vary every frame devstats_t dev_stats, dev_peakstats; overflowtimes_t dev_overflows; //this stores the last time overflow messages were displayed, not the last time overflows occured @@ -231,6 +231,13 @@ void Host_Version_f (void) Con_Printf ("Exe: "__TIME__" "__DATE__"\n"); } +/* cvar callback functions : */ +void Host_Callback_Notify (cvar_t *var) +{ + if (sv.active) + SV_BroadcastPrintf ("\"%s\" changed to \"%s\"\n", var->name, var->string); +} + /* ======================= Host_InitLocal @@ -242,31 +249,36 @@ void Host_InitLocal (void) Host_InitCommands (); - Cvar_RegisterVariable (&host_framerate, NULL); - Cvar_RegisterVariable (&host_speeds, NULL); - Cvar_RegisterVariable (&host_maxfps, NULL); //johnfitz - Cvar_RegisterVariable (&host_timescale, NULL); //johnfitz + Cvar_RegisterVariable (&host_framerate); + Cvar_RegisterVariable (&host_speeds); + Cvar_RegisterVariable (&host_maxfps); //johnfitz + Cvar_RegisterVariable (&host_timescale); //johnfitz - Cvar_RegisterVariable (&max_edicts, Max_Edicts_f); //johnfitz - Cvar_RegisterVariable (&devstats, NULL); //johnfitz + Cvar_RegisterVariable (&max_edicts); //johnfitz + Cvar_SetCallback (&max_edicts, Max_Edicts_f); + Cvar_RegisterVariable (&devstats); //johnfitz - Cvar_RegisterVariable (&sys_ticrate, NULL); - Cvar_RegisterVariable (&sys_throttle, NULL); - Cvar_RegisterVariable (&serverprofile, NULL); + Cvar_RegisterVariable (&sys_ticrate); + Cvar_RegisterVariable (&sys_throttle); + Cvar_RegisterVariable (&serverprofile); - Cvar_RegisterVariable (&fraglimit, NULL); - Cvar_RegisterVariable (&timelimit, NULL); - Cvar_RegisterVariable (&teamplay, NULL); - Cvar_RegisterVariable (&samelevel, NULL); - Cvar_RegisterVariable (&noexit, NULL); - Cvar_RegisterVariable (&skill, NULL); - Cvar_RegisterVariable (&developer, NULL); - Cvar_RegisterVariable (&coop, NULL); - Cvar_RegisterVariable (&deathmatch, NULL); + Cvar_RegisterVariable (&fraglimit); + Cvar_RegisterVariable (&timelimit); + Cvar_RegisterVariable (&teamplay); + Cvar_SetCallback (&fraglimit, Host_Callback_Notify); + Cvar_SetCallback (&timelimit, Host_Callback_Notify); + Cvar_SetCallback (&teamplay, Host_Callback_Notify); + Cvar_RegisterVariable (&samelevel); + Cvar_RegisterVariable (&noexit); + Cvar_SetCallback (&noexit, Host_Callback_Notify); + Cvar_RegisterVariable (&skill); + Cvar_RegisterVariable (&developer); + Cvar_RegisterVariable (&coop); + Cvar_RegisterVariable (&deathmatch); - Cvar_RegisterVariable (&pausable, NULL); + Cvar_RegisterVariable (&pausable); - Cvar_RegisterVariable (&temp1, NULL); + Cvar_RegisterVariable (&temp1); Host_FindMaxClients (); diff --git a/quakespasm/Quake/in_sdl.c b/quakespasm/Quake/in_sdl.c index 90237685..2cfc95a8 100644 --- a/quakespasm/Quake/in_sdl.c +++ b/quakespasm/Quake/in_sdl.c @@ -39,7 +39,7 @@ static int buttonremap[] = }; /* mouse variables */ -cvar_t m_filter = {"m_filter","0"}; +cvar_t m_filter = {"m_filter","0",CVAR_NONE}; /* total accumulated mouse movement since last frame, * gets updated from the main game loop via IN_MouseMove */ diff --git a/quakespasm/Quake/net_dgrm.c b/quakespasm/Quake/net_dgrm.c index 4de328a3..4bcd0f60 100644 --- a/quakespasm/Quake/net_dgrm.c +++ b/quakespasm/Quake/net_dgrm.c @@ -973,7 +973,7 @@ static qsocket_t *_Datagram_CheckNewConnections (void) // search for the next server cvar while (var) { - if (var->server) + if (var->flags & CVAR_SERVERINFO) break; var = var->next; } diff --git a/quakespasm/Quake/net_main.c b/quakespasm/Quake/net_main.c index 00ee3776..07fb8c48 100644 --- a/quakespasm/Quake/net_main.c +++ b/quakespasm/Quake/net_main.c @@ -61,8 +61,8 @@ int messagesReceived = 0; int unreliableMessagesSent = 0; int unreliableMessagesReceived = 0; -static cvar_t net_messagetimeout = {"net_messagetimeout","300"}; -cvar_t hostname = {"hostname", "UNNAMED"}; +static cvar_t net_messagetimeout = {"net_messagetimeout","300",CVAR_NONE}; +cvar_t hostname = {"hostname", "UNNAMED", CVAR_NONE}; // these two macros are to make the code more readable #define sfunc net_drivers[sock->driver] @@ -733,8 +733,8 @@ void NET_Init (void) // allocate space for network message buffer SZ_Alloc (&net_message, NET_MAXMESSAGE); - Cvar_RegisterVariable (&net_messagetimeout, NULL); - Cvar_RegisterVariable (&hostname, NULL); + Cvar_RegisterVariable (&net_messagetimeout); + Cvar_RegisterVariable (&hostname); Cmd_AddCommand ("slist", NET_Slist_f); Cmd_AddCommand ("listen", NET_Listen_f); diff --git a/quakespasm/Quake/pr_cmds.c b/quakespasm/Quake/pr_cmds.c index b145c922..623d6c88 100644 --- a/quakespasm/Quake/pr_cmds.c +++ b/quakespasm/Quake/pr_cmds.c @@ -1320,7 +1320,7 @@ Pick a vector for the player to shoot along vector aim(entity, missilespeed) ============= */ -cvar_t sv_aim = {"sv_aim", "0.93"}; +cvar_t sv_aim = {"sv_aim", "0.93", CVAR_NONE}; static void PF_aim (void) { edict_t *ent, *check, *bestent; diff --git a/quakespasm/Quake/pr_edict.c b/quakespasm/Quake/pr_edict.c index 012d65b7..dda04a14 100644 --- a/quakespasm/Quake/pr_edict.c +++ b/quakespasm/Quake/pr_edict.c @@ -70,17 +70,17 @@ static gefv_cache gefvCache[GEFV_CACHESIZE] = { NULL, "" } }; -cvar_t nomonsters = {"nomonsters", "0"}; -cvar_t gamecfg = {"gamecfg", "0"}; -cvar_t scratch1 = {"scratch1", "0"}; -cvar_t scratch2 = {"scratch2", "0"}; -cvar_t scratch3 = {"scratch3", "0"}; -cvar_t scratch4 = {"scratch4", "0"}; -cvar_t savedgamecfg = {"savedgamecfg", "0", true}; -cvar_t saved1 = {"saved1", "0", true}; -cvar_t saved2 = {"saved2", "0", true}; -cvar_t saved3 = {"saved3", "0", true}; -cvar_t saved4 = {"saved4", "0", true}; +cvar_t nomonsters = {"nomonsters", "0", CVAR_NONE}; +cvar_t gamecfg = {"gamecfg", "0", CVAR_NONE}; +cvar_t scratch1 = {"scratch1", "0", CVAR_NONE}; +cvar_t scratch2 = {"scratch2", "0", CVAR_NONE}; +cvar_t scratch3 = {"scratch3", "0", CVAR_NONE}; +cvar_t scratch4 = {"scratch4", "0", CVAR_NONE}; +cvar_t savedgamecfg = {"savedgamecfg", "0", CVAR_ARCHIVE}; +cvar_t saved1 = {"saved1", "0", CVAR_ARCHIVE}; +cvar_t saved2 = {"saved2", "0", CVAR_ARCHIVE}; +cvar_t saved3 = {"saved3", "0", CVAR_ARCHIVE}; +cvar_t saved4 = {"saved4", "0", CVAR_ARCHIVE}; /* ================= @@ -1138,17 +1138,17 @@ void PR_Init (void) Cmd_AddCommand ("edicts", ED_PrintEdicts); Cmd_AddCommand ("edictcount", ED_Count); Cmd_AddCommand ("profile", PR_Profile_f); - Cvar_RegisterVariable (&nomonsters, NULL); - Cvar_RegisterVariable (&gamecfg, NULL); - Cvar_RegisterVariable (&scratch1, NULL); - Cvar_RegisterVariable (&scratch2, NULL); - Cvar_RegisterVariable (&scratch3, NULL); - Cvar_RegisterVariable (&scratch4, NULL); - Cvar_RegisterVariable (&savedgamecfg, NULL); - Cvar_RegisterVariable (&saved1, NULL); - Cvar_RegisterVariable (&saved2, NULL); - Cvar_RegisterVariable (&saved3, NULL); - Cvar_RegisterVariable (&saved4, NULL); + Cvar_RegisterVariable (&nomonsters); + Cvar_RegisterVariable (&gamecfg); + Cvar_RegisterVariable (&scratch1); + Cvar_RegisterVariable (&scratch2); + Cvar_RegisterVariable (&scratch3); + Cvar_RegisterVariable (&scratch4); + Cvar_RegisterVariable (&savedgamecfg); + Cvar_RegisterVariable (&saved1); + Cvar_RegisterVariable (&saved2); + Cvar_RegisterVariable (&saved3); + Cvar_RegisterVariable (&saved4); } diff --git a/quakespasm/Quake/quakedef.h b/quakespasm/Quake/quakedef.h index cf49fc2c..13b2362e 100644 --- a/quakespasm/Quake/quakedef.h +++ b/quakespasm/Quake/quakedef.h @@ -276,6 +276,7 @@ void Host_ServerFrame (void); void Host_InitCommands (void); void Host_Init (void); void Host_Shutdown(void); +void Host_Callback_Notify (cvar_t *var); /* callback function for CVAR_NOTIFY */ void Host_Error (const char *error, ...) __attribute__((__format__(__printf__,1,2), __noreturn__)); void Host_EndGame (const char *message, ...) __attribute__((__format__(__printf__,1,2), __noreturn__)); void Host_Frame (float time); diff --git a/quakespasm/Quake/r_part.c b/quakespasm/Quake/r_part.c index 7365c62c..3956d0ea 100644 --- a/quakespasm/Quake/r_part.c +++ b/quakespasm/Quake/r_part.c @@ -40,8 +40,8 @@ int r_numparticles; gltexture_t *particletexture, *particletexture1, *particletexture2, *particletexture3, *particletexture4; //johnfitz float texturescalefactor; //johnfitz -- compensate for apparent size of different particle textures -cvar_t r_particles = {"r_particles","1", true}; //johnfitz -cvar_t r_quadparticles = {"r_quadparticles","1", true}; //johnfitz +cvar_t r_particles = {"r_particles","1", CVAR_ARCHIVE}; //johnfitz +cvar_t r_quadparticles = {"r_quadparticles","1", CVAR_ARCHIVE}; //johnfitz /* =============== @@ -166,8 +166,9 @@ void R_InitParticles (void) particles = (particle_t *) Hunk_AllocName (r_numparticles * sizeof(particle_t), "particles"); - Cvar_RegisterVariable (&r_particles, R_SetParticleTexture_f); //johnfitz - Cvar_RegisterVariable (&r_quadparticles, NULL); //johnfitz + Cvar_RegisterVariable (&r_particles); //johnfitz + Cvar_SetCallback (&r_particles, R_SetParticleTexture_f); + Cvar_RegisterVariable (&r_quadparticles); //johnfitz R_InitParticleTextures (); //johnfitz } diff --git a/quakespasm/Quake/snd_dma.c b/quakespasm/Quake/snd_dma.c index cd93411e..c9cd28b2 100644 --- a/quakespasm/Quake/snd_dma.c +++ b/quakespasm/Quake/snd_dma.c @@ -68,22 +68,22 @@ static sfx_t *ambient_sfx[NUM_AMBIENTS]; static qboolean sound_started = false; -cvar_t bgmvolume = {"bgmvolume", "1", true}; -cvar_t sfxvolume = {"volume", "0.7", true}; +cvar_t bgmvolume = {"bgmvolume", "1", CVAR_ARCHIVE}; +cvar_t sfxvolume = {"volume", "0.7", CVAR_ARCHIVE}; -cvar_t precache = {"precache", "1"}; -cvar_t loadas8bit = {"loadas8bit", "0"}; +cvar_t precache = {"precache", "1", CVAR_NONE}; +cvar_t loadas8bit = {"loadas8bit", "0", CVAR_NONE}; -cvar_t sndspeed = {"sndspeed", "11025"}; +cvar_t sndspeed = {"sndspeed", "11025", CVAR_NONE}; static float oldvolume = -1.0; -static cvar_t nosound = {"nosound", "0"}; -static cvar_t ambient_level = {"ambient_level", "0.3"}; -static cvar_t ambient_fade = {"ambient_fade", "100"}; -static cvar_t snd_noextraupdate = {"snd_noextraupdate", "0"}; -static cvar_t snd_show = {"snd_show", "0"}; -static cvar_t _snd_mixahead = {"_snd_mixahead", "0.1", true}; +static cvar_t nosound = {"nosound", "0", CVAR_NONE}; +static cvar_t ambient_level = {"ambient_level", "0.3", CVAR_NONE}; +static cvar_t ambient_fade = {"ambient_fade", "100", CVAR_NONE}; +static cvar_t snd_noextraupdate = {"snd_noextraupdate", "0", CVAR_NONE}; +static cvar_t snd_show = {"snd_show", "0", CVAR_NONE}; +static cvar_t _snd_mixahead = {"_snd_mixahead", "0.1", CVAR_ARCHIVE}; static void S_SoundInfo_f (void) @@ -145,17 +145,17 @@ void S_Init (void) return; } - Cvar_RegisterVariable(&nosound, NULL); - Cvar_RegisterVariable(&sfxvolume, NULL); - Cvar_RegisterVariable(&precache, NULL); - Cvar_RegisterVariable(&loadas8bit, NULL); - Cvar_RegisterVariable(&bgmvolume, NULL); - Cvar_RegisterVariable(&ambient_level, NULL); - Cvar_RegisterVariable(&ambient_fade, NULL); - Cvar_RegisterVariable(&snd_noextraupdate, NULL); - Cvar_RegisterVariable(&snd_show, NULL); - Cvar_RegisterVariable(&_snd_mixahead, NULL); - Cvar_RegisterVariable(&sndspeed, NULL); + Cvar_RegisterVariable(&nosound); + Cvar_RegisterVariable(&sfxvolume); + Cvar_RegisterVariable(&precache); + Cvar_RegisterVariable(&loadas8bit); + Cvar_RegisterVariable(&bgmvolume); + Cvar_RegisterVariable(&ambient_level); + Cvar_RegisterVariable(&ambient_fade); + Cvar_RegisterVariable(&snd_noextraupdate); + Cvar_RegisterVariable(&snd_show); + Cvar_RegisterVariable(&_snd_mixahead); + Cvar_RegisterVariable(&sndspeed); if (safemode || COM_CheckParm("-nosound")) return; diff --git a/quakespasm/Quake/sv_main.c b/quakespasm/Quake/sv_main.c index c57b979a..c227494f 100644 --- a/quakespasm/Quake/sv_main.c +++ b/quakespasm/Quake/sv_main.c @@ -89,18 +89,21 @@ void SV_Init (void) extern cvar_t sv_aim; extern cvar_t sv_altnoclip; //johnfitz - Cvar_RegisterVariable (&sv_maxvelocity, NULL); - Cvar_RegisterVariable (&sv_gravity, NULL); - Cvar_RegisterVariable (&sv_friction, NULL); - Cvar_RegisterVariable (&sv_edgefriction, NULL); - Cvar_RegisterVariable (&sv_stopspeed, NULL); - Cvar_RegisterVariable (&sv_maxspeed, NULL); - Cvar_RegisterVariable (&sv_accelerate, NULL); - Cvar_RegisterVariable (&sv_idealpitchscale, NULL); - Cvar_RegisterVariable (&sv_aim, NULL); - Cvar_RegisterVariable (&sv_nostep, NULL); - Cvar_RegisterVariable (&sv_freezenonclients, NULL); - Cvar_RegisterVariable (&sv_altnoclip, NULL); //johnfitz + Cvar_RegisterVariable (&sv_maxvelocity); + Cvar_RegisterVariable (&sv_gravity); + Cvar_RegisterVariable (&sv_friction); + Cvar_SetCallback (&sv_gravity, Host_Callback_Notify); + Cvar_SetCallback (&sv_friction, Host_Callback_Notify); + Cvar_RegisterVariable (&sv_edgefriction); + Cvar_RegisterVariable (&sv_stopspeed); + Cvar_RegisterVariable (&sv_maxspeed); + Cvar_SetCallback (&sv_maxspeed, Host_Callback_Notify); + Cvar_RegisterVariable (&sv_accelerate); + Cvar_RegisterVariable (&sv_idealpitchscale); + Cvar_RegisterVariable (&sv_aim); + Cvar_RegisterVariable (&sv_nostep); + Cvar_RegisterVariable (&sv_freezenonclients); + Cvar_RegisterVariable (&sv_altnoclip); //johnfitz Cmd_AddCommand ("sv_protocol", &SV_Protocol_f); //johnfitz diff --git a/quakespasm/Quake/sv_phys.c b/quakespasm/Quake/sv_phys.c index 06dbb164..e7bf7875 100644 --- a/quakespasm/Quake/sv_phys.c +++ b/quakespasm/Quake/sv_phys.c @@ -40,12 +40,12 @@ solid_edge items only clip against bsp models. */ -cvar_t sv_friction = {"sv_friction","4",false,true}; -cvar_t sv_stopspeed = {"sv_stopspeed","100"}; -cvar_t sv_gravity = {"sv_gravity","800",false,true}; -cvar_t sv_maxvelocity = {"sv_maxvelocity","2000"}; -cvar_t sv_nostep = {"sv_nostep","0"}; -cvar_t sv_freezenonclients = {"sv_freezenonclients","0"}; +cvar_t sv_friction = {"sv_friction","4",CVAR_NOTIFY|CVAR_SERVERINFO}; +cvar_t sv_stopspeed = {"sv_stopspeed","100",CVAR_NONE}; +cvar_t sv_gravity = {"sv_gravity","800",CVAR_NOTIFY|CVAR_SERVERINFO}; +cvar_t sv_maxvelocity = {"sv_maxvelocity","2000",CVAR_NONE}; +cvar_t sv_nostep = {"sv_nostep","0",CVAR_NONE}; +cvar_t sv_freezenonclients = {"sv_freezenonclients","0",CVAR_NONE}; #define MOVE_EPSILON 0.01 diff --git a/quakespasm/Quake/sv_user.c b/quakespasm/Quake/sv_user.c index 91b85a24..35eb662c 100644 --- a/quakespasm/Quake/sv_user.c +++ b/quakespasm/Quake/sv_user.c @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. edict_t *sv_player; extern cvar_t sv_friction; -cvar_t sv_edgefriction = {"edgefriction", "2"}; +cvar_t sv_edgefriction = {"edgefriction", "2", CVAR_NONE}; extern cvar_t sv_stopspeed; static vec3_t forward, right, up; @@ -42,8 +42,8 @@ qboolean onground; usercmd_t cmd; -cvar_t sv_idealpitchscale = {"sv_idealpitchscale","0.8"}; -cvar_t sv_altnoclip = {"sv_altnoclip","1",true}; //johnfitz +cvar_t sv_idealpitchscale = {"sv_idealpitchscale","0.8",CVAR_NONE}; +cvar_t sv_altnoclip = {"sv_altnoclip","1",CVAR_ARCHIVE}; //johnfitz /* =============== @@ -165,8 +165,8 @@ void SV_UserFriction (void) SV_Accelerate ============== */ -cvar_t sv_maxspeed = {"sv_maxspeed", "320", false, true}; -cvar_t sv_accelerate = {"sv_accelerate", "10"}; +cvar_t sv_maxspeed = {"sv_maxspeed", "320", CVAR_NOTIFY|CVAR_SERVERINFO}; +cvar_t sv_accelerate = {"sv_accelerate", "10", CVAR_NONE}; void SV_Accelerate (void) { int i; diff --git a/quakespasm/Quake/sys_sdl_unix.c b/quakespasm/Quake/sys_sdl_unix.c index 958ed8b4..090f5482 100644 --- a/quakespasm/Quake/sys_sdl_unix.c +++ b/quakespasm/Quake/sys_sdl_unix.c @@ -34,7 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. qboolean isDedicated; -cvar_t sys_throttle = {"sys_throttle", "0.02", true}; +cvar_t sys_throttle = {"sys_throttle", "0.02", CVAR_ARCHIVE}; #define MAX_HANDLES 32 /* johnfitz -- was 10 */ static FILE *sys_handles[MAX_HANDLES]; diff --git a/quakespasm/Quake/sys_sdl_win.c b/quakespasm/Quake/sys_sdl_win.c index bd14b41a..1b8bd6bb 100644 --- a/quakespasm/Quake/sys_sdl_win.c +++ b/quakespasm/Quake/sys_sdl_win.c @@ -37,7 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. qboolean isDedicated; qboolean Win95, Win95old, WinNT, WinVista; -cvar_t sys_throttle = {"sys_throttle", "0.02", true}; +cvar_t sys_throttle = {"sys_throttle", "0.02", CVAR_ARCHIVE}; static HANDLE hinput, houtput; diff --git a/quakespasm/Quake/view.c b/quakespasm/Quake/view.c index d5856297..3092c00e 100644 --- a/quakespasm/Quake/view.c +++ b/quakespasm/Quake/view.c @@ -31,34 +31,34 @@ when crossing a water boudnary. */ -cvar_t scr_ofsx = {"scr_ofsx","0", false}; -cvar_t scr_ofsy = {"scr_ofsy","0", false}; -cvar_t scr_ofsz = {"scr_ofsz","0", false}; +cvar_t scr_ofsx = {"scr_ofsx","0", CVAR_NONE}; +cvar_t scr_ofsy = {"scr_ofsy","0", CVAR_NONE}; +cvar_t scr_ofsz = {"scr_ofsz","0", CVAR_NONE}; -cvar_t cl_rollspeed = {"cl_rollspeed", "200"}; -cvar_t cl_rollangle = {"cl_rollangle", "2.0"}; +cvar_t cl_rollspeed = {"cl_rollspeed", "200", CVAR_NONE}; +cvar_t cl_rollangle = {"cl_rollangle", "2.0", CVAR_NONE}; -cvar_t cl_bob = {"cl_bob","0.02", false}; -cvar_t cl_bobcycle = {"cl_bobcycle","0.6", false}; -cvar_t cl_bobup = {"cl_bobup","0.5", false}; +cvar_t cl_bob = {"cl_bob","0.02", CVAR_NONE}; +cvar_t cl_bobcycle = {"cl_bobcycle","0.6", CVAR_NONE}; +cvar_t cl_bobup = {"cl_bobup","0.5", CVAR_NONE}; -cvar_t v_kicktime = {"v_kicktime", "0.5", false}; -cvar_t v_kickroll = {"v_kickroll", "0.6", false}; -cvar_t v_kickpitch = {"v_kickpitch", "0.6", false}; -cvar_t v_gunkick = {"v_gunkick", "1"}; //johnfitz +cvar_t v_kicktime = {"v_kicktime", "0.5", CVAR_NONE}; +cvar_t v_kickroll = {"v_kickroll", "0.6", CVAR_NONE}; +cvar_t v_kickpitch = {"v_kickpitch", "0.6", CVAR_NONE}; +cvar_t v_gunkick = {"v_gunkick", "1", CVAR_NONE}; //johnfitz -cvar_t v_iyaw_cycle = {"v_iyaw_cycle", "2", false}; -cvar_t v_iroll_cycle = {"v_iroll_cycle", "0.5", false}; -cvar_t v_ipitch_cycle = {"v_ipitch_cycle", "1", false}; -cvar_t v_iyaw_level = {"v_iyaw_level", "0.3", false}; -cvar_t v_iroll_level = {"v_iroll_level", "0.1", false}; -cvar_t v_ipitch_level = {"v_ipitch_level", "0.3", false}; +cvar_t v_iyaw_cycle = {"v_iyaw_cycle", "2", CVAR_NONE}; +cvar_t v_iroll_cycle = {"v_iroll_cycle", "0.5", CVAR_NONE}; +cvar_t v_ipitch_cycle = {"v_ipitch_cycle", "1", CVAR_NONE}; +cvar_t v_iyaw_level = {"v_iyaw_level", "0.3", CVAR_NONE}; +cvar_t v_iroll_level = {"v_iroll_level", "0.1", CVAR_NONE}; +cvar_t v_ipitch_level = {"v_ipitch_level", "0.3", CVAR_NONE}; -cvar_t v_idlescale = {"v_idlescale", "0", false}; +cvar_t v_idlescale = {"v_idlescale", "0", CVAR_NONE}; -cvar_t crosshair = {"crosshair", "0", true}; +cvar_t crosshair = {"crosshair", "0", CVAR_ARCHIVE}; -cvar_t gl_cshiftpercent = {"gl_cshiftpercent", "100", false}; +cvar_t gl_cshiftpercent = {"gl_cshiftpercent", "100", CVAR_NONE}; float v_dmg_time, v_dmg_roll, v_dmg_pitch; @@ -135,8 +135,8 @@ float V_CalcBob (void) //============================================================================= -cvar_t v_centermove = {"v_centermove", "0.15", false}; -cvar_t v_centerspeed = {"v_centerspeed","500"}; +cvar_t v_centermove = {"v_centermove", "0.15", CVAR_NONE}; +cvar_t v_centerspeed = {"v_centerspeed","500", CVAR_NONE}; void V_StartPitchDrift (void) @@ -888,33 +888,33 @@ void V_Init (void) Cmd_AddCommand ("bf", V_BonusFlash_f); Cmd_AddCommand ("centerview", V_StartPitchDrift); - Cvar_RegisterVariable (&v_centermove, NULL); - Cvar_RegisterVariable (&v_centerspeed, NULL); + Cvar_RegisterVariable (&v_centermove); + Cvar_RegisterVariable (&v_centerspeed); - Cvar_RegisterVariable (&v_iyaw_cycle, NULL); - Cvar_RegisterVariable (&v_iroll_cycle, NULL); - Cvar_RegisterVariable (&v_ipitch_cycle, NULL); - Cvar_RegisterVariable (&v_iyaw_level, NULL); - Cvar_RegisterVariable (&v_iroll_level, NULL); - Cvar_RegisterVariable (&v_ipitch_level, NULL); + Cvar_RegisterVariable (&v_iyaw_cycle); + Cvar_RegisterVariable (&v_iroll_cycle); + Cvar_RegisterVariable (&v_ipitch_cycle); + Cvar_RegisterVariable (&v_iyaw_level); + Cvar_RegisterVariable (&v_iroll_level); + Cvar_RegisterVariable (&v_ipitch_level); - Cvar_RegisterVariable (&v_idlescale, NULL); - Cvar_RegisterVariable (&crosshair, NULL); - Cvar_RegisterVariable (&gl_cshiftpercent, NULL); + Cvar_RegisterVariable (&v_idlescale); + Cvar_RegisterVariable (&crosshair); + Cvar_RegisterVariable (&gl_cshiftpercent); - Cvar_RegisterVariable (&scr_ofsx, NULL); - Cvar_RegisterVariable (&scr_ofsy, NULL); - Cvar_RegisterVariable (&scr_ofsz, NULL); - Cvar_RegisterVariable (&cl_rollspeed, NULL); - Cvar_RegisterVariable (&cl_rollangle, NULL); - Cvar_RegisterVariable (&cl_bob, NULL); - Cvar_RegisterVariable (&cl_bobcycle, NULL); - Cvar_RegisterVariable (&cl_bobup, NULL); + Cvar_RegisterVariable (&scr_ofsx); + Cvar_RegisterVariable (&scr_ofsy); + Cvar_RegisterVariable (&scr_ofsz); + Cvar_RegisterVariable (&cl_rollspeed); + Cvar_RegisterVariable (&cl_rollangle); + Cvar_RegisterVariable (&cl_bob); + Cvar_RegisterVariable (&cl_bobcycle); + Cvar_RegisterVariable (&cl_bobup); - Cvar_RegisterVariable (&v_kicktime, NULL); - Cvar_RegisterVariable (&v_kickroll, NULL); - Cvar_RegisterVariable (&v_kickpitch, NULL); - Cvar_RegisterVariable (&v_gunkick, NULL); //johnfitz + Cvar_RegisterVariable (&v_kicktime); + Cvar_RegisterVariable (&v_kickroll); + Cvar_RegisterVariable (&v_kickpitch); + Cvar_RegisterVariable (&v_gunkick); //johnfitz }