aboutsummaryrefslogtreecommitdiffstats
path: root/code/client
diff options
context:
space:
mode:
Diffstat (limited to 'code/client')
-rw-r--r--code/client/cl_main.c196
-rw-r--r--code/client/cl_ui.c72
-rw-r--r--code/client/client.h12
3 files changed, 106 insertions, 174 deletions
diff --git a/code/client/cl_main.c b/code/client/cl_main.c
index 589907d..c2edd02 100644
--- a/code/client/cl_main.c
+++ b/code/client/cl_main.c
@@ -36,7 +36,6 @@ cvar_t *rconAddress;
cvar_t *cl_timeout;
cvar_t *cl_maxpackets;
cvar_t *cl_packetdup;
-cvar_t *cl_master;
cvar_t *cl_timeNudge;
cvar_t *cl_showTimeDelta;
cvar_t *cl_freezeDemo;
@@ -1817,13 +1816,8 @@ void CL_MotdPacket( netadr_t from ) {
CL_InitServerInfo
===================
*/
-void CL_InitServerInfo( serverInfo_t *server, serverAddress_t *address ) {
- server->adr.type = NA_IP;
- server->adr.ip[0] = address->ip[0];
- server->adr.ip[1] = address->ip[1];
- server->adr.ip[2] = address->ip[2];
- server->adr.ip[3] = address->ip[3];
- server->adr.port = address->port;
+void CL_InitServerInfo( serverInfo_t *server, netadr_t *address ) {
+ server->adr = *address;
server->clients = 0;
server->hostName[0] = '\0';
server->mapName[0] = '\0';
@@ -1844,11 +1838,12 @@ CL_ServersResponsePacket
===================
*/
void CL_ServersResponsePacket( netadr_t from, msg_t *msg ) {
- int i, count, max, total;
- serverAddress_t addresses[MAX_SERVERSPERPACKET];
+ int i, count, total;
+ netadr_t addresses[MAX_SERVERSPERPACKET];
int numservers;
byte* buffptr;
byte* buffend;
+ netadrtype_t family;
Com_Printf("CL_ServersResponsePacket\n");
@@ -1858,71 +1853,74 @@ void CL_ServersResponsePacket( netadr_t from, msg_t *msg ) {
cls.numGlobalServerAddresses = 0;
}
- if (cls.nummplayerservers == -1) {
- cls.nummplayerservers = 0;
- }
-
// parse through server response string
numservers = 0;
buffptr = msg->data;
buffend = buffptr + msg->cursize;
- while (buffptr+1 < buffend) {
+ while (buffptr+1 < buffend)
+ {
// advance to initial token
- do {
- if (*buffptr++ == '\\')
- break;
+ do
+ {
+ if (*buffptr == '\\')
+ {
+ family = NA_IP;
+ break;
+ }
+ else if(*buffptr == '/')
+ {
+ family = NA_IP6;
+ break;
+ }
+
+ buffptr++;
}
while (buffptr < buffend);
- if ( buffptr >= buffend - 6 ) {
- break;
+ buffptr++;
+
+ if(family == NA_IP)
+ {
+ if (buffend - buffptr < sizeof(addresses[numservers].ip) + sizeof(addresses[numservers].port) + sizeof("\\EOT") - 1)
+ break;
+
+ for(i = 0; i < sizeof(addresses[numservers].ip); i++)
+ addresses[numservers].ip[i] = *buffptr++;
+ }
+ else
+ {
+ if (buffend - buffptr < sizeof(addresses[numservers].ip6) + sizeof(addresses[numservers].port) + sizeof("\\EOT") - 1)
+ break;
+
+ for(i = 0; i < sizeof(addresses[numservers].ip6); i++)
+ addresses[numservers].ip6[i] = *buffptr++;
}
- // parse out ip
- addresses[numservers].ip[0] = *buffptr++;
- addresses[numservers].ip[1] = *buffptr++;
- addresses[numservers].ip[2] = *buffptr++;
- addresses[numservers].ip[3] = *buffptr++;
+ addresses[numservers].type = family;
// parse out port
- addresses[numservers].port = (*buffptr++)<<8;
+ addresses[numservers].port = (*buffptr++) << 8;
addresses[numservers].port += *buffptr++;
addresses[numservers].port = BigShort( addresses[numservers].port );
// syntax check
- if (*buffptr != '\\') {
+ if (*buffptr != '\\' && *buffptr != '/')
break;
- }
-
- Com_DPrintf( "server: %d ip: %d.%d.%d.%d:%d\n",numservers,
- addresses[numservers].ip[0],
- addresses[numservers].ip[1],
- addresses[numservers].ip[2],
- addresses[numservers].ip[3],
- addresses[numservers].port );
-
+
numservers++;
- if (numservers >= MAX_SERVERSPERPACKET) {
+ if (numservers >= MAX_SERVERSPERPACKET)
break;
- }
// parse out EOT
- if (buffptr[1] == 'E' && buffptr[2] == 'O' && buffptr[3] == 'T') {
+ if (buffptr[1] == 'E' && buffptr[2] == 'O' && buffptr[3] == 'T')
break;
- }
}
- if (cls.masterNum == 0) {
- count = cls.numglobalservers;
- max = MAX_GLOBAL_SERVERS;
- } else {
- count = cls.nummplayerservers;
- max = MAX_OTHER_SERVERS;
- }
+ count = cls.numglobalservers;
- for (i = 0; i < numservers && count < max; i++) {
+ for (i = 0; i < numservers && count < MAX_GLOBAL_SERVERS; i++) {
// build net address
- serverInfo_t *server = (cls.masterNum == 0) ? &cls.globalServers[count] : &cls.mplayerServers[count];
+ serverInfo_t *server = &cls.globalServers[count];
CL_InitServerInfo( server, &addresses[i] );
// advance to next slot
@@ -1930,29 +1928,18 @@ void CL_ServersResponsePacket( netadr_t from, msg_t *msg ) {
}
// if getting the global list
- if (cls.masterNum == 0) {
- if ( cls.numGlobalServerAddresses < MAX_GLOBAL_SERVERS ) {
- // if we couldn't store the servers in the main list anymore
- for (; i < numservers && count >= max; i++) {
- serverAddress_t *addr;
- // just store the addresses in an additional list
- addr = &cls.globalServerAddresses[cls.numGlobalServerAddresses++];
- addr->ip[0] = addresses[i].ip[0];
- addr->ip[1] = addresses[i].ip[1];
- addr->ip[2] = addresses[i].ip[2];
- addr->ip[3] = addresses[i].ip[3];
- addr->port = addresses[i].port;
- }
+ if ( count >= MAX_GLOBAL_SERVERS && cls.numGlobalServerAddresses < MAX_GLOBAL_SERVERS )
+ {
+ // if we couldn't store the servers in the main list anymore
+ for (; i < numservers && cls.numGlobalServerAddresses < MAX_GLOBAL_SERVERS; i++)
+ {
+ // just store the addresses in an additional list
+ cls.globalServerAddresses[cls.numGlobalServerAddresses++] = addresses[i];
}
}
- if (cls.masterNum == 0) {
- cls.numglobalservers = count;
- total = count + cls.numGlobalServerAddresses;
- } else {
- cls.nummplayerservers = count;
- total = count;
- }
+ cls.numglobalservers = count;
+ total = count + cls.numGlobalServerAddresses;
Com_Printf("%d servers parsed (total %d)\n", numservers, total);
}
@@ -2672,7 +2659,6 @@ void CL_Init( void ) {
cl_timeout = Cvar_Get ("cl_timeout", "200", 0);
- cl_master = Cvar_Get ("cl_master", MASTER_SERVER_NAME, CVAR_ARCHIVE);
cl_timeNudge = Cvar_Get ("cl_timeNudge", "0", CVAR_TEMP );
cl_shownet = Cvar_Get ("cl_shownet", "0", CVAR_TEMP );
cl_showSend = Cvar_Get ("cl_showSend", "0", CVAR_TEMP );
@@ -2898,12 +2884,6 @@ static void CL_SetServerInfoByAddress(netadr_t from, const char *info, int ping)
}
}
- for (i = 0; i < MAX_OTHER_SERVERS; i++) {
- if (NET_CompareAdr(from, cls.mplayerServers[i].adr)) {
- CL_SetServerInfo(&cls.mplayerServers[i], info, ping);
- }
- }
-
for (i = 0; i < MAX_GLOBAL_SERVERS; i++) {
if (NET_CompareAdr(from, cls.globalServers[i].adr)) {
CL_SetServerInfo(&cls.globalServers[i], info, ping);
@@ -3260,43 +3240,49 @@ CL_GlobalServers_f
*/
void CL_GlobalServers_f( void ) {
netadr_t to;
- int i;
- int count;
- char *buffptr;
- char command[1024];
+ int count, i, masterNum;
+ char command[1024], *masteraddress;
- if ( Cmd_Argc() < 3) {
- Com_Printf( "usage: globalservers <master# 0-1> <protocol> [keywords]\n");
+ if ((count = Cmd_Argc()) < 3 || (masterNum = atoi(Cmd_Argv(1))) < 0 || masterNum > 4)
+ {
+ Com_Printf( "usage: globalservers <master# 0-4> <protocol> [keywords]\n");
return;
}
- cls.masterNum = atoi( Cmd_Argv(1) );
-
- Com_Printf( "Requesting servers from the master...\n");
+ sprintf(command, "sv_master%d", masterNum + 1);
+ masteraddress = Cvar_VariableString(command);
+
+ if(!*masteraddress)
+ {
+ Com_Printf( "CL_GlobalServers_f: Error: No master server address given.\n");
+ return;
+ }
// reset the list, waiting for response
// -1 is used to distinguish a "no response"
- NET_StringToAdr( cl_master->string, &to, NA_IP );
-
- if( cls.masterNum == 1 ) {
- cls.nummplayerservers = -1;
- cls.pingUpdateSource = AS_MPLAYER;
- }
- else {
- cls.numglobalservers = -1;
- cls.pingUpdateSource = AS_GLOBAL;
+ i = NET_StringToAdr(masteraddress, &to, NA_UNSPEC);
+
+ if(!i)
+ {
+ Com_Printf( "CL_GlobalServers_f: Error: could not resolve address of master %s\n", masteraddress);
+ return;
}
- to.type = NA_IP;
- to.port = BigShort(PORT_MASTER);
+ else if(i == 2)
+ to.port = BigShort(PORT_MASTER);
+
+ Com_Printf("Requesting servers from master %s...\n", masteraddress);
+
+ cls.numglobalservers = -1;
+ cls.pingUpdateSource = AS_GLOBAL;
- sprintf( command, "getservers %s", Cmd_Argv(2) );
+ Com_sprintf( command, sizeof(command), "getservers %s", Cmd_Argv(2) );
- // tack on keywords
- buffptr = command + strlen( command );
- count = Cmd_Argc();
- for (i=3; i<count; i++)
- buffptr += sprintf( buffptr, " %s", Cmd_Argv(i) );
+ for (i=3; i < count; i++)
+ {
+ Q_strcat(command, sizeof(command), " ");
+ Q_strcat(command, sizeof(command), Cmd_Argv(i));
+ }
NET_OutOfBandPrint( NS_SERVER, to, "%s", command );
}
@@ -3549,10 +3535,6 @@ qboolean CL_UpdateVisiblePings_f(int source) {
server = &cls.localServers[0];
max = cls.numlocalservers;
break;
- case AS_MPLAYER :
- server = &cls.mplayerServers[0];
- max = cls.nummplayerservers;
- break;
case AS_GLOBAL :
server = &cls.globalServers[0];
max = cls.numglobalservers;
@@ -3561,6 +3543,8 @@ qboolean CL_UpdateVisiblePings_f(int source) {
server = &cls.favoriteServers[0];
max = cls.numfavoriteservers;
break;
+ default:
+ return qfalse;
}
for (i = 0; i < max; i++) {
if (server[i].visible) {
diff --git a/code/client/cl_ui.c b/code/client/cl_ui.c
index a4d813a..3cabd04 100644
--- a/code/client/cl_ui.c
+++ b/code/client/cl_ui.c
@@ -50,19 +50,17 @@ LAN_LoadCachedServers
void LAN_LoadCachedServers( void ) {
int size;
fileHandle_t fileIn;
- cls.numglobalservers = cls.nummplayerservers = cls.numfavoriteservers = 0;
+ cls.numglobalservers = cls.numfavoriteservers = 0;
cls.numGlobalServerAddresses = 0;
if (FS_SV_FOpenFileRead("servercache.dat", &fileIn)) {
FS_Read(&cls.numglobalservers, sizeof(int), fileIn);
- FS_Read(&cls.nummplayerservers, sizeof(int), fileIn);
FS_Read(&cls.numfavoriteservers, sizeof(int), fileIn);
FS_Read(&size, sizeof(int), fileIn);
- if (size == sizeof(cls.globalServers) + sizeof(cls.favoriteServers) + sizeof(cls.mplayerServers)) {
+ if (size == sizeof(cls.globalServers) + sizeof(cls.favoriteServers)) {
FS_Read(&cls.globalServers, sizeof(cls.globalServers), fileIn);
- FS_Read(&cls.mplayerServers, sizeof(cls.mplayerServers), fileIn);
FS_Read(&cls.favoriteServers, sizeof(cls.favoriteServers), fileIn);
} else {
- cls.numglobalservers = cls.nummplayerservers = cls.numfavoriteservers = 0;
+ cls.numglobalservers = cls.numfavoriteservers = 0;
cls.numGlobalServerAddresses = 0;
}
FS_FCloseFile(fileIn);
@@ -78,12 +76,10 @@ void LAN_SaveServersToCache( void ) {
int size;
fileHandle_t fileOut = FS_SV_FOpenFileWrite("servercache.dat");
FS_Write(&cls.numglobalservers, sizeof(int), fileOut);
- FS_Write(&cls.nummplayerservers, sizeof(int), fileOut);
FS_Write(&cls.numfavoriteservers, sizeof(int), fileOut);
- size = sizeof(cls.globalServers) + sizeof(cls.favoriteServers) + sizeof(cls.mplayerServers);
+ size = sizeof(cls.globalServers) + sizeof(cls.favoriteServers);
FS_Write(&size, sizeof(int), fileOut);
FS_Write(&cls.globalServers, sizeof(cls.globalServers), fileOut);
- FS_Write(&cls.mplayerServers, sizeof(cls.mplayerServers), fileOut);
FS_Write(&cls.favoriteServers, sizeof(cls.favoriteServers), fileOut);
FS_FCloseFile(fileOut);
}
@@ -104,10 +100,7 @@ static void LAN_ResetPings(int source) {
servers = &cls.localServers[0];
count = MAX_OTHER_SERVERS;
break;
- case AS_MPLAYER :
- servers = &cls.mplayerServers[0];
- count = MAX_OTHER_SERVERS;
- break;
+ case AS_MPLAYER:
case AS_GLOBAL :
servers = &cls.globalServers[0];
count = MAX_GLOBAL_SERVERS;
@@ -141,10 +134,7 @@ static int LAN_AddServer(int source, const char *name, const char *address) {
count = &cls.numlocalservers;
servers = &cls.localServers[0];
break;
- case AS_MPLAYER :
- count = &cls.nummplayerservers;
- servers = &cls.mplayerServers[0];
- break;
+ case AS_MPLAYER:
case AS_GLOBAL :
max = MAX_GLOBAL_SERVERS;
count = &cls.numglobalservers;
@@ -188,10 +178,7 @@ static void LAN_RemoveServer(int source, const char *addr) {
count = &cls.numlocalservers;
servers = &cls.localServers[0];
break;
- case AS_MPLAYER :
- count = &cls.nummplayerservers;
- servers = &cls.mplayerServers[0];
- break;
+ case AS_MPLAYER:
case AS_GLOBAL :
count = &cls.numglobalservers;
servers = &cls.globalServers[0];
@@ -229,9 +216,7 @@ static int LAN_GetServerCount( int source ) {
case AS_LOCAL :
return cls.numlocalservers;
break;
- case AS_MPLAYER :
- return cls.nummplayerservers;
- break;
+ case AS_MPLAYER:
case AS_GLOBAL :
return cls.numglobalservers;
break;
@@ -255,12 +240,7 @@ static void LAN_GetServerAddressString( int source, int n, char *buf, int buflen
return;
}
break;
- case AS_MPLAYER :
- if (n >= 0 && n < MAX_OTHER_SERVERS) {
- Q_strncpyz(buf, NET_AdrToStringwPort( cls.mplayerServers[n].adr) , buflen );
- return;
- }
- break;
+ case AS_MPLAYER:
case AS_GLOBAL :
if (n >= 0 && n < MAX_GLOBAL_SERVERS) {
Q_strncpyz(buf, NET_AdrToStringwPort( cls.globalServers[n].adr) , buflen );
@@ -292,11 +272,7 @@ static void LAN_GetServerInfo( int source, int n, char *buf, int buflen ) {
server = &cls.localServers[n];
}
break;
- case AS_MPLAYER :
- if (n >= 0 && n < MAX_OTHER_SERVERS) {
- server = &cls.mplayerServers[n];
- }
- break;
+ case AS_MPLAYER:
case AS_GLOBAL :
if (n >= 0 && n < MAX_GLOBAL_SERVERS) {
server = &cls.globalServers[n];
@@ -343,11 +319,7 @@ static int LAN_GetServerPing( int source, int n ) {
server = &cls.localServers[n];
}
break;
- case AS_MPLAYER :
- if (n >= 0 && n < MAX_OTHER_SERVERS) {
- server = &cls.mplayerServers[n];
- }
- break;
+ case AS_MPLAYER:
case AS_GLOBAL :
if (n >= 0 && n < MAX_GLOBAL_SERVERS) {
server = &cls.globalServers[n];
@@ -377,11 +349,7 @@ static serverInfo_t *LAN_GetServerPtr( int source, int n ) {
return &cls.localServers[n];
}
break;
- case AS_MPLAYER :
- if (n >= 0 && n < MAX_OTHER_SERVERS) {
- return &cls.mplayerServers[n];
- }
- break;
+ case AS_MPLAYER:
case AS_GLOBAL :
if (n >= 0 && n < MAX_GLOBAL_SERVERS) {
return &cls.globalServers[n];
@@ -514,9 +482,7 @@ static void LAN_MarkServerVisible(int source, int n, qboolean visible ) {
case AS_LOCAL :
server = &cls.localServers[0];
break;
- case AS_MPLAYER :
- server = &cls.mplayerServers[0];
- break;
+ case AS_MPLAYER:
case AS_GLOBAL :
server = &cls.globalServers[0];
count = MAX_GLOBAL_SERVERS;
@@ -538,11 +504,7 @@ static void LAN_MarkServerVisible(int source, int n, qboolean visible ) {
cls.localServers[n].visible = visible;
}
break;
- case AS_MPLAYER :
- if (n >= 0 && n < MAX_OTHER_SERVERS) {
- cls.mplayerServers[n].visible = visible;
- }
- break;
+ case AS_MPLAYER:
case AS_GLOBAL :
if (n >= 0 && n < MAX_GLOBAL_SERVERS) {
cls.globalServers[n].visible = visible;
@@ -570,11 +532,7 @@ static int LAN_ServerIsVisible(int source, int n ) {
return cls.localServers[n].visible;
}
break;
- case AS_MPLAYER :
- if (n >= 0 && n < MAX_OTHER_SERVERS) {
- return cls.mplayerServers[n].visible;
- }
- break;
+ case AS_MPLAYER:
case AS_GLOBAL :
if (n >= 0 && n < MAX_GLOBAL_SERVERS) {
return cls.globalServers[n].visible;
diff --git a/code/client/client.h b/code/client/client.h
index 7a0bd53..34aacc5 100644
--- a/code/client/client.h
+++ b/code/client/client.h
@@ -264,11 +264,6 @@ typedef struct {
} serverInfo_t;
typedef struct {
- byte ip[4];
- unsigned short port;
-} serverAddress_t;
-
-typedef struct {
connstate_t state; // connection status
qboolean cddialog; // bring up the cd needed dialog next frame
@@ -295,18 +290,13 @@ typedef struct {
serverInfo_t globalServers[MAX_GLOBAL_SERVERS];
// additional global servers
int numGlobalServerAddresses;
- serverAddress_t globalServerAddresses[MAX_GLOBAL_SERVERS];
+ netadr_t globalServerAddresses[MAX_GLOBAL_SERVERS];
int numfavoriteservers;
serverInfo_t favoriteServers[MAX_OTHER_SERVERS];
- int nummplayerservers;
- serverInfo_t mplayerServers[MAX_OTHER_SERVERS];
-
int pingUpdateSource; // source currently pinging or updating
- int masterNum;
-
// update server info
netadr_t updateServer;
char updateChallenge[MAX_TOKEN_CHARS];