Make 'globalservers 0' fetch all masters

This commit fixes the vanilla Q3 UI VMs not displaying a server list
when id Software's master server is down.

Originally master 0 for the globalservers command was Internet and
master 1 was MPlayer (defunct). In 2008 ioquake3 changed it so that
master 0 to 4 were five separate master servers with no affect on
original Quake3/Team Arena UI VMs; they continued to get the server
list from master.quake3arena.com.

id Software's master server (master.quake3arena.com) goes down
occasionally. Using ioq3's UI VM additional master servers can be
accessed but players using the original UI VMs are unable to get a
server list.

In order to fix the original UI VMs in Quake3/Team Arena's pk3s this
commit makes 'globalservers 0' fetch all master servers. So players
get a combined list of id Software's and ioquake3's master list. Or
just ioquake3's list if id Software's master is down.

Getting lists from individual master servers using globalservers has
changed from 0 through 4 to 1 through 5 to accommodate using 0 for
other purposes. This commit modifies ioq3's UI code to support the new
values for globalservers command.

A side affect of these changes is that UI VMs based on ioq3 since 2008
will have Internet1 fetch all master servers and Internet2 request
sv_master1 instead of sv_master2 and so on. It may be worth noting that
getting server list from masters 3-5 could not be done using ioq3's UI
before 2011.
This commit is contained in:
Zack Middleton 2017-07-20 15:39:51 -05:00 committed by GitHub
parent fa1549d457
commit 9f239d647b
3 changed files with 75 additions and 41 deletions

View file

