]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Added 2(3) builtin functions.
authorblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 30 Oct 2003 12:49:30 +0000 (12:49 +0000)
committerblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 30 Oct 2003 12:49:30 +0000 (12:49 +0000)
Changed the 2d mouse code, so that the relative coords are mapped into the console coord system (mouse speed is always the same in the menu qc).

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3615 d7cf8633-e32d-0410-b094-e92efae38249

prvm_cmds.c
vid_shared.c

index a9ce8ac9f6dcf27d9af7c0b87ec8a86f8b5840d9..cc3e46bd882a991e58a0bd10cd26f2af6c894aa7 100644 (file)
@@ -86,6 +86,8 @@ float gettime()
                loadfromdata(string data)
                loadfromfile(string file)
 float  mod(float val, float m)
                loadfromdata(string data)
                loadfromfile(string file)
 float  mod(float val, float m)
+const string   str_cvar (string)
+               crash()
                
 perhaps only : Menu : WriteMsg 
 ===============================
                
 perhaps only : Menu : WriteMsg 
 ===============================
@@ -660,6 +662,35 @@ void VM_cvar (void)
        PRVM_G_FLOAT(OFS_RETURN) = Cvar_VariableValue(PRVM_G_STRING(OFS_PARM0));
 }
 
        PRVM_G_FLOAT(OFS_RETURN) = Cvar_VariableValue(PRVM_G_STRING(OFS_PARM0));
 }
 
+/*
+=================
+VM_str_cvar
+
+const string   str_cvar (string)
+=================
+*/
+void VM_str_cvar(void) 
+{
+       char *out, *name;
+       const char *cvar_string;
+       VM_SAFEPARMCOUNT(1,VM_str_cvar);
+
+       name = PRVM_G_STRING(OFS_PARM0);
+
+       if(!name)
+               PRVM_ERROR("VM_str_cvar: %s: null string\n", PRVM_NAME);
+
+       VM_CheckEmptyString(name);
+
+       out = VM_GetTempString(); 
+
+       cvar_string = Cvar_VariableString(name);
+       
+       strcpy(out, cvar_string);
+
+       PRVM_G_INT(OFS_PARM0) = PRVM_SetString(out);
+}
+
 /*
 =================
 VM_cvar_set
 /*
 =================
 VM_cvar_set
@@ -1081,6 +1112,21 @@ void VM_coredump (void)
        Cbuf_AddText("\n");
 }
 
        Cbuf_AddText("\n");
 }
 
+/*
+=========
+VM_crash
+
+crash()
+=========
+*/
+
+void VM_crash(void) 
+{
+       VM_SAFEPARMCOUNT(0, VM_crash);
+
+       PRVM_ERROR("Crash called by %s\n",PRVM_NAME);
+}
+
 /*
 =========
 VM_traceon
 /*
 =========
 VM_traceon
@@ -2077,6 +2123,32 @@ void VM_clientstate(void)
        PRVM_G_FLOAT(OFS_RETURN) = cls.state;
 }
 
        PRVM_G_FLOAT(OFS_RETURN) = cls.state;
 }
 
+/*
+=========
+VM_getostype
+
+float  getostype(void)
+=========
+*/ // not used at the moment -> not included in the common list
+void VM_getostype(void)
+{
+       VM_SAFEPARMCOUNT(0,VM_getostype);
+
+       /*
+       OS_WINDOWS
+       OS_LINUX
+       OS_MAC - not supported
+       */
+
+#ifdef _WIN32
+       PRVM_G_FLOAT(OFS_RETURN) = 0;
+#elif defined _MAC
+       PRVM_G_FLOAT(OFS_RETURN) = 2;
+#else
+       PRVM_G_FLOAT(OFS_RETURN) = 1;
+#endif
+}
+
 /*
 =========
 VM_getmousepos
 /*
 =========
 VM_getmousepos
@@ -2788,7 +2860,9 @@ prvm_builtin_t vm_m_builtins[] = {
        VM_loadfromdata,
        VM_loadfromfile,
        VM_modulo,              // 70
        VM_loadfromdata,
        VM_loadfromfile,
        VM_modulo,              // 70
-       e10,                    // 80
+       VM_str_cvar,    
+       VM_crash,               // 72
+       0,0,0,0,0,0,0,0,// 80
        e10,                    // 90
        e10,                    // 100
        e100,                   // 200
        e10,                    // 90
        e10,                    // 100
        e100,                   // 200
index b77fe6b1ea2d2cb1f3a12ea964655208df4fd859..55c7562bbb2a6f135d9942b5d44a4b77c1361fa3 100644 (file)
@@ -560,8 +560,8 @@ void IN_Mouse(usercmd_t *cmd, float mx, float my)
        old_mouse_x = mx;
        old_mouse_y = my;
 
        old_mouse_x = mx;
        old_mouse_y = my;
 
-       in_mouse_x = mouse_x;
-       in_mouse_y = mouse_y;
+       in_mouse_x = (float) mouse_x * vid.conwidth / vid.realwidth;
+       in_mouse_y = (float) mouse_y * vid.conheight / vid.realheight;
 
        // AK: eveything else is client stuff 
        // BTW, this should be seperated somewhen
 
        // AK: eveything else is client stuff 
        // BTW, this should be seperated somewhen