From 9f239d647b5e7d21e437ad6f012af436b30bb456 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Thu, 20 Jul 2017 15:39:51 -0500 Subject: [PATCH] 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. --- code/client/cl_main.c | 37 ++++++++++++++++++++++++++++----- code/q3_ui/ui_servers2.c | 44 ++++++++++++++++++++++------------------ code/ui/ui_main.c | 35 +++++++++++++++++--------------- 3 files changed, 75 insertions(+), 41 deletions(-) diff --git a/code/client/cl_main.c b/code/client/cl_main.c index b0712a3d..506940b1 100644 --- a/code/client/cl_main.c +++ b/code/client/cl_main.c @@ -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 [keywords]\n", MAX_MASTER_SERVERS - 1); + Com_Printf("usage: globalservers [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; diff --git a/code/q3_ui/ui_servers2.c b/code/q3_ui/ui_servers2.c index 48308053..93e4697b 100644 --- a/code/q3_ui/ui_servers2.c +++ b/code/q3_ui/ui_servers2.c @@ -81,14 +81,15 @@ MULTIPLAYER MENU (SERVER BROWSER) #define GR_LETTERS 31 #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 UIAS_GLOBAL0 1 +#define UIAS_GLOBAL1 2 +#define UIAS_GLOBAL2 3 +#define UIAS_GLOBAL3 4 +#define UIAS_GLOBAL4 5 +#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_MAP 1 @@ -104,11 +105,12 @@ MULTIPLAYER MENU (SERVER BROWSER) static const char *master_items[] = { "Local", - "Internet1", - "Internet2", - "Internet3", - "Internet4", - "Internet5", + "Internet", + "Master1", + "Master2", + "Master3", + "Master4", + "Master5", "Favorites", NULL }; @@ -347,6 +349,7 @@ int ArenaServers_SourceForLAN(void) { default: case UIAS_LOCAL: return AS_LOCAL; + case UIAS_GLOBAL0: case UIAS_GLOBAL1: case UIAS_GLOBAL2: case UIAS_GLOBAL3: @@ -431,7 +434,7 @@ static void ArenaServers_UpdateMenu( void ) { g_arenaservers.punkbuster.generic.flags &= ~QMF_GRAYED; // 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; } else { @@ -465,7 +468,7 @@ static void ArenaServers_UpdateMenu( void ) { } // 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; } else { @@ -1010,7 +1013,7 @@ static void ArenaServers_StartRefresh( void ) return; } - if( g_servertype >= UIAS_GLOBAL1 && g_servertype <= UIAS_GLOBAL5 ) { + if( g_servertype >= UIAS_GLOBAL0 && g_servertype <= UIAS_GLOBAL5 ) { switch( g_arenaservers.gametype.curvalue ) { default: case GAMES_ALL: @@ -1046,10 +1049,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", g_servertype - UIAS_GLOBAL1, protocol, myargs )); + trap_Cmd_ExecuteText( EXEC_APPEND, va( "globalservers %d %s%s\n", g_servertype - UIAS_GLOBAL0, protocol, myargs )); } 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) { - 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)); if(*masterstr) break; @@ -1122,14 +1125,15 @@ int ArenaServers_SetType( int type ) g_arenaservers.maxservers = MAX_LOCALSERVERS; break; + case UIAS_GLOBAL0: 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[type-UIAS_GLOBAL1]; - g_arenaservers.numservers = &g_numglobalservers[type-UIAS_GLOBAL1]; + g_arenaservers.serverlist = g_globalserverlist[type-UIAS_GLOBAL0]; + g_arenaservers.numservers = &g_numglobalservers[type-UIAS_GLOBAL0]; g_arenaservers.maxservers = MAX_GLOBALSERVERS; break; diff --git a/code/ui/ui_main.c b/code/ui/ui_main.c index 81b324b5..73d3f60a 100644 --- a/code/ui/ui_main.c +++ b/code/ui/ui_main.c @@ -55,20 +55,22 @@ static const int numSkillLevels = ARRAY_LEN( skillLevels ); #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 UIAS_GLOBAL0 1 +#define UIAS_GLOBAL1 2 +#define UIAS_GLOBAL2 3 +#define UIAS_GLOBAL3 4 +#define UIAS_GLOBAL4 5 +#define UIAS_GLOBAL5 6 +#define UIAS_FAVORITES 7 static const char *netSources[] = { "Local", - "Internet1", - "Internet2", - "Internet3", - "Internet4", - "Internet5", + "Internet", + "Master1", + "Master2", + "Master3", + "Master4", + "Master5", "Favorites" }; static const int numNetSources = ARRAY_LEN( netSources ); @@ -999,6 +1001,7 @@ int UI_SourceForLAN(void) { default: case UIAS_LOCAL: return AS_LOCAL; + case UIAS_GLOBAL0: case UIAS_GLOBAL1: case UIAS_GLOBAL2: 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) { - 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)); if(*masterstr) 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. // Automatically update local and favorite servers. // 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 ) { return; // have cached list } @@ -6041,14 +6044,14 @@ static void UI_StartServerRefresh(qboolean full, qboolean force) } 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"); 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 { - 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" ) ) ); } } }