]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
-Fixed a wrong parameter type in netconn.
authorblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 22 Dec 2004 23:10:20 +0000 (23:10 +0000)
committerblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 22 Dec 2004 23:10:20 +0000 (23:10 +0000)
-Made hostcache_cachecount public again.
-Added altstr_set to the new VM.
-Started work on the new hostcache interface for the menu qc.

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

netconn.c
netconn.h
prvm_cmds.c

index 09c69084cc0bcf206fb99ae2afb19de3f164678c..3174d045e831611ef0ec69ebef09cbfa8358d72a 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -164,7 +164,7 @@ static qboolean _HostCache_SortTest( hostcache_t *A, hostcache_t *B )
        return result < 0;
 }
 
-static qboolean _hc_testint( int A, hostcache_infofield_t op, int B )
+static qboolean _hc_testint( int A, hostcache_maskop_t op, int B )
 {
        int diff;
 
index 17f57221769cd16adb06b3934ffab9017da0963e..7bb3c53c61c8193c017984a0d2790a24c7e350ac 100755 (executable)
--- a/netconn.h
+++ b/netconn.h
@@ -229,6 +229,8 @@ extern qboolean                                     hostcache_sortdescending;
 extern int                     hostcache_viewcount;
 extern hostcache_t     *hostcache_viewset[HOSTCACHE_VIEWCACHESIZE];
 
+extern int                     hostcache_cachecount; 
+
 extern qboolean                hostcache_consoleoutput;
 
 #if !defined(_WIN32 ) && !defined (__linux__) && !defined (__sun__)
index e79bfce593b7fa4be5f81e651d21d7cd00a7ae8b..5079cdbf57392b3d9a60e41a1a2663c1f1fbed44 100644 (file)
@@ -103,6 +103,7 @@ intt        ftoi(float num)
 float  altstr_count(string)
 string altstr_prepare(string)
 string altstr_get(string,float)
+string altstr_set(string altstr, float num, string set)
                
 perhaps only : Menu : WriteMsg 
 ===============================
@@ -151,7 +152,7 @@ float       isfunction(string function_name)
 vector getresolution(float number)
 string keynumtostring(float keynum)
 string findkeysforcommand(string command)
-float  gethostcachevalue(float type)
+float  gethostcachestat(float type)
 string gethostcachestring(float type, float hostnr)
 
                parseentitydata(entity ent, string data)
@@ -1144,7 +1145,7 @@ void VM_precache_sound (void)
        PRVM_G_INT(OFS_RETURN) = PRVM_G_INT(OFS_PARM0);
        VM_CheckEmptyString (s);
 
-       if(!S_PrecacheSound (s,true, true))
+       if(snd_initialized.integer && !S_PrecacheSound (s,true, true))
                Con_Printf("VM_precache_sound: Failed to load %s for %s\n", s, PRVM_NAME);
 }
 
@@ -3054,6 +3055,57 @@ void VM_altstr_get( void )
        PRVM_G_INT( OFS_RETURN ) = PRVM_SetString( outstr );
 }
 
