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* buffend;
Com_Printf("CL_ServersResponsePacket\n");
Com_Printf("CL_ServersResponsePacket from %s\n", NET_AdrToStringwPort(*from));
if (cls.numglobalservers == -1) {
// state to detect lack of servers or lack of response
@ -4165,6 +4165,10 @@ void CL_LocalServers_f( void ) {
/*
==================
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 ) {
@ -4172,13 +4176,36 @@ void CL_GlobalServers_f( void ) {
int count, i, masterNum;
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;
}
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);
if(!*masteraddress)
@ -4200,7 +4227,7 @@ void CL_GlobalServers_f( void ) {
else if(i == 2)
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.pingUpdateSource = AS_GLOBAL;