From a2535521709ba873592188925ed1c9c170eb662c Mon Sep 17 00:00:00 2001 From: divverent Date: Wed, 6 Feb 2008 07:38:46 +0000 Subject: [PATCH] disable joystick by default, and make joy_enable saved; add extension DP_QC_CVAR_TYPE that checks what type a cvar is (like, if the engine created it or the mod, or if it is saved) will write dpextensions.qc block for it later, a start of its description is in mbuiltin.h in Nexuiz git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8076 d7cf8633-e32d-0410-b094-e92efae38249 --- clvm_cmds.c | 2 +- cvar.c | 2 +- mvm_cmds.c | 3 ++- prvm_cmds.c | 43 +++++++++++++++++++++++++++++++++++++++++++ prvm_cmds.h | 2 ++ svvm_cmds.c | 3 ++- vid_sdl.c | 2 +- 7 files changed, 52 insertions(+), 5 deletions(-) diff --git a/clvm_cmds.c b/clvm_cmds.c index 1c6222a3..dabd7e65 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -3347,7 +3347,7 @@ VM_gecko_movemouse, // #491 void gecko_mousemove( string name, float x, float VM_gecko_resize, // #492 void gecko_resize( string name, float w, float h ) VM_gecko_get_texture_extent, // #493 vector gecko_get_texture_extent( string name ) VM_crc16, // #494 float(float caseinsensitive, string s, ...) crc16 = #494 (DP_QC_CRC16) -NULL, // #495 +VM_cvar_type, // #495 float(string name) cvar_type = #495; (DP_QC_CVAR_TYPE) NULL, // #496 NULL, // #497 NULL, // #498 diff --git a/cvar.c b/cvar.c index e51b8d09..7203dee6 100644 --- a/cvar.c +++ b/cvar.c @@ -474,7 +474,7 @@ cvar_t *Cvar_Get (const char *name, const char *value, int flags) memcpy(cvar->defstring, value, alloclen); cvar->value = atof (cvar->string); cvar->integer = (int) cvar->value; - cvar->description = "custom cvar"; + cvar->description = "custom cvar"; // actually checked by VM_cvar_type // link the variable in // alphanumerical order diff --git a/mvm_cmds.c b/mvm_cmds.c index 07cd69e1..80d238c0 100644 --- a/mvm_cmds.c +++ b/mvm_cmds.c @@ -25,6 +25,7 @@ char *vm_m_extensions = "DP_QC_STRINGBUFFERS " "DP_QC_CRC16 " "FTE_STRINGS " +"DP_QC_CVAR_TYPE " ; /* @@ -1281,7 +1282,7 @@ VM_gecko_movemouse, // #491 void gecko_mousemove( string name, float x, float VM_gecko_resize, // #492 void gecko_resize( string name, float w, float h ) VM_gecko_get_texture_extent, // #493 vector gecko_get_texture_extent( string name ) VM_crc16, // #494 float(float caseinsensitive, string s, ...) crc16 = #494 (DP_QC_CRC16) -NULL, // #495 +VM_cvar_type, // #495 float(string name) cvar_type = #495; (DP_QC_CVAR_TYPE) NULL, // #496 NULL, // #497 NULL, // #498 diff --git a/prvm_cmds.c b/prvm_cmds.c index 4f39cd0f..5a86819e 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -428,6 +428,49 @@ void VM_cvar (void) PRVM_G_FLOAT(OFS_RETURN) = Cvar_VariableValue(string); } +/* +================= +VM_cvar + +float cvar_type (string) +float CVAR_TYPEFLAG_EXISTS = 1; +float CVAR_TYPEFLAG_SAVED = 2; +float CVAR_TYPEFLAG_PRIVATE = 4; +float CVAR_TYPEFLAG_ENGINE = 8; +float CVAR_TYPEFLAG_HASDESCRIPTION = 16; +================= +*/ +void VM_cvar_type (void) +{ + char string[VM_STRINGTEMP_LENGTH]; + cvar_t *cvar; + int ret; + + VM_SAFEPARMCOUNTRANGE(1,8,VM_cvar); + VM_VarString(0, string, sizeof(string)); + VM_CheckEmptyString(string); + cvar = Cvar_FindVar(string); + + + if(!cvar) + { + PRVM_G_FLOAT(OFS_RETURN) = 0; + return; // CVAR_TYPE_NONE + } + + ret = 1; // CVAR_EXISTS + if(cvar->flags & CVAR_SAVE) + ret |= 2; // CVAR_TYPE_SAVED + if(cvar->flags & CVAR_PRIVATE) + ret |= 4; // CVAR_TYPE_PRIVATE + if(!(cvar->flags & CVAR_ALLOCATED)) + ret |= 8; // CVAR_TYPE_ENGINE + if(strcmp(cvar->description, "custom cvar")) // has to match Cvar_Get's placeholder string + ret |= 16; // CVAR_TYPE_HASDESCRIPTION + + PRVM_G_FLOAT(OFS_RETURN) = ret; +} + /* ================= VM_cvar_string diff --git a/prvm_cmds.h b/prvm_cmds.h index f09e57b5..fdabb68d 100644 --- a/prvm_cmds.h +++ b/prvm_cmds.h @@ -88,6 +88,7 @@ float gettime() parseentitydata(entity ent, string data) float mod(float val, float m) const string cvar_string (string) +float cvar_type (string) crash() stackdump() @@ -232,6 +233,7 @@ void VM_break (void); void VM_localcmd (void); void VM_cvar (void); void VM_cvar_string(void); +void VM_cvar_type (void); void VM_cvar_defstring (void); void VM_cvar_set (void); void VM_dprint (void); diff --git a/svvm_cmds.c b/svvm_cmds.c index fdd0293b..a11074cb 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -55,6 +55,7 @@ char *vm_sv_extensions = "DP_QC_CHANGEPITCH " "DP_QC_COPYENTITY " "DP_QC_CVAR_DEFSTRING " +"DP_QC_CVAR_TYPE " "DP_QC_CVAR_STRING " "DP_QC_ETOS " "DP_QC_FINDCHAIN " @@ -3342,7 +3343,7 @@ NULL, // #491 NULL, // #492 NULL, // #493 VM_crc16, // #494 float(float caseinsensitive, string s, ...) crc16 = #494 (DP_QC_CRC16) -NULL, // #495 +VM_cvar_type, // #495 float(string name) cvar_type = #495; (DP_QC_CVAR_TYPE) NULL, // #496 NULL, // #497 NULL, // #498 diff --git a/vid_sdl.c b/vid_sdl.c index 8b41854a..0bdfbf55 100644 --- a/vid_sdl.c +++ b/vid_sdl.c @@ -28,7 +28,7 @@ int cl_available = true; qboolean vid_supportrefreshrate = false; cvar_t joy_detected = {CVAR_READONLY, "joy_detected", "0", "number of joysticks detected by engine"}; -cvar_t joy_enable = {0, "joy_enable", "1", "enables joystick support"}; +cvar_t joy_enable = {CVAR_SAVE, "joy_enable", "0", "enables joystick support"}; cvar_t joy_index = {0, "joy_index", "0", "selects which joystick to use if you have multiple"}; cvar_t joy_axisforward = {0, "joy_axisforward", "1", "which joystick axis to query for forward/backward movement"}; cvar_t joy_axisside = {0, "joy_axisside", "0", "which joystick axis to query for right/left movement"}; -- 2.39.2