- Add unset command for cvars created by the user

- Fix crash bug when maximum number of cvars has been reached
- Fix cvar_restart
- Add possibility to cleanly switch mods ingame (#2819)
This commit is contained in:
Thilo Schulz 2009-11-09 22:41:42 +00:00
parent 606ce66726
commit 258429efe7
8 changed files with 414 additions and 143 deletions

View file

@ -787,30 +787,33 @@ default values.
==========================================================
*/
#define CVAR_ARCHIVE 1 // set to cause it to be saved to vars.rc
// used for system variables, not for player
// specific configurations
#define CVAR_USERINFO 2 // sent to server on connect or change
#define CVAR_SERVERINFO 4 // sent in response to front end requests
#define CVAR_SYSTEMINFO 8 // these cvars will be duplicated on all clients
#define CVAR_INIT 16 // don't allow change from console at all,
// but can be set from the command line
#define CVAR_LATCH 32 // will only change when C code next does
// a Cvar_Get(), so it can't be changed
// without proper initialization. modified
// will be set, even though the value hasn't
// changed yet
#define CVAR_ROM 64 // display only, cannot be set by user at all
#define CVAR_USER_CREATED 128 // created by a set command
#define CVAR_TEMP 256 // can be set even when cheats are disabled, but is not archived
#define CVAR_CHEAT 512 // can not be changed if cheats are disabled
#define CVAR_NORESTART 1024 // do not clear when a cvar_restart is issued
#define CVAR_ARCHIVE 0x0001 // set to cause it to be saved to vars.rc
// used for system variables, not for player
// specific configurations
#define CVAR_USERINFO 0x0002 // sent to server on connect or change
#define CVAR_SERVERINFO 0x0004 // sent in response to front end requests
#define CVAR_SYSTEMINFO 0x0008 // these cvars will be duplicated on all clients
#define CVAR_INIT 0x0010 // don't allow change from console at all,
// but can be set from the command line
#define CVAR_LATCH 0x0020 // will only change when C code next does
// a Cvar_Get(), so it can't be changed
// without proper initialization. modified
// will be set, even though the value hasn't
// changed yet
#define CVAR_ROM 0x0040 // display only, cannot be set by user at all
#define CVAR_USER_CREATED 0x0080 // created by a set command
#define CVAR_TEMP 0x0100 // can be set even when cheats are disabled, but is not archived
#define CVAR_CHEAT 0x0200 // can not be changed if cheats are disabled
#define CVAR_NORESTART 0x0400 // do not clear when a cvar_restart is issued
#define CVAR_SERVER_CREATED 2048 // cvar was created by a server the client connected to.
#define CVAR_SERVER_CREATED 0x0800 // cvar was created by a server the client connected to.
#define CVAR_VM_CREATED 0x1000 // cvar was created exclusively in one of the VMs.
#define CVAR_NONEXISTENT 0xFFFFFFFF // Cvar doesn't exist.
// nothing outside the Cvar_*() functions should modify these fields!
typedef struct cvar_s {
typedef struct cvar_s cvar_t;
struct cvar_s {
char *name;
char *string;
char *resetString; // cvar_restart will reset to this value
@ -824,9 +827,13 @@ typedef struct cvar_s {
qboolean integral;
float min;
float max;
struct cvar_s *next;
struct cvar_s *hashNext;
} cvar_t;
cvar_t *next;
cvar_t *prev;
cvar_t *hashNext;
cvar_t *hashPrev;
int hashIndex;
};
#define MAX_CVAR_VALUE_STRING 256