Attempt to stabilize ODE. Now using constant step (sys_ticrate set steptime) - on...
[divverent/darkplaces.git] / mvm_cmds.c
index 9ac5b87..4f7e301 100644 (file)
@@ -9,9 +9,11 @@
 //============================================================================
 // Menu
 
-char *vm_m_extensions =
+const char *vm_m_extensions =
 "BX_WAL_SUPPORT "
 "DP_CINEMATIC_DPV "
+"DP_CSQC_BINDMAPS "
+"DP_CRYPTO "
 "DP_GFX_FONTS "
 "DP_GFX_FONTS_FREETYPE "
 "DP_UTF8 "
@@ -39,6 +41,7 @@ char *vm_m_extensions =
 "DP_QC_UNLIMITEDTEMPSTRINGS "
 "DP_QC_URI_ESCAPE "
 "DP_QC_URI_GET "
+"DP_QC_URI_POST "
 "DP_QC_WHICHPACK "
 "FTE_STRINGS "
 ;
@@ -749,6 +752,99 @@ static void VM_M_getmousepos(void)
                VectorSet(PRVM_G_VECTOR(OFS_RETURN), in_mouse_x * vid_conwidth.integer / vid.width, in_mouse_y * vid_conheight.integer / vid.height, 0);
 }
 
