Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

[Tutorial PSP] - Proper PSP Server Browser

| Inside3d Forums Forum Index -> Programming Tutorials

View previous topic :: View next topic
Author | Message
--- | ---
Team Xlink Joined: 25 Jun 2009 Posts: 320 |

Posted: Thu Apr 01, 2010 11:37 pm Post subject: [Tutorial PSP] - Proper PSP Server Browser |

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:
static void _Datagram_SearchForHosts (qboolean xmit)

In that function after this:

Code:
struct qsockaddr myaddr;

Add this:

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

Step 2.
Scroll down to this:

Code:
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:
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.
_________________

Anonymous wrote:
if it works, it works. if it doesn't, HAHAHA!

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> Programming Tutorials | All times are GMT
Page 1 of 1

Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2004 phpBB Group