mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 15:01:41 +00:00
alpha code for master server queries
This commit is contained in:
parent
1843bb5839
commit
2ece48c535
4 changed files with 67 additions and 5 deletions
|
@ -63,5 +63,8 @@ char *gettokstart(char *str, int req, char delim);
|
|||
int gettoklen(char *str, int req, char delim);
|
||||
|
||||
void timepassed (double time1, double *time2);
|
||||
|
||||
void MSL_ParseServerList(char *msl_data);
|
||||
|
||||
void SList_Init (void);
|
||||
#endif // _CL_SLIST_H
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#define A2C_CLIENT_COMMAND 'B' // + command line
|
||||
#define S2M_SHUTDOWN 'C'
|
||||
|
||||
#define M2C_MASTER_REPLY 'd' // + \n + qw server port list
|
||||
|
||||
//==================
|
||||
// note that there are some defs.qc that mirror to these numbers
|
||||
|
|
|
@ -855,12 +855,13 @@ void
|
|||
CL_ConnectionlessPacket (void)
|
||||
{
|
||||
char *s;
|
||||
int c;
|
||||
int c, clcp_temp;
|
||||
|
||||
MSG_BeginReading (net_message);
|
||||
MSG_ReadLong (net_message); // skip the -1
|
||||
|
||||
c = MSG_ReadByte (net_message);
|
||||
clcp_temp = 0;
|
||||
if (!cls.demoplayback)
|
||||
Con_Printf ("%s: ", NET_AdrToString (net_from));
|
||||
// Con_DPrintf ("%s", net_message.data + 5);
|
||||
|
@ -986,6 +987,14 @@ CL_ConnectionlessPacket (void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (c == M2C_MASTER_REPLY)
|
||||
{
|
||||
Con_Printf("Master Server Reply\n");
|
||||
clcp_temp = MSG_ReadByte (net_message);
|
||||
s = MSG_ReadString (net_message);
|
||||
MSL_ParseServerList(s);
|
||||
return;
|
||||
}
|
||||
if (c == svc_disconnect) {
|
||||
if (cls.demoplayback)
|
||||
Host_EndGame ("End of demo");
|
||||
|
|
|
@ -61,6 +61,8 @@
|
|||
#include "QF/va.h"
|
||||
|
||||
server_entry_t *slist;
|
||||
server_entry_t *all_slist;
|
||||
|
||||
int slist_last_details;
|
||||
|
||||
server_entry_t *
|
||||
|
@ -76,9 +78,9 @@ SL_Add (server_entry_t *start, char *ip, char *desc)
|
|||
start->prev = 0;
|
||||
start->next = 0;
|
||||
start->server = malloc (strlen (ip) + 1);
|
||||
start->desc = malloc (strlen (desc) + 1);
|
||||
start->desc = malloc (strlen (desc ? desc : ip) + 1);
|
||||
strcpy (start->server, ip);
|
||||
strcpy (start->desc, desc);
|
||||
strcpy (start->desc, desc ? desc : ip);
|
||||
return (start);
|
||||
}
|
||||
|
||||
|
@ -88,10 +90,10 @@ SL_Add (server_entry_t *start, char *ip, char *desc)
|
|||
|
||||
p->next->prev = p;
|
||||
p->next->server = malloc (strlen (ip) + 1);
|
||||
p->next->desc = malloc (strlen (desc) + 1);
|
||||
p->next->desc = malloc (strlen (desc ? desc : ip) + 1);
|
||||
|
||||
strcpy (p->next->server, ip);
|
||||
strcpy (p->next->desc, desc);
|
||||
strcpy (p->next->desc, desc ? desc : ip);
|
||||
|
||||
return (start);
|
||||
}
|
||||
|
@ -405,6 +407,30 @@ SL_Con_Details (server_entry_t *sldata, int slitemno)
|
|||
Con_Printf("No Details Available\n");
|
||||
}
|
||||
|
||||
void
|
||||
SL_MasterUpdate(void)
|
||||
{
|
||||
netadr_t addy;
|
||||
char data[] = "c\n";
|
||||
NET_StringToAdr ("qwmaster.ocrana.de:27000", &addy);
|
||||
NET_SendPacket (3, data, addy);
|
||||
NET_StringToAdr ("qwmaster.barrysworld.com:27000", &addy);
|
||||
NET_SendPacket (3, data, addy);
|
||||
NET_StringToAdr ("203.55.240.100:27000", &addy);
|
||||
NET_SendPacket (3, data, addy);
|
||||
NET_StringToAdr ("192.246.40.37:27000", &addy);
|
||||
NET_SendPacket (3, data, addy);
|
||||
NET_StringToAdr ("192.246.40.37:27002", &addy);
|
||||
NET_SendPacket (3, data, addy);
|
||||
NET_StringToAdr ("192.246.40.37:27003", &addy);
|
||||
NET_SendPacket (3, data, addy);
|
||||
NET_StringToAdr ("192.246.40.37:27004", &addy);
|
||||
NET_SendPacket (3, data, addy);
|
||||
NET_StringToAdr ("192.246.40.37:27006", &addy);
|
||||
NET_SendPacket (3, data, addy);
|
||||
NET_StringToAdr ("203.9.148.7:27000", &addy);
|
||||
}
|
||||
|
||||
void
|
||||
SL_Command (void)
|
||||
{
|
||||
|
@ -419,6 +445,14 @@ SL_Command (void)
|
|||
else
|
||||
Con_Printf("Syntax: slist update\n");
|
||||
}
|
||||
else if (strcasecmp(Cmd_Argv(1),"masterupdate") == 0)
|
||||
{
|
||||
SL_MasterUpdate();
|
||||
}
|
||||
else if (strcasecmp(Cmd_Argv(1),"masterlist") == 0)
|
||||
{
|
||||
SL_Con_List(all_slist);
|
||||
}
|
||||
else if (strcasecmp(Cmd_Argv(1),"connect") == 0)
|
||||
{
|
||||
if (Cmd_Argc () == 3)
|
||||
|
@ -441,6 +475,20 @@ SL_Command (void)
|
|||
SL_Con_Details(slist,sltemp);
|
||||
}
|
||||
}
|
||||
void
|
||||
MSL_ParseServerList(char *msl_data)
|
||||
{
|
||||
int msl_ptr;
|
||||
for (msl_ptr = 0; msl_ptr < strlen(msl_data); msl_ptr = msl_ptr + 6)
|
||||
{
|
||||
all_slist = SL_Add(all_slist, va("%i.%i.%i.%i:%i",
|
||||
(byte)msl_data[msl_ptr],
|
||||
(byte)msl_data[msl_ptr+1],
|
||||
(byte)msl_data[msl_ptr+2],
|
||||
(byte)msl_data[msl_ptr+3],
|
||||
((byte)msl_data[msl_ptr+4]<<8)|(byte)msl_data[msl_ptr+5]), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void SList_Init (void)
|
||||
{
|
||||
|
@ -457,6 +505,7 @@ void SList_Init (void)
|
|||
slist = SL_LoadF (servlist, slist);
|
||||
Qclose (servlist);
|
||||
}
|
||||
all_slist = NULL;
|
||||
}
|
||||
Cmd_AddCommand("slist",SL_Command,"console commands to access server list\n");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue