disable joystick by default, and make joy_enable saved;
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 6 Feb 2008 07:38:46 +0000 (07:38 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 6 Feb 2008 07:38:46 +0000 (07:38 +0000)
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
cvar.c
mvm_cmds.c
prvm_cmds.c
prvm_cmds.h
svvm_cmds.c
vid_sdl.c

index 1c6222a..dabd7e6 100644 (file)
@@ -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 e51b8d0..7203dee 100644 (file)
--- 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
index 07cd69e..80d238c 100644 (file)
@@ -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
index 4f39cd0..5a86819 100644 (file)
@@ -430,6 +430,49 @@ void VM_cvar (void)
 
 /*
 =================
+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
 
 const string   VM_cvar_string (string, ...)
index f09e57b..fdabb68 100644 (file)
@@ -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);
index fdd0293..a11074c 100644 (file)
@@ -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
index 8b41854..0bdfbf5 100644 (file)
--- 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"};