Announcement

Collapse
No announcement yet.

Crappy in-game server browser output code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Crappy in-game server browser output code

    Ok this is just a straight shot at reading from servers.quakeone.com
    Code:
    //R00k: This is a crude FIRST attempt at a realtime server list.
    #define SERVERLIST_URL "http://servers.quakeone.com/"
    #define SERVERLIST_FILE "index.php?format=proquake"
    
    void Cmd_Servers_f (void)
    {
    	char url[1024];
    	qboolean success;
    	FILE *f;
    	extern int Web_Get( const char *url, const char *referer, const char *name, int resume, int max_downloading_time, int timeout, int ( *_progress )(double) );
    	extern char *Con_Quakebar (int len);
    	char buf[256] = {0};
    	char name[32] = {0};
    	
    	Q_snprintfz( url, sizeof( url ), "%s%s", SERVERLIST_URL, SERVERLIST_FILE );
    	success = Web_Get( url, NULL, va("%s/servers.txt", com_gamedir), false, 2, 2, NULL );
    
    	if( !success )
    		return;
    
    	Q_strncpyz (buf, va("%s/servers.txt", com_gamedir), sizeof(buf));
    
    	if (!(f = fopen(buf, "rt")))
    	{
    		Con_Printf ("ERROR: couldn't open servers.txt\n");
    		return;
    	}
    
    	Con_Printf ("reading : servers.quakeone.com\n");
    	
    	Con_Printf ("����������������������������������������\n");
    	
    	while (fgets(buf, 72, f))
    	{
    		if (strstr(Cmd_Argv(1),"all"))
    		{
    		}
    		else
    		{
    			if (strstr(buf,"00/"))
    			{
    				memset (buf, 0, sizeof(buf));
    				continue;
    			}
    		}
    
    		AddTabs (buf);
    		Con_Printf ("%s", buf);
    		memset (buf, 0, sizeof(buf));
    	}
    
    	Con_Printf ("\n����������������������������������������\n");
    	Con_Printf ("\n");
    	fclose (f);
    }
    thats it.
    www.quakeone.com/qrack | www.quakeone.com/cax| http://en.twitch.tv/sputnikutah

  • #2
    Awesome, i'm glad it's being put to good use. I just renewed the hosting for another year too.

    Comment


    • #3
      Can haz more,plz.
      Want to get into playing Quake again? Click here for the Multiplayer-Startup kit! laissez bon temps rouler!

      Comment


      • #4
        Nice 4am code!

        Would it not be better to modify the status command to read server names from a text file?
        Could probably be done with a cfg.scr even easier.

        PS
        I get some kind of error when I try to compile that code, please help.
        Life is Grand!

        Comment


        • #5
          Ya this is straight out of the gut of Qrack, not really a tut for Fitzquake. But with a little effort u can get it to fit. Oh BTW, you need to have LIBCurl added to the project
          www.quakeone.com/qrack | www.quakeone.com/cax| http://en.twitch.tv/sputnikutah

          Comment

          Working...
          X