]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_cmds.c
disable joystick by default, and make joy_enable saved;
[xonotic/darkplaces.git] / prvm_cmds.c
index a5c944c732d0ba88d9f34a8d9c9986258eff8a01..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
@@ -1596,6 +1639,9 @@ void VM_fgets(void)
 
        VM_SAFEPARMCOUNT(1,VM_fgets);
 
+       // set the return value regardless of any possible errors
+       PRVM_G_INT(OFS_RETURN) = OFS_NULL;
+
        filenum = (int)PRVM_G_FLOAT(OFS_PARM0);
        if (filenum < 0 || filenum >= PRVM_MAX_OPENFILES)
        {
@@ -1628,8 +1674,6 @@ void VM_fgets(void)
                Con_Printf("fgets: %s: %s\n", PRVM_NAME, string);
        if (c >= 0 || end)
                PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(string);
-       else
-               PRVM_G_INT(OFS_RETURN) = OFS_NULL;
 }
 
 /*
@@ -2197,7 +2241,22 @@ void VM_clientstate(void)
 {
        VM_SAFEPARMCOUNT(0,VM_clientstate);
 
-       PRVM_G_FLOAT(OFS_RETURN) = cls.state;
+
+       switch( cls.state ) {
+               case ca_uninitialized:
+               case ca_dedicated:
+                       PRVM_G_FLOAT(OFS_RETURN) = 0;
+                       break;
+               case ca_disconnected:
+                       PRVM_G_FLOAT(OFS_RETURN) = 1;
+                       break;
+               case ca_connected:
+                       PRVM_G_FLOAT(OFS_RETURN) = 2;
+                       break;
+               default:
+                       // should never be reached!
+                       break;
+       }
 }
 
 /*
@@ -2554,7 +2613,7 @@ void VM_precache_pic(void)
        VM_CheckEmptyString (s);
 
        // AK Draw_CachePic is supposed to always return a valid pointer
-       if( Draw_CachePic(s, false)->tex == r_texture_notexture )
+       if( Draw_CachePic_Flags(s, CACHEPICFLAG_NOTPERSISTENT)->tex == r_texture_notexture )
                PRVM_G_INT(OFS_RETURN) = OFS_NULL;
 }
 
@@ -2778,7 +2837,7 @@ void VM_drawpic(void)
        if(pos[2] || size[2])
                Con_Printf("VM_drawpic: z value%s from %s discarded\n",(pos[2] && size[2]) ? "s" : " ",((pos[2] && size[2]) ? "pos and size" : (pos[2] ? "pos" : "size")));
 
-       DrawQ_Pic(pos[0], pos[1], Draw_CachePic(picname, true), size[0], size[1], rgb[0], rgb[1], rgb[2], PRVM_G_FLOAT(OFS_PARM4), flag);
+       DrawQ_Pic(pos[0], pos[1], Draw_CachePic (picname), size[0], size[1], rgb[0], rgb[1], rgb[2], PRVM_G_FLOAT(OFS_PARM4), flag);
        PRVM_G_FLOAT(OFS_RETURN) = 1;
 }
 /*
@@ -2826,7 +2885,7 @@ void VM_drawsubpic(void)
        if(pos[2] || size[2])
                Con_Printf("VM_drawsubpic: z value%s from %s discarded\n",(pos[2] && size[2]) ? "s" : " ",((pos[2] && size[2]) ? "pos and size" : (pos[2] ? "pos" : "size")));
 
-       DrawQ_SuperPic(pos[0], pos[1], Draw_CachePic(picname, true),
+       DrawQ_SuperPic(pos[0], pos[1], Draw_CachePic (picname),
                size[0], size[1],
                srcPos[0],              srcPos[1],              rgb[0], rgb[1], rgb[2], alpha,
                srcPos[0] + srcSize[0], srcPos[1],              rgb[0], rgb[1], rgb[2], alpha,
@@ -2921,7 +2980,7 @@ void VM_getimagesize(void)
        p = PRVM_G_STRING(OFS_PARM0);
        VM_CheckEmptyString (p);
 
-       pic = Draw_CachePic (p, false);
+       pic = Draw_CachePic_Flags (p, CACHEPICFLAG_NOTPERSISTENT);
 
        PRVM_G_VECTOR(OFS_RETURN)[0] = pic->width;
        PRVM_G_VECTOR(OFS_RETURN)[1] = pic->height;
@@ -3128,7 +3187,7 @@ void VM_gecko_create( void ) {
                        return;
        }
 
-       instance = prog->opengeckoinstances[ i ] = CL_Gecko_CreateBrowser( name );
+       instance = prog->opengeckoinstances[ i ] = CL_Gecko_CreateBrowser( name, PRVM_GetProgNr() );
    if( !instance ) {
                // TODO: error handling [12/3/2007 Black]
                PRVM_G_FLOAT( OFS_RETURN ) = 0;