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! |
|
|