aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-04-11 18:39:03 +0000
committerthilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-04-11 18:39:03 +0000
commita957b652bae5d1a5320eb01c349437bc7197b91a (patch)
treee0a83c4a59321c9fe728cde2e0572fc8b496e143
parent23d2a365bdf5b9e2fdf88809db685512e5fddf7c (diff)
downloadioquake3-aero-a957b652bae5d1a5320eb01c349437bc7197b91a.tar.gz
ioquake3-aero-a957b652bae5d1a5320eb01c349437bc7197b91a.zip
- Revamp in-game server browser: you can now scan for games on multiple master servers, while retaining compatibility with old QVMs.
- Make Master server reporting/server queries ipv6 capable. git-svn-id: svn://svn.icculus.org/quake3/trunk@1311 edf5b092-35ff-0310-97b2-ce42778d08ea
-rw-r--r--code/client/cl_main.c196
-rw-r--r--code/client/cl_ui.c72
-rw-r--r--code/client/client.h12
-rw-r--r--code/q3_ui/ui_servers2.c104
-rw-r--r--code/qcommon/net_chan.c31
-rw-r--r--code/qcommon/qcommon.h2
-rw-r--r--code/server/sv_main.c6
-rw-r--r--code/ui/ui_main.c16
8 files changed, 181 insertions, 258 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];
diff --git a/code/q3_ui/ui_servers2.c b/code/q3_ui/ui_servers2.c
index fa679f6..6c7cf16 100644
--- a/code/q3_ui/ui_servers2.c
+++ b/code/q3_ui/ui_servers2.c
@@ -80,10 +80,13 @@ MULTIPLAYER MENU (SERVER BROWSER)
#define GR_LOGO 30
#define GR_LETTERS 31
-#define AS_LOCAL 0
-#define AS_MPLAYER 1
-#define AS_GLOBAL 2
-#define AS_FAVORITES 3
+#define UIAS_LOCAL 0
+#define UIAS_GLOBAL1 1
+#define UIAS_GLOBAL2 2
+#define UIAS_GLOBAL3 3
+#define UIAS_GLOBAL4 4
+#define UIAS_GLOBAL5 5
+#define UIAS_FAVORITES 6
#define SORT_HOST 0
#define SORT_MAP 1
@@ -99,7 +102,11 @@ MULTIPLAYER MENU (SERVER BROWSER)
static const char *master_items[] = {
"Local",
- "Internet",
+ "Internet1",
+ "Internet2",
+ "Internet3",
+ "Internet4",
+ "Internet5",
"Favorites",
NULL
};
@@ -241,8 +248,6 @@ static servernode_t g_localserverlist[MAX_LOCALSERVERS];
static int g_numlocalservers;
static servernode_t g_favoriteserverlist[MAX_FAVORITESERVERS];
static int g_numfavoriteservers;
-static servernode_t g_mplayerserverlist[MAX_GLOBALSERVERS];
-static int g_nummplayerservers;
static int g_servertype;
static int g_gametype;
static int g_sortkey;
@@ -403,7 +408,7 @@ static void ArenaServers_UpdateMenu( void ) {
g_arenaservers.punkbuster.generic.flags &= ~QMF_GRAYED;
// update status bar
- if( g_servertype == AS_GLOBAL || g_servertype == AS_MPLAYER ) {
+ if( g_servertype >= UIAS_GLOBAL1 && g_servertype <= UIAS_GLOBAL5 ) {
g_arenaservers.statusbar.string = quake3worldMessage;
}
else {
@@ -438,7 +443,7 @@ static void ArenaServers_UpdateMenu( void ) {
}
// update status bar
- if( g_servertype == AS_GLOBAL || g_servertype == AS_MPLAYER ) {
+ if( g_servertype >= UIAS_GLOBAL1 && g_servertype <= UIAS_GLOBAL5 ) {
g_arenaservers.statusbar.string = quake3worldMessage;
}
else {
@@ -618,7 +623,7 @@ static void ArenaServers_Insert( char* adrstr, char* info, int pingtime )
int i;
- if ((pingtime >= ArenaServers_MaxPing()) && (g_servertype != AS_FAVORITES))
+ if ((pingtime >= ArenaServers_MaxPing()) && (g_servertype != UIAS_FAVORITES))
{
// slow global or local servers do not get entered
return;
@@ -809,7 +814,7 @@ static void ArenaServers_StopRefresh( void )
g_arenaservers.refreshservers = qfalse;
- if (g_servertype == AS_FAVORITES)
+ if (g_servertype == UIAS_FAVORITES)
{
// nonresponsive favorites must be shown
ArenaServers_InsertFavorites();
@@ -845,8 +850,8 @@ static void ArenaServers_DoRefresh( void )
if (uis.realtime < g_arenaservers.refreshtime)
{
- if (g_servertype != AS_FAVORITES) {
- if (g_servertype == AS_LOCAL) {
+ if (g_servertype != UIAS_FAVORITES) {
+ if (g_servertype == UIAS_LOCAL) {
if (!trap_LAN_GetServerCount(g_servertype)) {
return;
}
@@ -920,7 +925,7 @@ static void ArenaServers_DoRefresh( void )
// get results of servers query
// counts can increase as servers respond
- if (g_servertype == AS_FAVORITES) {
+ if (g_servertype == UIAS_FAVORITES) {
g_arenaservers.numqueriedservers = g_arenaservers.numfavoriteaddresses;
} else {
g_arenaservers.numqueriedservers = trap_LAN_GetServerCount(g_servertype);
@@ -950,7 +955,7 @@ static void ArenaServers_DoRefresh( void )
// get an address to ping
- if (g_servertype == AS_FAVORITES) {
+ if (g_servertype == UIAS_FAVORITES) {
strcpy( adrstr, g_arenaservers.favoriteaddresses[g_arenaservers.currentping] );
} else {
trap_LAN_GetServerAddressString(g_servertype, g_arenaservers.currentping, adrstr, MAX_ADDRESSLENGTH );
@@ -1007,19 +1012,12 @@ static void ArenaServers_StartRefresh( void )
// place menu in zeroed state
ArenaServers_UpdateMenu();
- if( g_servertype == AS_LOCAL ) {
+ if( g_servertype == UIAS_LOCAL ) {
trap_Cmd_ExecuteText( EXEC_APPEND, "localservers\n" );
return;
}
- if( g_servertype == AS_GLOBAL || g_servertype == AS_MPLAYER ) {
- if( g_servertype == AS_GLOBAL ) {
- i = 0;
- }
- else {
- i = 1;
- }
-
+ if( g_servertype >= UIAS_GLOBAL1 && g_servertype <= UIAS_GLOBAL5 ) {
switch( g_arenaservers.gametype.curvalue ) {
default:
case GAMES_ALL:
@@ -1055,10 +1053,10 @@ static void ArenaServers_StartRefresh( void )
protocol[0] = '\0';
trap_Cvar_VariableStringBuffer( "debug_protocol", protocol, sizeof(protocol) );
if (strlen(protocol)) {
- trap_Cmd_ExecuteText( EXEC_APPEND, va( "globalservers %d %s%s\n", i, protocol, myargs ));
+ trap_Cmd_ExecuteText( EXEC_APPEND, va( "globalservers %d %s%s\n", g_servertype - 1, protocol, myargs ));
}
else {
- trap_Cmd_ExecuteText( EXEC_APPEND, va( "globalservers %d %d%s\n", i, (int)trap_Cvar_VariableValue( "protocol" ), myargs ) );
+ trap_Cmd_ExecuteText( EXEC_APPEND, va( "globalservers %d %d%s\n", g_servertype - 1, (int)trap_Cvar_VariableValue( "protocol" ), myargs ) );
}
}
}
@@ -1101,43 +1099,52 @@ void ArenaServers_Sort( int type ) {
ArenaServers_SetType
=================
*/
-void ArenaServers_SetType( int type )
+int ArenaServers_SetType( int type )
{
- if (g_servertype == type)
- return;
+ if(type >= UIAS_GLOBAL1 && type <= UIAS_GLOBAL5)
+ {
+ char masterstr[2], cvarname[sizeof("sv_master1")];
+
+ while(type <= UIAS_GLOBAL5)
+ {
+ Com_sprintf(cvarname, sizeof(cvarname), "sv_master%d", type);
+ trap_Cvar_VariableStringBuffer(cvarname, masterstr, sizeof(masterstr));
+ if(*masterstr)
+ break;
+
+ type++;
+ }
+ }
g_servertype = type;
switch( type ) {
default:
- case AS_LOCAL:
+ case UIAS_LOCAL:
g_arenaservers.remove.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);
g_arenaservers.serverlist = g_localserverlist;
g_arenaservers.numservers = &g_numlocalservers;
g_arenaservers.maxservers = MAX_LOCALSERVERS;
break;
- case AS_GLOBAL:
+ case UIAS_GLOBAL1:
+ case UIAS_GLOBAL2:
+ case UIAS_GLOBAL3:
+ case UIAS_GLOBAL4:
+ case UIAS_GLOBAL5:
g_arenaservers.remove.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);
g_arenaservers.serverlist = g_globalserverlist;
g_arenaservers.numservers = &g_numglobalservers;
g_arenaservers.maxservers = MAX_GLOBALSERVERS;
break;
- case AS_FAVORITES:
+ case UIAS_FAVORITES:
g_arenaservers.remove.generic.flags &= ~(QMF_INACTIVE|QMF_HIDDEN);
g_arenaservers.serverlist = g_favoriteserverlist;
g_arenaservers.numservers = &g_numfavoriteservers;
g_arenaservers.maxservers = MAX_FAVORITESERVERS;
break;
- case AS_MPLAYER:
- g_arenaservers.remove.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);
- g_arenaservers.serverlist = g_mplayerserverlist;
- g_arenaservers.numservers = &g_nummplayerservers;
- g_arenaservers.maxservers = MAX_GLOBALSERVERS;
- break;
-
}
if( !*g_arenaservers.numservers ) {
@@ -1150,6 +1157,8 @@ void ArenaServers_SetType( int type )
ArenaServers_UpdateMenu();
}
strcpy(g_arenaservers.status.string,"hit refresh to update");
+
+ return type;
}
/*
@@ -1181,7 +1190,6 @@ ArenaServers_Event
*/
static void ArenaServers_Event( void* ptr, int event ) {
int id;
- int value;
id = ((menucommon_s*)ptr)->id;
@@ -1191,13 +1199,8 @@ static void ArenaServers_Event( void* ptr, int event ) {
switch( id ) {
case ID_MASTER:
- value = g_arenaservers.master.curvalue;
- if (value >= 1)
- {
- value++;
- }
- trap_Cvar_SetValue( "ui_browserMaster", value );
- ArenaServers_SetType( value );
+ g_arenaservers.master.curvalue = ArenaServers_SetType(g_arenaservers.master.curvalue);
+ trap_Cvar_SetValue( "ui_browserMaster", g_arenaservers.master.curvalue);
break;
case ID_GAMETYPE:
@@ -1304,7 +1307,7 @@ static sfxHandle_t ArenaServers_MenuKey( int key ) {
return menu_move_sound;
}
- if( ( key == K_DEL || key == K_KP_DEL ) && ( g_servertype == AS_FAVORITES ) &&
+ if( ( key == K_DEL || key == K_KP_DEL ) && ( g_servertype == UIAS_FAVORITES ) &&
( Menu_ItemAtCursor( &g_arenaservers.menu) == &g_arenaservers.list ) ) {
ArenaServers_Remove();
ArenaServers_UpdateMenu();
@@ -1328,7 +1331,6 @@ ArenaServers_MenuInit
*/
static void ArenaServers_MenuInit( void ) {
int i;
- int type;
int y;
int value;
static char statusbuffer[MAX_STATUSLENGTH];
@@ -1600,9 +1602,7 @@ static void ArenaServers_MenuInit( void ) {
g_arenaservers.punkbuster.curvalue = Com_Clamp( 0, 1, trap_Cvar_VariableValue( "cl_punkbuster" ) );
// force to initial state and refresh
- type = g_servertype;
- g_servertype = -1;
- ArenaServers_SetType( type );
+ g_arenaservers.master.curvalue = g_servertype = ArenaServers_SetType(g_servertype);
trap_Cvar_Register(NULL, "debug_protocol", "", 0 );
}
diff --git a/code/qcommon/net_chan.c b/code/qcommon/net_chan.c
index e4b1739..8869c01 100644
--- a/code/qcommon/net_chan.c
+++ b/code/qcommon/net_chan.c
@@ -673,17 +673,19 @@ void QDECL NET_OutOfBandData( netsrc_t sock, netadr_t adr, byte *format, int len
NET_StringToAdr
Traps "localhost" for loopback, passes everything else to system
+return 0 on address not found, 1 on address found with port, 2 on address found without port.
=============
*/
-qboolean NET_StringToAdr( const char *s, netadr_t *a, netadrtype_t family ) {
- qboolean r;
+int NET_StringToAdr( const char *s, netadr_t *a, netadrtype_t family )
+{
char base[MAX_STRING_CHARS], *search;
char *port = NULL;
if (!strcmp (s, "localhost")) {
Com_Memset (a, 0, sizeof(*a));
a->type = NA_LOOPBACK;
- return qtrue;
+// as NA_LOOPBACK doesn't require ports report port was given.
+ return 1;
}
Q_strncpyz( base, s, sizeof( base ) );
@@ -719,19 +721,20 @@ qboolean NET_StringToAdr( const char *s, netadr_t *a, netadrtype_t family ) {
search = base;
}
- r = Sys_StringToAdr( search, a, family );
-
- if ( !r ) {
+ if(!Sys_StringToAdr(search, a, family))
+ {
a->type = NA_BAD;
- return qfalse;
+ return 0;
}
- if ( port ) {
- a->port = BigShort( (short)atoi( port ) );
- } else {
- a->port = BigShort( PORT_SERVER );
+ if(port)
+ {
+ a->port = BigShort((short) atoi(port));
+ return 1;
+ }
+ else
+ {
+ a->port = BigShort(PORT_SERVER);
+ return 2;
}
-
- return qtrue;
}
-
diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h
index 0fe6a47..8746f3b 100644
--- a/code/qcommon/qcommon.h
+++ b/code/qcommon/qcommon.h
@@ -171,7 +171,7 @@ qboolean NET_CompareBaseAdr (netadr_t a, netadr_t b);
qboolean NET_IsLocalAddress (netadr_t adr);
const char *NET_AdrToString (netadr_t a);
const char *NET_AdrToStringwPort (netadr_t a);
-qboolean NET_StringToAdr ( const char *s, netadr_t *a, netadrtype_t family);
+int NET_StringToAdr ( const char *s, netadr_t *a, netadrtype_t family);
qboolean NET_GetLoopPacket (netsrc_t sock, netadr_t *net_from, msg_t *net_message);
void NET_JoinMulticast6(void);
void NET_LeaveMulticast6(void);
diff --git a/code/server/sv_main.c b/code/server/sv_main.c
index 0974c83..96a6515 100644
--- a/code/server/sv_main.c
+++ b/code/server/sv_main.c
@@ -252,7 +252,7 @@ void SV_MasterHeartbeat( void ) {
sv_master[i]->modified = qfalse;
Com_Printf( "Resolving %s\n", sv_master[i]->string );
- if ( !NET_StringToAdr( sv_master[i]->string, &adr[i], NA_IP ) ) {
+ if ( !NET_StringToAdr( sv_master[i]->string, &adr[i], NA_UNSPEC ) ) {
// if the address failed to resolve, clear it
// so we don't take repeated dns hits
Com_Printf( "Couldn't resolve address: %s\n", sv_master[i]->string );
@@ -263,9 +263,7 @@ void SV_MasterHeartbeat( void ) {
if ( !strchr( sv_master[i]->string, ':' ) ) {
adr[i].port = BigShort( PORT_MASTER );
}
- Com_Printf( "%s resolved to %i.%i.%i.%i:%i\n", sv_master[i]->string,
- adr[i].ip[0], adr[i].ip[1], adr[i].ip[2], adr[i].ip[3],
- BigShort( adr[i].port ) );
+ Com_Printf( "%s resolved to %s\n", sv_master[i]->string, NET_AdrToStringwPort(adr[i]));
}
diff --git a/code/ui/ui_main.c b/code/ui/ui_main.c
index dcf6743..c06ecdd 100644
--- a/code/ui/ui_main.c
+++ b/code/ui/ui_main.c
@@ -2495,12 +2495,8 @@ static qboolean UI_NetSource_HandleKey(int flags, float *special, int key) {
if (key == K_MOUSE2) {
ui_netSource.integer--;
- if (ui_netSource.integer == AS_MPLAYER)
- ui_netSource.integer--;
} else {
ui_netSource.integer++;
- if (ui_netSource.integer == AS_MPLAYER)
- ui_netSource.integer++;
}
if (ui_netSource.integer >= numNetSources) {
@@ -5972,20 +5968,14 @@ static void UI_StartServerRefresh(qboolean full)
}
uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 5000;
- if( ui_netSource.integer == AS_GLOBAL || ui_netSource.integer == AS_MPLAYER ) {
- if( ui_netSource.integer == AS_GLOBAL ) {
- i = 0;
- }
- else {
- i = 1;
- }
+ if( ui_netSource.integer == AS_GLOBAL ) {
ptr = UI_Cvar_VariableString("debug_protocol");
if (strlen(ptr)) {
- trap_Cmd_ExecuteText( EXEC_NOW, va( "globalservers %d %s full empty\n", i, ptr));
+ trap_Cmd_ExecuteText( EXEC_NOW, va( "globalservers 0 %s full empty\n", ptr));
}
else {
- trap_Cmd_ExecuteText( EXEC_NOW, va( "globalservers %d %d full empty\n", i, (int)trap_Cvar_VariableValue( "protocol" ) ) );
+ trap_Cmd_ExecuteText( EXEC_NOW, va( "globalservers 0 %d full empty\n", (int)trap_Cvar_VariableValue( "protocol" ) ) );
}
}
}