Forum

[Tutorial PSP] - Proper PSP Server Browser

Post tutorials on how to do certain tasks within game or engine code here.

Moderator: InsideQC Admins

[Tutorial PSP] - Proper PSP Server Browser

Postby Team Xlink » Thu Apr 01, 2010 11:37 pm

Hello.

As you may know I made a server list tutorial, but it wasn't even close to proper and wasn't very good.
This one is better.

Features:

    Server Name
    Number of Players Playing
    Max number of Players
    Map name

Why should you use this instead of the one from my other tutorial?
    Simpler
    All changes are done in net_dgrm.c
    No new files
    No messing with menu code
    More features


Step 1.
Open up net_dgrm.c

Find this:

Code: Select all
static void _Datagram_SearchForHosts (qboolean xmit)


In that function after this:

Code: Select all
   struct qsockaddr myaddr;


Add this:

Code: Select all
   struct qsockaddr writeAddr;
   FILE *netserversHandle=0;
   char string[100];
   char *newline;

Step 2.

Scroll down to this:

Code: Select all
   dfunc.GetSocketAddr (dfunc.controlSock, &myaddr);
   if (xmit)
   {
      SZ_Clear(&net_message);
      // save space for the header, filled in later
      MSG_WriteLong(&net_message, 0);
      MSG_WriteByte(&net_message, CCREQ_SERVER_INFO);
      MSG_WriteString(&net_message, "QUAKE");
      MSG_WriteByte(&net_message, NET_PROTOCOL_VERSION);
      *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
      dfunc.Broadcast(dfunc.controlSock, net_message.data, net_message.cursize);


After that add this:
Code: Select all
      if(tcpipAvailable)
      {
         netserversHandle = fopen(va("%s/netservers.cfg",com_gamedir), "r");
         if(netserversHandle > 0)
         {
            while(fgets (string, 100, netserversHandle) > 0)
            {
               newline = strrchr(string, '\n');
               if(newline)
                  *newline = '\0';

               newline = strrchr(string, '\r');
               if(newline)
                  *newline = '\0';

               dfunc.GetAddrFromName(string, &writeAddr);
               dfunc.Write(dfunc.controlSock,
                        net_message.data,
                        net_message.cursize,
                        &writeAddr);
               sceDisplayWaitVblankStart();
            }
         }
         fclose(netserversHandle);
      }

Now your done!

That was easy now wasn't it?

How do I use it?

Create a file called netservers.cfg

In it put the server address.

Put that file in your Quake/id1 folder

That is it!

Now after reading this and even after looking at the code you may say this still isn't a proper server browser, that is true but to me it is proper enough to be considered proper.
Team Xlink
 
Posts: 368
Joined: Thu Jun 25, 2009 4:45 am
Location: Michigan

Return to Programming Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest