]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
-Added 2 builtins to make the hostcache stuff easier extensible.
authorblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 1 Jan 2005 19:00:33 +0000 (19:00 +0000)
committerblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 1 Jan 2005 19:00:33 +0000 (19:00 +0000)
 More to follow soon.
-Cmd now has a shutdown function so it doesnt leak anything (hopefully).

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

cmd.c
cmd.h
host.c
prvm_cmds.c

diff --git a/cmd.c b/cmd.c
index fe455296ef4fc3278ac270e7308ebcd0c1ae95f7..f8c3f1fcf633fd42eab313aa570b777d106d87c7 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -459,6 +459,16 @@ void Cmd_Init (void)
        Cmd_AddCommand ("seta", Cvar_SetA_f);
 }
 
+/*
+============
+Cmd_Shutdown
+============
+*/
+void Cmd_Shutdown(void)
+{
+       Mem_FreePool(&cmd_mempool);
+}
+
 /*
 ============
 Cmd_Argc
diff --git a/cmd.h b/cmd.h
index 35ce36f26b8582b8f350e00f330febec5f1b1add..c05f7062fbaf2566c0116b64488ce7173c277338 100644 (file)
--- a/cmd.h
+++ b/cmd.h
@@ -80,6 +80,7 @@ typedef enum
 extern cmd_source_t cmd_source;
 
 void Cmd_Init (void);
+void Cmd_Shutdown (void);
 
 void Cmd_AddCommand (const char *cmd_name, xcommand_t function);
 // called by the init functions of other parts of the program to
diff --git a/host.c b/host.c
index 0b73b6539cb66325e4cf14ac3a4a214a5981858e..a1a9d129ac587f20359b4bd23692fe9adeb16cf2 100644 (file)
--- a/host.c
+++ b/host.c
@@ -1022,6 +1022,7 @@ void Host_Shutdown(void)
                VID_Shutdown();
        }
 
+       Cmd_Shutdown();
        Sys_Shutdown();
        Log_Close ();
 }
index ba52d1213aae636ac8af8128e8fccdfeeac3dc40..4bf7209baf33608520d2fe9e019921914a62f968 100644 (file)
@@ -166,6 +166,8 @@ float       stringtokeynum(string key)
                sethostcachesort(float field, float descending)
                refreshhostcache()
 float  gethostcachenumber(float fld, float hostnr)
+float  gethostcacheindexforkey(string key)
+               addwantedhostcachekey(string key)
 */
 
 #include "quakedef.h"
@@ -3806,9 +3808,59 @@ refreshhostcache()
 */
 void VM_M_refreshhostcache( void )
 {
+       VM_SAFEPARMCOUNT( 0, VM_M_refreshhostcache );
        HostCache_QueryList();
 }
 
+/*
+========================
+VM_M_gethostcacheindexforkey
+
+float gethostcacheindexforkey(string key)
+========================
+*/
+void VM_M_gethostcacheindexforkey( void )
+{
+       char *key;
+       VM_SAFEPARMCOUNT( 1, VM_M_gethostcacheindexforkey );
+
+       key = PRVM_G_STRING( OFS_PARM0 );
+       VM_CheckEmptyString( key );
+       
+       if( !strcmp( key, "cname" ) )
+               PRVM_G_FLOAT( OFS_RETURN ) = HCIF_CNAME;
+       else if( !strcmp( key, "ping" ) )
+               PRVM_G_FLOAT( OFS_RETURN ) = HCIF_PING;
+       else if( !strcmp( key, "game" ) )
+               PRVM_G_FLOAT( OFS_RETURN ) = HCIF_GAME;
+       else if( !strcmp( key, "mod" ) )
+               PRVM_G_FLOAT( OFS_RETURN ) = HCIF_MOD;
+       else if( !strcmp( key, "map" ) )
+               PRVM_G_FLOAT( OFS_RETURN ) = HCIF_MAP;
+       else if( !strcmp( key, "name" ) )
+               PRVM_G_FLOAT( OFS_RETURN ) = HCIF_NAME;
+       else if( !strcmp( key, "maxplayers" ) )
+               PRVM_G_FLOAT( OFS_RETURN ) = HCIF_MAXPLAYERS;
+       else if( !strcmp( key, "numplayers" ) )
+               PRVM_G_FLOAT( OFS_RETURN ) = HCIF_NUMPLAYERS;
+       else if( !strcmp( key, "protocol" ) )
+               PRVM_G_FLOAT( OFS_RETURN ) = HCIF_PROTOCOL;
+       else
+               PRVM_G_FLOAT( OFS_RETURN ) = -1;
+}
+
+/*
+========================
+VM_M_addwantedhostcachekey
+
+addwantedhostcachekey(string key)
+========================
+*/
+void VM_M_addwantedhostcachekey( void )
+{
+       VM_SAFEPARMCOUNT( 1, VM_M_addwantedhostcachekey );
+}
+
 prvm_builtin_t vm_m_builtins[] = {
        0, // to be consistent with the old vm
        // common builtings (mostly)
@@ -3959,7 +4011,9 @@ prvm_builtin_t vm_m_builtins[] = {
        VM_M_resorthostcache,
        VM_M_sethostcachesort,
        VM_M_refreshhostcache,
-       VM_M_gethostcachenumber // 621
+       VM_M_gethostcachenumber,
+       VM_M_gethostcacheindexforkey, 
+       VM_M_addwantedhostcachekey // 623
 };
 
 const int vm_m_numbuiltins = sizeof(vm_m_builtins) / sizeof(prvm_builtin_t);