+void VM_M_crypto_getkeyfp(void)
+{
+       lhnetaddress_t addr;
+       const char *s;
+       char keyfp[FP64_SIZE + 1];
+
+       VM_SAFEPARMCOUNT(1,VM_M_crypto_getkeyfp);
+
+       s = PRVM_G_STRING( OFS_PARM0 );
+       VM_CheckEmptyString( s );
+
+       if(LHNETADDRESS_FromString(&addr, s, 26000) && Crypto_RetrieveHostKey(&addr, NULL, keyfp, sizeof(keyfp), NULL, 0, NULL))
+               PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString( keyfp );
+       else
+               PRVM_G_INT( OFS_RETURN ) = OFS_NULL;
+}
+void VM_M_crypto_getidfp(void)
+{
+       lhnetaddress_t addr;
+       const char *s;
+       char idfp[FP64_SIZE + 1];
+
+       VM_SAFEPARMCOUNT(1,VM_M_crypto_getidfp);
+
+       s = PRVM_G_STRING( OFS_PARM0 );
+       VM_CheckEmptyString( s );
+
+       if(LHNETADDRESS_FromString(&addr, s, 26000) && Crypto_RetrieveHostKey(&addr, NULL, NULL, 0, idfp, sizeof(idfp), NULL))
+               PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString( idfp );
+       else
+               PRVM_G_INT( OFS_RETURN ) = OFS_NULL;
+}
+void VM_M_crypto_getencryptlevel(void)
+{
+       lhnetaddress_t addr;
+       const char *s;
+       int aeslevel;
+
+       VM_SAFEPARMCOUNT(1,VM_M_crypto_getencryptlevel);
+
+       s = PRVM_G_STRING( OFS_PARM0 );
+       VM_CheckEmptyString( s );
+
+       if(LHNETADDRESS_FromString(&addr, s, 26000) && Crypto_RetrieveHostKey(&addr, NULL, NULL, 0, NULL, 0, &aeslevel))
+               PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString(aeslevel ? va("%d AES128", aeslevel) : "0");
+       else
+               PRVM_G_INT( OFS_RETURN ) = OFS_NULL;
+}
+void VM_M_crypto_getmykeyfp(void)
+{
+       int i;
+       char keyfp[FP64_SIZE + 1];
+
+       VM_SAFEPARMCOUNT(1,VM_M_crypto_getmykey);
+
+       i = PRVM_G_FLOAT( OFS_PARM0 );
+       switch(Crypto_RetrieveLocalKey(i, keyfp, sizeof(keyfp), NULL, 0))
+       {
+               case -1:
+                       PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString("");
+                       break;
+               case 0:
+                       PRVM_G_INT( OFS_RETURN ) = OFS_NULL;
+                       break;
+               default:
+               case 1:
+                       PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString(keyfp);
+                       break;
+       }
+}
+void VM_M_crypto_getmyidfp(void)
+{
+       int i;
+       char idfp[FP64_SIZE + 1];
+
+       VM_SAFEPARMCOUNT(1,VM_M_crypto_getmykey);
+
+       i = PRVM_G_FLOAT( OFS_PARM0 );
+       switch(Crypto_RetrieveLocalKey(i, NULL, 0, idfp, sizeof(idfp)))
+       {
+               case -1:
+                       PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString("");
+                       break;
+               case 0:
+                       PRVM_G_INT( OFS_RETURN ) = OFS_NULL;
+                       break;
+               default:
+               case 1:
+                       PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString(idfp);
+                       break;
+       }
+}
+
 prvm_builtin_t vm_m_builtins[] = {
 NULL,                                                                  //   #0 NULL function (not callable)
 VM_checkextension,                             //   #1
@@ -1117,9 +1213,9 @@ NULL,                                                                     // #336
 NULL,                                                                  // #337
 NULL,                                                                  // #338
 NULL,                                                                  // #339
-NULL,                                                                  // #340
-NULL,                                                                  // #341
-NULL,                                                                  // #342
+VM_keynumtostring,                             // #340 string keynumtostring(float keynum)
+VM_stringtokeynum,                             // #341 float stringtokeynum(string key)
+VM_getkeybind,                                                 // #342 string(float keynum[, float bindmap]) getkeybind (EXT_CSQC)
 NULL,                                                                  // #343
 NULL,                                                                  // #344
 NULL,                                                                  // #345
@@ -1290,7 +1386,7 @@ NULL,                                                                     // #509
 VM_uri_escape,                                 // #510 string(string in) uri_escape = #510;
 VM_uri_unescape,                               // #511 string(string in) uri_unescape = #511;
 VM_etof,                                       // #512 float(entity ent) num_for_edict = #512 (DP_QC_NUM_FOR_EDICT)
-VM_uri_get,                                            // #513 float(string uril, float id) uri_get = #513; (DP_QC_URI_GET)
+VM_uri_get,                                            // #513 float(string uri, float id, [string post_contenttype, string post_delim, [float buf]]) uri_get = #513; (DP_QC_URI_GET, DP_QC_URI_POST)
 VM_tokenize_console,                                   // #514 float(string str) tokenize_console = #514; (DP_QC_TOKENIZE_CONSOLE)
 VM_argv_start_index,                                   // #515 float(float idx) argv_start_index = #515; (DP_QC_TOKENIZE_CONSOLE)
 VM_argv_end_index,                                             // #516 float(float idx) argv_end_index = #516; (DP_QC_TOKENIZE_CONSOLE)
@@ -1387,7 +1483,7 @@ VM_writetofile,                                   // #606 void writetofile(float fhandle, entity ent)
 VM_isfunction,                                 // #607 float isfunction(string function_name)
 VM_M_getresolution,                            // #608 vector getresolution(float number, [float forfullscreen])
 VM_keynumtostring,                             // #609 string keynumtostring(float keynum)
-VM_findkeysforcommand,         // #610 string findkeysforcommand(string command)
+VM_findkeysforcommand,         // #610 string findkeysforcommand(string command[, float bindmap])
 VM_M_getserverliststat,                        // #611 float gethostcachevalue(float type)
 VM_M_getserverliststring,              // #612 string gethostcachestring(float type, float hostnr)
 VM_parseentitydata,                            // #613 void parseentitydata(entity ent, string data)
@@ -1405,6 +1501,16 @@ VM_CL_getextresponse,                    // #624 string getextresponse(void)
 VM_netaddress_resolve,          // #625 string netaddress_resolve(string, float)
 VM_M_getgamedirinfo,            // #626 string getgamedirinfo(float n, float prop)
 VM_sprintf,                     // #627 string sprintf(string format, ...)
+NULL, // #628
+NULL, // #629
+VM_setkeybind,                                         // #630 float(float key, string bind[, float bindmap]) setkeybind
+VM_getbindmaps,                                                // #631 vector(void) getbindmap
+VM_setbindmaps,                                                // #632 float(vector bm) setbindmap
+VM_M_crypto_getkeyfp,                                  // #633 string(string addr) crypto_getkeyfp
+VM_M_crypto_getidfp,                                   // #634 string(string addr) crypto_getidfp
+VM_M_crypto_getencryptlevel,                           // #635 string(string addr) crypto_getencryptlevel
+VM_M_crypto_getmykeyfp,                                        // #636 string(float addr) crypto_getmykeyfp
+VM_M_crypto_getmyidfp,                                 // #637 string(float addr) crypto_getmyidfp
 NULL
 };