+/*
+========================
+VM_altstr_set
+
+string altstr_set(string altstr, float num, string set)
+========================
+*/
+void VM_altstr_set( void )
+{
+    int num;
+       char *altstr, *str;
+       char *in;
+       char *outstr, *out;
+
+       VM_SAFEPARMCOUNT( 3, VM_altstr_set );
+
+       altstr = PRVM_G_STRING( OFS_PARM0 );
+       VM_CheckEmptyString( altstr );
+
+       num = PRVM_G_FLOAT( OFS_PARM1 );
+
+       str = PRVM_G_STRING( OFS_PARM2 );
+       VM_CheckEmptyString( str );
+
+       outstr = out = VM_GetTempString();
+       for( num = num * 2 + 1, in = altstr; *in && num; *out++ = *in++ )
+               if( *in == '\\' && !*++in )
+                       break;
+               else if( *in == '\'' )
+                       num--;
+
+       if( !in ) {
+               PRVM_G_INT( OFS_RETURN ) = PRVM_SetString( "" );
+               return;
+       }
+       // copy set in
+       for( ; *str; *out++ = *str++ );
+       // now jump over the old contents
+       for( ; *in; *out++ = *in++ )
+               if( *in == '\'' || *in == '\\' && !*++in )
+                       break;
+       
+       if( !in ) {
+               PRVM_G_INT( OFS_RETURN ) = PRVM_SetString( "" );
+               return;
+       }
+
+       strcpy( out, in );
+       PRVM_G_INT( OFS_RETURN ) = PRVM_SetString( outstr );
+}
+
 void VM_Cmd_Init(void)
 {
        // only init the stuff for the current prog
@@ -3418,49 +3470,61 @@ void VM_M_findkeysforcommand(void)
 
 /*
 =========
-VM_M_gethostcachecount
+VM_M_gethostcachestat
 
-float  gethostcachevalue(float type)
+float  gethostcachestat(float type)
 =========
 */
 /*
        type:
-0      hostcachecount
-1      masterquerycount
-2      masterreplycount
-3      serverquerycount
-4      serverreplycount
+0      hostcache_viewcount
+1   hostcache_totalcount
+2      masterquerycount
+3      masterreplycount
+4      serverquerycount
+5      serverreplycount
 */
-void VM_M_gethostcachevalue( void )
+void VM_M_gethostcachestat( void )
 {
        int type;
-       VM_SAFEPARMCOUNT ( 1, VM_M_gethostcachevalue );
+       VM_SAFEPARMCOUNT ( 1, VM_M_gethostcachestat );
 
        PRVM_G_FLOAT( OFS_RETURN ) = 0;
 
        type = PRVM_G_FLOAT( OFS_PARM0 );
        if( type < 0 || type > 4 )
-               Con_Printf( "VM_M_gethostcachevalue: bad type %i!\n", type );
+               Con_Printf( "VM_M_gethostcachestat: bad type %i!\n", type );
        else switch(type)
        {
        case 0:
                PRVM_G_FLOAT ( OFS_RETURN ) = hostcache_viewcount;
                return;
        case 1:
+               PRVM_G_FLOAT ( OFS_RETURN ) = hostcache_cachecount; 
+       case 2:
                PRVM_G_FLOAT ( OFS_RETURN ) = masterquerycount;
                return;
-       case 2:
+       case 3:
                PRVM_G_FLOAT ( OFS_RETURN ) = masterreplycount;
                return;
-       case 3:
+       case 4:
                PRVM_G_FLOAT ( OFS_RETURN ) = serverquerycount;
                return;
-       case 4:
+       case 5:
                PRVM_G_FLOAT ( OFS_RETURN ) = serverreplycount;
                return;
        }
 }
 
+/*
+========================
+VM_M_sethostcachemask
+
+sethostcachemask( string map, string mod, string name, 
+========================
+*/
+
+
 /*
 =========
 VM_M_gethostcachestring
@@ -3592,8 +3656,9 @@ prvm_builtin_t vm_m_builtins[] = {
        VM_itof,                // isString
        VM_altstr_count,
        VM_altstr_prepare,
-       VM_altstr_get,  // 84
-       0,0,0,0,0,0,    // 90
+       VM_altstr_get,
+       VM_altstr_set,  // 85
+       0,0,0,0,0,      // 90
        e10,                    // 100
        e100,                   // 200
        e100,                   // 300
@@ -3645,7 +3710,7 @@ prvm_builtin_t vm_m_builtins[] = {
        VM_M_getresolution,
        VM_M_keynumtostring,
        VM_M_findkeysforcommand,// 610
-       VM_M_gethostcachevalue,
+       VM_M_gethostcachestat,
        VM_M_gethostcachestring,
        VM_M_parseentitydata    // 613
 };