]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
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 1c6222a39f0f678bb51ded123124701e62101fdd..dabd7e65138a95c84bd43c4bedbe768689f3e5a2 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 e51b8d0943d73ec3b865e2bf8c1af36a331a8304..7203dee6a996f6219466e820b3fab393afefdc20 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 07cd69e181e3c4a60af35f1bbd1f52c75cf9c44a..80d238c0720c527c427af2e7c1034bb359d0bb5b 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 4f39cd0ff07274ab0d5ae095a41597d2f69357f7..5a86819ec7f701760ddc83689451d6c11aa8af57 100644 (file)
@@ -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
index f09e57b51b513aa7de7d1e287c5558ac33c55814..fdabb68db5e0e667dfa2e7391a0193df9726784e 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 fdd0293b1c982458c1f401eb5eccf41269b9f5a2..a11074cba6ae9d5bbf6cf83fb517d6e997f00b54 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 8b41854a43983fd85a9cda6c095a0aa20cdb587d..0bdfbf5517237e8bb5b8afeeb88975442880b535 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"};