@ -2471,7 +2471,7 @@ void CL_ServersResponsePacket( const netadr_t* from, msg_t *msg, qboolean extend
byte* buffptr; byte* buffptr;
byte* buffend; byte* buffend;
Com_Printf("CL_ServersResponsePacket\n"); Com_Printf("CL_ServersResponsePacket from %s\n", NET_AdrToStringwPort(*from));
if (cls.numglobalservers == -1) { if (cls.numglobalservers == -1) {
// state to detect lack of servers or lack of response // state to detect lack of servers or lack of response
@ -4165,6 +4165,10 @@ void CL_LocalServers_f( void ) {
/* /*
================== ==================
CL_GlobalServers_f CL_GlobalServers_f
Originally master 0 was Internet and master 1 was MPlayer.
ioquake3 2008; added support for requesting five separate master servers using 0-4.
ioquake3 2017; made master 0 fetch all master servers and 1-5 request a single master server.
================== ==================
*/ */
void CL_GlobalServers_f( void ) { void CL_GlobalServers_f( void ) {
@ -4172,13 +4176,36 @@ void CL_GlobalServers_f( void ) {
int count, i, masterNum; int count, i, masterNum;
char command[1024], *masteraddress; char command[1024], *masteraddress;
if ((count = Cmd_Argc()) < 3 || (masterNum = atoi(Cmd_Argv(1))) < 0 || masterNum > MAX_MASTER_SERVERS - 1) if ((count = Cmd_Argc()) < 3 || (masterNum = atoi(Cmd_Argv(1))) < 0 || masterNum > MAX_MASTER_SERVERS)
{ {
Com_Printf("usage: globalservers <master# 0-%d> <protocol> [keywords]\n", MAX_MASTER_SERVERS - 1); Com_Printf("usage: globalservers <master# 0-%d> <protocol> [keywords]\n", MAX_MASTER_SERVERS);
return; return;
} }
sprintf(command, "sv_master%d", masterNum + 1); // request from all master servers
if ( masterNum == 0 ) {
int numAddress = 0;
for ( i = 1; i <= MAX_MASTER_SERVERS; i++ ) {
sprintf(command, "sv_master%d", i);
masteraddress = Cvar_VariableString(command);
if(!*masteraddress)
continue;
numAddress++;
Com_sprintf(command, sizeof(command), "globalservers %d %s %s\n", i, Cmd_Argv(2), Cmd_ArgsFrom(3));
Cbuf_AddText(command);
}
if ( !numAddress ) {
Com_Printf( "CL_GlobalServers_f: Error: No master server addresses.\n");
}
return;
}
sprintf(command, "sv_master%d", masterNum);
masteraddress = Cvar_VariableString(command); masteraddress = Cvar_VariableString(command);
if(!*masteraddress) if(!*masteraddress)
@ -4200,7 +4227,7 @@ void CL_GlobalServers_f( void ) {
else if(i == 2) else if(i == 2)
to.port = BigShort(PORT_MASTER); to.port = BigShort(PORT_MASTER);
Com_Printf("Requesting servers from master %s...\n", masteraddress); Com_Printf("Requesting servers from %s (%s)...\n", masteraddress, NET_AdrToStringwPort(to));
cls.numglobalservers = -1; cls.numglobalservers = -1;
cls.pingUpdateSource = AS_GLOBAL; cls.pingUpdateSource = AS_GLOBAL;

View file

@ -81,14 +81,15 @@ MULTIPLAYER MENU (SERVER BROWSER)
#define GR_LETTERS 31 #define GR_LETTERS 31
#define UIAS_LOCAL 0 #define UIAS_LOCAL 0
#define UIAS_GLOBAL1 1 #define UIAS_GLOBAL0 1
#define UIAS_GLOBAL2 2 #define UIAS_GLOBAL1 2
#define UIAS_GLOBAL3 3 #define UIAS_GLOBAL2 3
#define UIAS_GLOBAL4 4 #define UIAS_GLOBAL3 4
#define UIAS_GLOBAL5 5 #define UIAS_GLOBAL4 5
#define UIAS_FAVORITES 6 #define UIAS_GLOBAL5 6
#define UIAS_FAVORITES 7
#define UI_MAX_MASTER_SERVERS 5 #define UI_MAX_MASTER_SERVERS 6
#define SORT_HOST 0 #define SORT_HOST 0
#define SORT_MAP 1 #define SORT_MAP 1
@ -104,11 +105,12 @@ MULTIPLAYER MENU (SERVER BROWSER)
static const char *master_items[] = { static const char *master_items[] = {
"Local", "Local",
"Internet1", "Internet",
"Internet2", "Master1",
"Internet3", "Master2",
"Internet4", "Master3",
"Internet5", "Master4",
"Master5",
"Favorites", "Favorites",
NULL NULL
}; };
@ -347,6 +349,7 @@ int ArenaServers_SourceForLAN(void) {
default: default:
case UIAS_LOCAL: case UIAS_LOCAL:
return AS_LOCAL; return AS_LOCAL;
case UIAS_GLOBAL0:
case UIAS_GLOBAL1: case UIAS_GLOBAL1:
case UIAS_GLOBAL2: case UIAS_GLOBAL2:
case UIAS_GLOBAL3: case UIAS_GLOBAL3:
@ -431,7 +434,7 @@ static void ArenaServers_UpdateMenu( void ) {
g_arenaservers.punkbuster.generic.flags &= ~QMF_GRAYED; g_arenaservers.punkbuster.generic.flags &= ~QMF_GRAYED;
// update status bar // update status bar
if( g_servertype >= UIAS_GLOBAL1 && g_servertype <= UIAS_GLOBAL5 ) { if( g_servertype >= UIAS_GLOBAL0 && g_servertype <= UIAS_GLOBAL5 ) {
g_arenaservers.statusbar.string = quake3worldMessage; g_arenaservers.statusbar.string = quake3worldMessage;
} }
else { else {
@ -465,7 +468,7 @@ static void ArenaServers_UpdateMenu( void ) {
} }
// update status bar // update status bar
if( g_servertype >= UIAS_GLOBAL1 && g_servertype <= UIAS_GLOBAL5 ) { if( g_servertype >= UIAS_GLOBAL0 && g_servertype <= UIAS_GLOBAL5 ) {
g_arenaservers.statusbar.string = quake3worldMessage; g_arenaservers.statusbar.string = quake3worldMessage;
} }
else { else {
@ -1010,7 +1013,7 @@ static void ArenaServers_StartRefresh( void )
return; return;
} }
if( g_servertype >= UIAS_GLOBAL1 && g_servertype <= UIAS_GLOBAL5 ) { if( g_servertype >= UIAS_GLOBAL0 && g_servertype <= UIAS_GLOBAL5 ) {
switch( g_arenaservers.gametype.curvalue ) { switch( g_arenaservers.gametype.curvalue ) {
default: default:
case GAMES_ALL: case GAMES_ALL:
@ -1046,10 +1049,10 @@ static void ArenaServers_StartRefresh( void )
protocol[0] = '\0'; protocol[0] = '\0';
trap_Cvar_VariableStringBuffer( "debug_protocol", protocol, sizeof(protocol) ); trap_Cvar_VariableStringBuffer( "debug_protocol", protocol, sizeof(protocol) );
if (strlen(protocol)) { if (strlen(protocol)) {
trap_Cmd_ExecuteText( EXEC_APPEND, va( "globalservers %d %s%s\n", g_servertype - UIAS_GLOBAL1, protocol, myargs )); trap_Cmd_ExecuteText( EXEC_APPEND, va( "globalservers %d %s%s\n", g_servertype - UIAS_GLOBAL0, protocol, myargs ));
} }
else { else {
trap_Cmd_ExecuteText( EXEC_APPEND, va( "globalservers %d %d%s\n", g_servertype - UIAS_GLOBAL1, (int)trap_Cvar_VariableValue( "protocol" ), myargs ) ); trap_Cmd_ExecuteText( EXEC_APPEND, va( "globalservers %d %d%s\n", g_servertype - UIAS_GLOBAL0, (int)trap_Cvar_VariableValue( "protocol" ), myargs ) );
} }
} }
} }
@ -1102,7 +1105,7 @@ int ArenaServers_SetType( int type )
while(type <= UIAS_GLOBAL5) while(type <= UIAS_GLOBAL5)
{ {
Com_sprintf(cvarname, sizeof(cvarname), "sv_master%d", type); Com_sprintf(cvarname, sizeof(cvarname), "sv_master%d", type - UIAS_GLOBAL0);
trap_Cvar_VariableStringBuffer(cvarname, masterstr, sizeof(masterstr)); trap_Cvar_VariableStringBuffer(cvarname, masterstr, sizeof(masterstr));
if(*masterstr) if(*masterstr)
break; break;
@ -1122,14 +1125,15 @@ int ArenaServers_SetType( int type )
g_arenaservers.maxservers = MAX_LOCALSERVERS; g_arenaservers.maxservers = MAX_LOCALSERVERS;
break; break;
case UIAS_GLOBAL0:
case UIAS_GLOBAL1: case UIAS_GLOBAL1:
case UIAS_GLOBAL2: case UIAS_GLOBAL2:
case UIAS_GLOBAL3: case UIAS_GLOBAL3:
case UIAS_GLOBAL4: case UIAS_GLOBAL4:
case UIAS_GLOBAL5: case UIAS_GLOBAL5:
g_arenaservers.remove.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN); g_arenaservers.remove.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);
g_arenaservers.serverlist = g_globalserverlist[type-UIAS_GLOBAL1]; g_arenaservers.serverlist = g_globalserverlist[type-UIAS_GLOBAL0];
g_arenaservers.numservers = &g_numglobalservers[type-UIAS_GLOBAL1]; g_arenaservers.numservers = &g_numglobalservers[type-UIAS_GLOBAL0];
g_arenaservers.maxservers = MAX_GLOBALSERVERS; g_arenaservers.maxservers = MAX_GLOBALSERVERS;
break; break;

View file

@ -55,20 +55,22 @@ static const int numSkillLevels = ARRAY_LEN( skillLevels );
#define UIAS_LOCAL 0 #define UIAS_LOCAL 0
#define UIAS_GLOBAL1 1 #define UIAS_GLOBAL0 1
#define UIAS_GLOBAL2 2 #define UIAS_GLOBAL1 2
#define UIAS_GLOBAL3 3 #define UIAS_GLOBAL2 3
#define UIAS_GLOBAL4 4 #define UIAS_GLOBAL3 4
#define UIAS_GLOBAL5 5 #define UIAS_GLOBAL4 5
#define UIAS_FAVORITES 6 #define UIAS_GLOBAL5 6
#define UIAS_FAVORITES 7
static const char *netSources[] = { static const char *netSources[] = {
"Local", "Local",
"Internet1", "Internet",
"Internet2", "Master1",
"Internet3", "Master2",
"Internet4", "Master3",
"Internet5", "Master4",
"Master5",
"Favorites" "Favorites"
}; };
static const int numNetSources = ARRAY_LEN( netSources ); static const int numNetSources = ARRAY_LEN( netSources );
@ -999,6 +1001,7 @@ int UI_SourceForLAN(void) {
default: default:
case UIAS_LOCAL: case UIAS_LOCAL:
return AS_LOCAL; return AS_LOCAL;
case UIAS_GLOBAL0:
case UIAS_GLOBAL1: case UIAS_GLOBAL1:
case UIAS_GLOBAL2: case UIAS_GLOBAL2:
case UIAS_GLOBAL3: case UIAS_GLOBAL3:
@ -2484,7 +2487,7 @@ static qboolean UI_NetSource_HandleKey(int flags, float *special, int key) {
while(ui_netSource.integer >= UIAS_GLOBAL1 && ui_netSource.integer <= UIAS_GLOBAL5) while(ui_netSource.integer >= UIAS_GLOBAL1 && ui_netSource.integer <= UIAS_GLOBAL5)
{ {
Com_sprintf(cvarname, sizeof(cvarname), "sv_master%d", ui_netSource.integer); Com_sprintf(cvarname, sizeof(cvarname), "sv_master%d", ui_netSource.integer - UIAS_GLOBAL0);
trap_Cvar_VariableStringBuffer(cvarname, masterstr, sizeof(masterstr)); trap_Cvar_VariableStringBuffer(cvarname, masterstr, sizeof(masterstr));
if(*masterstr) if(*masterstr)
break; break;
@ -6008,7 +6011,7 @@ static void UI_StartServerRefresh(qboolean full, qboolean force)
// This function is called with force=qfalse when server browser menu opens or net source changes. // This function is called with force=qfalse when server browser menu opens or net source changes.
// Automatically update local and favorite servers. // Automatically update local and favorite servers.
// Only auto update master server list if there is no server info cache. // Only auto update master server list if there is no server info cache.
if ( !force && ( ui_netSource.integer >= UIAS_GLOBAL1 && ui_netSource.integer <= UIAS_GLOBAL5 ) ) { if ( !force && ( ui_netSource.integer >= UIAS_GLOBAL0 && ui_netSource.integer <= UIAS_GLOBAL5 ) ) {
if ( trap_LAN_GetServerCount( UI_SourceForLAN() ) > 0 ) { if ( trap_LAN_GetServerCount( UI_SourceForLAN() ) > 0 ) {
return; // have cached list return; // have cached list
} }
@ -6041,14 +6044,14 @@ static void UI_StartServerRefresh(qboolean full, qboolean force)
} }
uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 5000; uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 5000;
if( ui_netSource.integer >= UIAS_GLOBAL1 && ui_netSource.integer <= UIAS_GLOBAL5 ) { if( ui_netSource.integer >= UIAS_GLOBAL0 && ui_netSource.integer <= UIAS_GLOBAL5 ) {
ptr = UI_Cvar_VariableString("debug_protocol"); ptr = UI_Cvar_VariableString("debug_protocol");
if (strlen(ptr)) { if (strlen(ptr)) {
trap_Cmd_ExecuteText( EXEC_NOW, va( "globalservers %d %s full empty\n", ui_netSource.integer - UIAS_GLOBAL1, ptr ) ); trap_Cmd_ExecuteText( EXEC_NOW, va( "globalservers %d %s full empty\n", ui_netSource.integer - UIAS_GLOBAL0, ptr ) );
} }
else { else {
trap_Cmd_ExecuteText( EXEC_NOW, va( "globalservers %d %d full empty\n", ui_netSource.integer - UIAS_GLOBAL1, (int)trap_Cvar_VariableValue( "protocol" ) ) ); trap_Cmd_ExecuteText( EXEC_NOW, va( "globalservers %d %d full empty\n", ui_netSource.integer - UIAS_GLOBAL0, (int)trap_Cvar_VariableValue( "protocol" ) ) );
} }
} }
} }