new menu QC builtin string netaddress_resolve(string ip, float port). Not sure if...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 22 Sep 2008 05:50:55 +0000 (05:50 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 22 Sep 2008 05:50:55 +0000 (05:50 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8509 d7cf8633-e32d-0410-b094-e92efae38249

mvm_cmds.c
prvm_cmds.c
prvm_cmds.h

index 0aa7e78..e0ae2ba 100644 (file)
@@ -1442,7 +1442,8 @@ VM_M_refreshserverlist,                   // #620 void refreshhostcache(void)
 VM_M_getserverlistnumber,              // #621 float gethostcachenumber(float fld, float hostnr)
 VM_M_getserverlistindexforkey,// #622 float gethostcacheindexforkey(string key)
 VM_M_addwantedserverlistkey,   // #623 void addwantedhostcachekey(string key)
-VM_M_getextresponse                            // #624 string getextresponse(void)
+VM_M_getextresponse,                   // #624 string getextresponse(void)
+VM_netaddress_resolve           // #625 string netaddress_resolve(string, float)
 };
 
 const int vm_m_numbuiltins = sizeof(vm_m_builtins) / sizeof(prvm_builtin_t);
index 6d88a9d..812860b 100644 (file)
@@ -4875,6 +4875,7 @@ void VM_whichpack (void)
 {
        const char *fn, *pack;
 
+       VM_SAFEPARMCOUNT(1, VM_whichpack);
        fn = PRVM_G_STRING(OFS_PARM0);
        pack = FS_WhichPack(fn);
 
@@ -4931,6 +4932,8 @@ void VM_uri_get (void)
        if(!prog->funcoffsets.URI_Get_Callback)
                PRVM_ERROR("uri_get called by %s without URI_Get_Callback defined", PRVM_NAME);
 
+       VM_SAFEPARMCOUNT(2, VM_uri_get);
+
        url = PRVM_G_STRING(OFS_PARM0);
        id = PRVM_G_FLOAT(OFS_PARM1);
        handle = Z_Malloc(sizeof(*handle)); // this can't be the prog's mem pool, as curl may call the callback later!
@@ -4949,3 +4952,23 @@ void VM_uri_get (void)
                PRVM_G_INT(OFS_RETURN) = 0;
        }
 }
+
+void VM_netaddress_resolve (void)
+{
+       const char *ip;
+       char normalized[128];
+       int port;
+       lhnetaddress_t addr;
+
+       VM_SAFEPARMCOUNTRANGE(1, 2, VM_netaddress_resolve);
+
+       ip = PRVM_G_STRING(OFS_PARM0);
+       port = 0;
+       if(prog->argc > 1)
+               port = PRVM_G_FLOAT(OFS_PARM1);
+
+       if(LHNETADDRESS_FromString(&addr, ip, port) && LHNETADDRESS_ToString(&addr, normalized, sizeof(normalized), prog->argc > 1))
+               PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(normalized);
+       else
+               PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString("");
+}
index 42cd5d7..79646f7 100644 (file)
@@ -431,3 +431,4 @@ void VM_whichpack (void);
 
 void VM_etof (void);
 void VM_uri_get (void);
+void VM_netaddress_resolve (void);