From: black Date: Thu, 30 Oct 2003 12:49:30 +0000 (+0000) Subject: Added 2(3) builtin functions. X-Git-Tag: xonotic-v0.1.0preview~6288 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=87ef3b67c3ef8508096574170b91271cb17cfdc5;p=xonotic%2Fdarkplaces.git Added 2(3) builtin functions. 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 --- diff --git a/prvm_cmds.c b/prvm_cmds.c index a9ce8ac9..cc3e46bd 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -86,6 +86,8 @@ float gettime() loadfromdata(string data) loadfromfile(string file) float mod(float val, float m) +const string str_cvar (string) + crash() perhaps only : Menu : WriteMsg =============================== @@ -660,6 +662,35 @@ void VM_cvar (void) 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 @@ -1081,6 +1112,21 @@ void VM_coredump (void) 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 @@ -2077,6 +2123,32 @@ void VM_clientstate(void) 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 @@ -2788,7 +2860,9 @@ prvm_builtin_t vm_m_builtins[] = { 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 diff --git a/vid_shared.c b/vid_shared.c index b77fe6b1..55c7562b 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -560,8 +560,8 @@ void IN_Mouse(usercmd_t *cmd, float mx, float 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