Support five master servers in Team Arena server browser.

This commit is contained in:
Zack Middleton 2011-08-05 08:28:01 +00:00
parent f220db0e08
commit 6242d16e0d

View file

@ -54,10 +54,21 @@ static const char *skillLevels[] = {
static const int numSkillLevels = ARRAY_LEN( skillLevels ); 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
static const char *netSources[] = { static const char *netSources[] = {
"Local", "Local",
"Mplayer", "Internet1",
"Internet", "Internet2",
"Internet3",
"Internet4",
"Internet5",
"Favorites" "Favorites"
}; };
static const int numNetSources = ARRAY_LEN( netSources ); static const int numNetSources = ARRAY_LEN( netSources );
@ -981,6 +992,24 @@ void UI_Load(void) {
} }
// Convert ui's net source to AS_* used by trap calls.
int UI_SourceForLAN(void) {
switch (ui_netSource.integer) {
default:
case UIAS_LOCAL:
return AS_LOCAL;
case UIAS_GLOBAL1:
case UIAS_GLOBAL2:
case UIAS_GLOBAL3:
case UIAS_GLOBAL4:
case UIAS_GLOBAL5:
return AS_GLOBAL;
case UIAS_FAVORITES:
return AS_FAVORITES;
}
}
static const char *handicapValues[] = {"None","95","90","85","80","75","70","65","60","55","50","45","40","35","30","25","20","15","10","5",NULL}; static const char *handicapValues[] = {"None","95","90","85","80","75","70","65","60","55","50","45","40","35","30","25","20","15","10","5",NULL};
#ifndef MISSIONPACK #ifndef MISSIONPACK
static int numHandicaps = ARRAY_LEN(handicapValues); static int numHandicaps = ARRAY_LEN(handicapValues);
@ -1678,7 +1707,7 @@ static int UI_OwnerDrawWidth(int ownerDraw, float scale) {
s = va("%i. %s", ownerDraw-UI_REDTEAM1 + 1, text); s = va("%i. %s", ownerDraw-UI_REDTEAM1 + 1, text);
break; break;
case UI_NETSOURCE: case UI_NETSOURCE:
if (ui_netSource.integer < 0 || ui_netSource.integer > uiInfo.numJoinGameTypes) { if (ui_netSource.integer < 0 || ui_netSource.integer > numNetSources) {
ui_netSource.integer = 0; ui_netSource.integer = 0;
} }
s = va("Source: %s", netSources[ui_netSource.integer]); s = va("Source: %s", netSources[ui_netSource.integer]);
@ -1826,7 +1855,7 @@ static void UI_DrawServerRefreshDate(rectDef_t *rect, float scale, vec4_t color,
lowLight[2] = 0.8 * color[2]; lowLight[2] = 0.8 * color[2];
lowLight[3] = 0.8 * color[3]; lowLight[3] = 0.8 * color[3];
LerpColor(color,lowLight,newColor,0.5+0.5*sin(uiInfo.uiDC.realTime / PULSE_DIVISOR)); LerpColor(color,lowLight,newColor,0.5+0.5*sin(uiInfo.uiDC.realTime / PULSE_DIVISOR));
Text_Paint(rect->x, rect->y, scale, newColor, va("Getting info for %d servers (ESC to cancel)", trap_LAN_GetServerCount(ui_netSource.integer)), 0, 0, textStyle); Text_Paint(rect->x, rect->y, scale, newColor, va("Getting info for %d servers (ESC to cancel)", trap_LAN_GetServerCount(UI_SourceForLAN())), 0, 0, textStyle);
} else { } else {
char buff[64]; char buff[64];
Q_strncpyz(buff, UI_Cvar_VariableString(va("ui_lastServerRefresh_%i", ui_netSource.integer)), 64); Q_strncpyz(buff, UI_Cvar_VariableString(va("ui_lastServerRefresh_%i", ui_netSource.integer)), 64);
@ -2162,14 +2191,14 @@ static qboolean UI_OwnerDrawVisible(int flags) {
} }
if (flags & UI_SHOW_FAVORITESERVERS) { if (flags & UI_SHOW_FAVORITESERVERS) {
// this assumes you only put this type of display flag on something showing in the proper context // this assumes you only put this type of display flag on something showing in the proper context
if (ui_netSource.integer != AS_FAVORITES) { if (ui_netSource.integer != UIAS_FAVORITES) {
vis = qfalse; vis = qfalse;
} }
flags &= ~UI_SHOW_FAVORITESERVERS; flags &= ~UI_SHOW_FAVORITESERVERS;
} }
if (flags & UI_SHOW_NOTFAVORITESERVERS) { if (flags & UI_SHOW_NOTFAVORITESERVERS) {
// this assumes you only put this type of display flag on something showing in the proper context // this assumes you only put this type of display flag on something showing in the proper context
if (ui_netSource.integer == AS_FAVORITES) { if (ui_netSource.integer == UIAS_FAVORITES) {
vis = qfalse; vis = qfalse;
} }
flags &= ~UI_SHOW_NOTFAVORITESERVERS; flags &= ~UI_SHOW_NOTFAVORITESERVERS;
@ -2467,28 +2496,47 @@ static qboolean UI_TeamMember_HandleKey(int flags, float *special, int key, qboo
} }
static qboolean UI_NetSource_HandleKey(int flags, float *special, int key) { static qboolean UI_NetSource_HandleKey(int flags, float *special, int key) {
if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) { if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) {
if (key == K_MOUSE2) { if (key == K_MOUSE2) {
ui_netSource.integer--; ui_netSource.integer--;
} else { } else {
ui_netSource.integer++; ui_netSource.integer++;
} }
if(ui_netSource.integer >= UIAS_GLOBAL1 && ui_netSource.integer <= UIAS_GLOBAL5)
{
char masterstr[2], cvarname[sizeof("sv_master1")];
while(ui_netSource.integer >= UIAS_GLOBAL1 && ui_netSource.integer <= UIAS_GLOBAL5)
{
Com_sprintf(cvarname, sizeof(cvarname), "sv_master%d", ui_netSource.integer);
trap_Cvar_VariableStringBuffer(cvarname, masterstr, sizeof(masterstr));
if(*masterstr)
break;
if (key == K_MOUSE2) {
ui_netSource.integer--;
} else {
ui_netSource.integer++;
}
}
}
if (ui_netSource.integer >= numNetSources) { if (ui_netSource.integer >= numNetSources) {
ui_netSource.integer = 0; ui_netSource.integer = 0;
} else if (ui_netSource.integer < 0) { } else if (ui_netSource.integer < 0) {
ui_netSource.integer = numNetSources - 1; ui_netSource.integer = numNetSources - 1;
} }
UI_BuildServerDisplayList(qtrue); UI_BuildServerDisplayList(qtrue);
if (ui_netSource.integer != AS_GLOBAL) { if (!(ui_netSource.integer >= UIAS_GLOBAL1 && ui_netSource.integer <= UIAS_GLOBAL5)) {
UI_StartServerRefresh(qtrue); UI_StartServerRefresh(qtrue);
} }
trap_Cvar_Set( "ui_netSource", va("%d", ui_netSource.integer)); trap_Cvar_Set( "ui_netSource", va("%d", ui_netSource.integer));
return qtrue; return qtrue;
} }
return qfalse; return qfalse;
} }
static qboolean UI_NetFilter_HandleKey(int flags, float *special, int key) { static qboolean UI_NetFilter_HandleKey(int flags, float *special, int key) {
@ -2717,7 +2765,7 @@ UI_ServersQsortCompare
================= =================
*/ */
static int QDECL UI_ServersQsortCompare( const void *arg1, const void *arg2 ) { static int QDECL UI_ServersQsortCompare( const void *arg1, const void *arg2 ) {
return trap_LAN_CompareServers( ui_netSource.integer, uiInfo.serverStatus.sortKey, uiInfo.serverStatus.sortDir, *(int*)arg1, *(int*)arg2); return trap_LAN_CompareServers( UI_SourceForLAN(), uiInfo.serverStatus.sortKey, uiInfo.serverStatus.sortDir, *(int*)arg1, *(int*)arg2);
} }
@ -3312,13 +3360,13 @@ static void UI_RunMenuScript(char **args) {
uiInfo.nextServerStatusRefresh = 0; uiInfo.nextServerStatusRefresh = 0;
uiInfo.nextFindPlayerRefresh = 0; uiInfo.nextFindPlayerRefresh = 0;
} else if (Q_stricmp(name, "UpdateFilter") == 0) { } else if (Q_stricmp(name, "UpdateFilter") == 0) {
if (ui_netSource.integer == AS_LOCAL) { if (ui_netSource.integer == UIAS_LOCAL) {
UI_StartServerRefresh(qtrue); UI_StartServerRefresh(qtrue);
} }
UI_BuildServerDisplayList(qtrue); UI_BuildServerDisplayList(qtrue);
UI_FeederSelection(FEEDER_SERVERS, 0); UI_FeederSelection(FEEDER_SERVERS, 0);
} else if (Q_stricmp(name, "ServerStatus") == 0) { } else if (Q_stricmp(name, "ServerStatus") == 0) {
trap_LAN_GetServerAddressString(ui_netSource.integer, uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], uiInfo.serverStatusAddress, sizeof(uiInfo.serverStatusAddress)); trap_LAN_GetServerAddressString(UI_SourceForLAN(), uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], uiInfo.serverStatusAddress, sizeof(uiInfo.serverStatusAddress));
UI_BuildServerStatus(qtrue); UI_BuildServerStatus(qtrue);
} else if (Q_stricmp(name, "FoundPlayerServerStatus") == 0) { } else if (Q_stricmp(name, "FoundPlayerServerStatus") == 0) {
Q_strncpyz(uiInfo.serverStatusAddress, uiInfo.foundPlayerServerAddresses[uiInfo.currentFoundPlayerServer], sizeof(uiInfo.serverStatusAddress)); Q_strncpyz(uiInfo.serverStatusAddress, uiInfo.foundPlayerServerAddresses[uiInfo.currentFoundPlayerServer], sizeof(uiInfo.serverStatusAddress));
@ -3334,7 +3382,7 @@ static void UI_RunMenuScript(char **args) {
trap_Cvar_Set("cg_cameraOrbit", "0"); trap_Cvar_Set("cg_cameraOrbit", "0");
trap_Cvar_Set("ui_singlePlayerActive", "0"); trap_Cvar_Set("ui_singlePlayerActive", "0");
if (uiInfo.serverStatus.currentServer >= 0 && uiInfo.serverStatus.currentServer < uiInfo.serverStatus.numDisplayServers) { if (uiInfo.serverStatus.currentServer >= 0 && uiInfo.serverStatus.currentServer < uiInfo.serverStatus.numDisplayServers) {
trap_LAN_GetServerAddressString(ui_netSource.integer, uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], buff, 1024); trap_LAN_GetServerAddressString(UI_SourceForLAN(), uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], buff, 1024);
trap_Cmd_ExecuteText( EXEC_APPEND, va( "connect %s\n", buff ) ); trap_Cmd_ExecuteText( EXEC_APPEND, va( "connect %s\n", buff ) );
} }
} else if (Q_stricmp(name, "FoundPlayerJoinServer") == 0) { } else if (Q_stricmp(name, "FoundPlayerJoinServer") == 0) {
@ -3397,12 +3445,12 @@ static void UI_RunMenuScript(char **args) {
trap_Cmd_ExecuteText( EXEC_APPEND, va("addbot %s %i %s\n", UI_GetBotNameByNumber(uiInfo.botIndex), uiInfo.skillIndex+1, (uiInfo.redBlue == 0) ? "Red" : "Blue") ); trap_Cmd_ExecuteText( EXEC_APPEND, va("addbot %s %i %s\n", UI_GetBotNameByNumber(uiInfo.botIndex), uiInfo.skillIndex+1, (uiInfo.redBlue == 0) ? "Red" : "Blue") );
} }
} else if (Q_stricmp(name, "addFavorite") == 0) { } else if (Q_stricmp(name, "addFavorite") == 0) {
if (ui_netSource.integer != AS_FAVORITES) { if (ui_netSource.integer != UIAS_FAVORITES) {
char name[MAX_NAME_LENGTH]; char name[MAX_NAME_LENGTH];
char addr[MAX_NAME_LENGTH]; char addr[MAX_NAME_LENGTH];
int res; int res;
trap_LAN_GetServerInfo(ui_netSource.integer, uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], buff, MAX_STRING_CHARS); trap_LAN_GetServerInfo(UI_SourceForLAN(), uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], buff, MAX_STRING_CHARS);
name[0] = addr[0] = '\0'; name[0] = addr[0] = '\0';
Q_strncpyz(name, Info_ValueForKey(buff, "hostname"), MAX_NAME_LENGTH); Q_strncpyz(name, Info_ValueForKey(buff, "hostname"), MAX_NAME_LENGTH);
Q_strncpyz(addr, Info_ValueForKey(buff, "addr"), MAX_NAME_LENGTH); Q_strncpyz(addr, Info_ValueForKey(buff, "addr"), MAX_NAME_LENGTH);
@ -3423,9 +3471,9 @@ static void UI_RunMenuScript(char **args) {
} }
} }
} else if (Q_stricmp(name, "deleteFavorite") == 0) { } else if (Q_stricmp(name, "deleteFavorite") == 0) {
if (ui_netSource.integer == AS_FAVORITES) { if (ui_netSource.integer == UIAS_FAVORITES) {
char addr[MAX_NAME_LENGTH]; char addr[MAX_NAME_LENGTH];
trap_LAN_GetServerInfo(ui_netSource.integer, uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], buff, MAX_STRING_CHARS); trap_LAN_GetServerInfo(AS_FAVORITES, uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], buff, MAX_STRING_CHARS);
addr[0] = '\0'; addr[0] = '\0';
Q_strncpyz(addr, Info_ValueForKey(buff, "addr"), MAX_NAME_LENGTH); Q_strncpyz(addr, Info_ValueForKey(buff, "addr"), MAX_NAME_LENGTH);
if (strlen(addr) > 0) { if (strlen(addr) > 0) {
@ -3433,7 +3481,7 @@ static void UI_RunMenuScript(char **args) {
} }
} }
} else if (Q_stricmp(name, "createFavorite") == 0) { } else if (Q_stricmp(name, "createFavorite") == 0) {
if (ui_netSource.integer == AS_FAVORITES) { if (ui_netSource.integer == UIAS_FAVORITES) {
char name[MAX_NAME_LENGTH]; char name[MAX_NAME_LENGTH];
char addr[MAX_NAME_LENGTH]; char addr[MAX_NAME_LENGTH];
int res; int res;
@ -3688,7 +3736,7 @@ static void UI_BinaryServerInsertion(int num) {
while(mid > 0) { while(mid > 0) {
mid = len >> 1; mid = len >> 1;
// //
res = trap_LAN_CompareServers( ui_netSource.integer, uiInfo.serverStatus.sortKey, res = trap_LAN_CompareServers( UI_SourceForLAN(), uiInfo.serverStatus.sortKey,
uiInfo.serverStatus.sortDir, num, uiInfo.serverStatus.displayServers[offset+mid]); uiInfo.serverStatus.sortDir, num, uiInfo.serverStatus.displayServers[offset+mid]);
// if equal // if equal
if (res == 0) { if (res == 0) {
@ -3721,6 +3769,7 @@ static void UI_BuildServerDisplayList(qboolean force) {
char info[MAX_STRING_CHARS]; char info[MAX_STRING_CHARS];
// qboolean startRefresh = qtrue; TTimo: unused // qboolean startRefresh = qtrue; TTimo: unused
static int numinvisible; static int numinvisible;
int lanSource;
if (!(force || uiInfo.uiDC.realTime > uiInfo.serverStatus.nextDisplayRefresh)) { if (!(force || uiInfo.uiDC.realTime > uiInfo.serverStatus.nextDisplayRefresh)) {
return; return;
@ -3742,6 +3791,8 @@ static void UI_BuildServerDisplayList(qboolean force) {
uiInfo.serverStatus.motdWidth = -1; uiInfo.serverStatus.motdWidth = -1;
} }
lanSource = UI_SourceForLAN();
if (force) { if (force) {
numinvisible = 0; numinvisible = 0;
// clear number of displayed servers // clear number of displayed servers
@ -3750,12 +3801,12 @@ static void UI_BuildServerDisplayList(qboolean force) {
// set list box index to zero // set list box index to zero
Menu_SetFeederSelection(NULL, FEEDER_SERVERS, 0, NULL); Menu_SetFeederSelection(NULL, FEEDER_SERVERS, 0, NULL);
// mark all servers as visible so we store ping updates for them // mark all servers as visible so we store ping updates for them
trap_LAN_MarkServerVisible(ui_netSource.integer, -1, qtrue); trap_LAN_MarkServerVisible(lanSource, -1, qtrue);
} }
// get the server count (comes from the master) // get the server count (comes from the master)
count = trap_LAN_GetServerCount(ui_netSource.integer); count = trap_LAN_GetServerCount(lanSource);
if (count == -1 || (ui_netSource.integer == AS_LOCAL && count == 0) ) { if (count == -1 || (ui_netSource.integer == UIAS_LOCAL && count == 0) ) {
// still waiting on a response from the master // still waiting on a response from the master
uiInfo.serverStatus.numDisplayServers = 0; uiInfo.serverStatus.numDisplayServers = 0;
uiInfo.serverStatus.numPlayersOnServers = 0; uiInfo.serverStatus.numPlayersOnServers = 0;
@ -3766,22 +3817,22 @@ static void UI_BuildServerDisplayList(qboolean force) {
visible = qfalse; visible = qfalse;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
// if we already got info for this server // if we already got info for this server
if (!trap_LAN_ServerIsVisible(ui_netSource.integer, i)) { if (!trap_LAN_ServerIsVisible(lanSource, i)) {
continue; continue;
} }
visible = qtrue; visible = qtrue;
// get the ping for this server // get the ping for this server
ping = trap_LAN_GetServerPing(ui_netSource.integer, i); ping = trap_LAN_GetServerPing(lanSource, i);
if (ping > 0 || ui_netSource.integer == AS_FAVORITES) { if (ping > 0 || ui_netSource.integer == UIAS_FAVORITES) {
trap_LAN_GetServerInfo(ui_netSource.integer, i, info, MAX_STRING_CHARS); trap_LAN_GetServerInfo(lanSource, i, info, MAX_STRING_CHARS);
clients = atoi(Info_ValueForKey(info, "clients")); clients = atoi(Info_ValueForKey(info, "clients"));
uiInfo.serverStatus.numPlayersOnServers += clients; uiInfo.serverStatus.numPlayersOnServers += clients;
if (ui_browserShowEmpty.integer == 0) { if (ui_browserShowEmpty.integer == 0) {
if (clients == 0) { if (clients == 0) {
trap_LAN_MarkServerVisible(ui_netSource.integer, i, qfalse); trap_LAN_MarkServerVisible(lanSource, i, qfalse);
continue; continue;
} }
} }
@ -3789,7 +3840,7 @@ static void UI_BuildServerDisplayList(qboolean force) {
if (ui_browserShowFull.integer == 0) { if (ui_browserShowFull.integer == 0) {
maxClients = atoi(Info_ValueForKey(info, "sv_maxclients")); maxClients = atoi(Info_ValueForKey(info, "sv_maxclients"));
if (clients == maxClients) { if (clients == maxClients) {
trap_LAN_MarkServerVisible(ui_netSource.integer, i, qfalse); trap_LAN_MarkServerVisible(lanSource, i, qfalse);
continue; continue;
} }
} }
@ -3797,26 +3848,26 @@ static void UI_BuildServerDisplayList(qboolean force) {
if (uiInfo.joinGameTypes[ui_joinGameType.integer].gtEnum != -1) { if (uiInfo.joinGameTypes[ui_joinGameType.integer].gtEnum != -1) {
game = atoi(Info_ValueForKey(info, "gametype")); game = atoi(Info_ValueForKey(info, "gametype"));
if (game != uiInfo.joinGameTypes[ui_joinGameType.integer].gtEnum) { if (game != uiInfo.joinGameTypes[ui_joinGameType.integer].gtEnum) {
trap_LAN_MarkServerVisible(ui_netSource.integer, i, qfalse); trap_LAN_MarkServerVisible(lanSource, i, qfalse);
continue; continue;
} }
} }
if (ui_serverFilterType.integer > 0) { if (ui_serverFilterType.integer > 0) {
if (Q_stricmp(Info_ValueForKey(info, "game"), serverFilters[ui_serverFilterType.integer].basedir) != 0) { if (Q_stricmp(Info_ValueForKey(info, "game"), serverFilters[ui_serverFilterType.integer].basedir) != 0) {
trap_LAN_MarkServerVisible(ui_netSource.integer, i, qfalse); trap_LAN_MarkServerVisible(lanSource, i, qfalse);
continue; continue;
} }
} }
// make sure we never add a favorite server twice // make sure we never add a favorite server twice
if (ui_netSource.integer == AS_FAVORITES) { if (ui_netSource.integer == UIAS_FAVORITES) {
UI_RemoveServerFromDisplayList(i); UI_RemoveServerFromDisplayList(i);
} }
// insert the server into the list // insert the server into the list
UI_BinaryServerInsertion(i); UI_BinaryServerInsertion(i);
// done with this server // done with this server
if (ping > 0) { if (ping > 0) {
trap_LAN_MarkServerVisible(ui_netSource.integer, i, qfalse); trap_LAN_MarkServerVisible(lanSource, i, qfalse);
numinvisible++; numinvisible++;
} }
} }
@ -4012,6 +4063,7 @@ static void UI_BuildFindPlayerList(qboolean force) {
serverStatusInfo_t info; serverStatusInfo_t info;
char name[MAX_NAME_LENGTH+2]; char name[MAX_NAME_LENGTH+2];
char infoString[MAX_STRING_CHARS]; char infoString[MAX_STRING_CHARS];
int lanSource;
if (!force) { if (!force) {
if (!uiInfo.nextFindPlayerRefresh || uiInfo.nextFindPlayerRefresh > uiInfo.uiDC.realTime) { if (!uiInfo.nextFindPlayerRefresh || uiInfo.nextFindPlayerRefresh > uiInfo.uiDC.realTime) {
@ -4100,9 +4152,10 @@ static void UI_BuildFindPlayerList(qboolean force) {
// if we didn't try to get the status of all servers in the main browser yet // if we didn't try to get the status of all servers in the main browser yet
if (uiInfo.pendingServerStatus.num < uiInfo.serverStatus.numDisplayServers) { if (uiInfo.pendingServerStatus.num < uiInfo.serverStatus.numDisplayServers) {
uiInfo.pendingServerStatus.server[i].startTime = uiInfo.uiDC.realTime; uiInfo.pendingServerStatus.server[i].startTime = uiInfo.uiDC.realTime;
trap_LAN_GetServerAddressString(ui_netSource.integer, uiInfo.serverStatus.displayServers[uiInfo.pendingServerStatus.num], lanSource = UI_SourceForLAN();
trap_LAN_GetServerAddressString(lanSource, uiInfo.serverStatus.displayServers[uiInfo.pendingServerStatus.num],
uiInfo.pendingServerStatus.server[i].adrstr, sizeof(uiInfo.pendingServerStatus.server[i].adrstr)); uiInfo.pendingServerStatus.server[i].adrstr, sizeof(uiInfo.pendingServerStatus.server[i].adrstr));
trap_LAN_GetServerInfo(ui_netSource.integer, uiInfo.serverStatus.displayServers[uiInfo.pendingServerStatus.num], infoString, sizeof(infoString)); trap_LAN_GetServerInfo(lanSource, uiInfo.serverStatus.displayServers[uiInfo.pendingServerStatus.num], infoString, sizeof(infoString));
Q_strncpyz(uiInfo.pendingServerStatus.server[i].name, Info_ValueForKey(infoString, "hostname"), sizeof(uiInfo.pendingServerStatus.server[0].name)); Q_strncpyz(uiInfo.pendingServerStatus.server[i].name, Info_ValueForKey(infoString, "hostname"), sizeof(uiInfo.pendingServerStatus.server[0].name));
uiInfo.pendingServerStatus.server[i].valid = qtrue; uiInfo.pendingServerStatus.server[i].valid = qtrue;
uiInfo.pendingServerStatus.num++; uiInfo.pendingServerStatus.num++;
@ -4259,7 +4312,7 @@ static int UI_GetIndexFromSelection(int actual) {
} }
static void UI_UpdatePendingPings( void ) { static void UI_UpdatePendingPings( void ) {
trap_LAN_ResetPings(ui_netSource.integer); trap_LAN_ResetPings(UI_SourceForLAN());
uiInfo.serverStatus.refreshActive = qtrue; uiInfo.serverStatus.refreshActive = qtrue;
uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 1000; uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 1000;
@ -4286,7 +4339,7 @@ static const char *UI_FeederItemText(float feederID, int index, int column, qhan
if (index >= 0 && index < uiInfo.serverStatus.numDisplayServers) { if (index >= 0 && index < uiInfo.serverStatus.numDisplayServers) {
int ping, game, punkbuster; int ping, game, punkbuster;
if (lastColumn != column || lastTime > uiInfo.uiDC.realTime + 5000) { if (lastColumn != column || lastTime > uiInfo.uiDC.realTime + 5000) {
trap_LAN_GetServerInfo(ui_netSource.integer, uiInfo.serverStatus.displayServers[index], info, MAX_STRING_CHARS); trap_LAN_GetServerInfo(UI_SourceForLAN(), uiInfo.serverStatus.displayServers[index], info, MAX_STRING_CHARS);
lastColumn = column; lastColumn = column;
lastTime = uiInfo.uiDC.realTime; lastTime = uiInfo.uiDC.realTime;
} }
@ -4300,7 +4353,7 @@ static const char *UI_FeederItemText(float feederID, int index, int column, qhan
if (ping <= 0) { if (ping <= 0) {
return Info_ValueForKey(info, "addr"); return Info_ValueForKey(info, "addr");
} else { } else {
if ( ui_netSource.integer == AS_LOCAL ) { if ( ui_netSource.integer == UIAS_LOCAL ) {
int nettype = atoi(Info_ValueForKey(info, "nettype")); int nettype = atoi(Info_ValueForKey(info, "nettype"));
if (nettype < 0 || nettype >= ARRAY_LEN(netnames)) { if (nettype < 0 || nettype >= ARRAY_LEN(netnames)) {
@ -4456,7 +4509,7 @@ static void UI_FeederSelection(float feederID, int index) {
} else if (feederID == FEEDER_SERVERS) { } else if (feederID == FEEDER_SERVERS) {
const char *mapName = NULL; const char *mapName = NULL;
uiInfo.serverStatus.currentServer = index; uiInfo.serverStatus.currentServer = index;
trap_LAN_GetServerInfo(ui_netSource.integer, uiInfo.serverStatus.displayServers[index], info, MAX_STRING_CHARS); trap_LAN_GetServerInfo(UI_SourceForLAN(), uiInfo.serverStatus.displayServers[index], info, MAX_STRING_CHARS);
uiInfo.serverStatus.currentServerPreview = trap_R_RegisterShaderNoMip(va("levelshots/%s", Info_ValueForKey(info, "mapname"))); uiInfo.serverStatus.currentServerPreview = trap_R_RegisterShaderNoMip(va("levelshots/%s", Info_ValueForKey(info, "mapname")));
if (uiInfo.serverStatus.currentServerCinematic >= 0) { if (uiInfo.serverStatus.currentServerCinematic >= 0) {
trap_CIN_StopCinematic(uiInfo.serverStatus.currentServerCinematic); trap_CIN_StopCinematic(uiInfo.serverStatus.currentServerCinematic);
@ -5657,6 +5710,9 @@ vmCvar_t ui_lastServerRefresh_0;
vmCvar_t ui_lastServerRefresh_1; vmCvar_t ui_lastServerRefresh_1;
vmCvar_t ui_lastServerRefresh_2; vmCvar_t ui_lastServerRefresh_2;
vmCvar_t ui_lastServerRefresh_3; vmCvar_t ui_lastServerRefresh_3;
vmCvar_t ui_lastServerRefresh_4;
vmCvar_t ui_lastServerRefresh_5;
vmCvar_t ui_lastServerRefresh_6;
vmCvar_t ui_singlePlayerActive; vmCvar_t ui_singlePlayerActive;
vmCvar_t ui_scoreAccuracy; vmCvar_t ui_scoreAccuracy;
vmCvar_t ui_scoreImpressives; vmCvar_t ui_scoreImpressives;
@ -5775,6 +5831,9 @@ static cvarTable_t cvarTable[] = {
{ &ui_lastServerRefresh_1, "ui_lastServerRefresh_1", "", CVAR_ARCHIVE}, { &ui_lastServerRefresh_1, "ui_lastServerRefresh_1", "", CVAR_ARCHIVE},
{ &ui_lastServerRefresh_2, "ui_lastServerRefresh_2", "", CVAR_ARCHIVE}, { &ui_lastServerRefresh_2, "ui_lastServerRefresh_2", "", CVAR_ARCHIVE},
{ &ui_lastServerRefresh_3, "ui_lastServerRefresh_3", "", CVAR_ARCHIVE}, { &ui_lastServerRefresh_3, "ui_lastServerRefresh_3", "", CVAR_ARCHIVE},
{ &ui_lastServerRefresh_4, "ui_lastServerRefresh_4", "", CVAR_ARCHIVE},
{ &ui_lastServerRefresh_5, "ui_lastServerRefresh_5", "", CVAR_ARCHIVE},
{ &ui_lastServerRefresh_6, "ui_lastServerRefresh_6", "", CVAR_ARCHIVE},
{ &ui_singlePlayerActive, "ui_singlePlayerActive", "0", 0}, { &ui_singlePlayerActive, "ui_singlePlayerActive", "0", 0},
{ &ui_scoreAccuracy, "ui_scoreAccuracy", "0", CVAR_ARCHIVE}, { &ui_scoreAccuracy, "ui_scoreAccuracy", "0", CVAR_ARCHIVE},
{ &ui_scoreImpressives, "ui_scoreImpressives", "0", CVAR_ARCHIVE}, { &ui_scoreImpressives, "ui_scoreImpressives", "0", CVAR_ARCHIVE},
@ -5855,7 +5914,7 @@ static void UI_StopServerRefresh( void )
Com_Printf("%d servers listed in browser with %d players.\n", Com_Printf("%d servers listed in browser with %d players.\n",
uiInfo.serverStatus.numDisplayServers, uiInfo.serverStatus.numDisplayServers,
uiInfo.serverStatus.numPlayersOnServers); uiInfo.serverStatus.numPlayersOnServers);
count = trap_LAN_GetServerCount(ui_netSource.integer); count = trap_LAN_GetServerCount(UI_SourceForLAN());
if (count - uiInfo.serverStatus.numDisplayServers > 0) { if (count - uiInfo.serverStatus.numDisplayServers > 0) {
Com_Printf("%d servers not listed due to packet loss or pings higher than %d\n", Com_Printf("%d servers not listed due to packet loss or pings higher than %d\n",
count - uiInfo.serverStatus.numDisplayServers, count - uiInfo.serverStatus.numDisplayServers,
@ -5893,13 +5952,13 @@ static void UI_DoServerRefresh( void )
if (!uiInfo.serverStatus.refreshActive) { if (!uiInfo.serverStatus.refreshActive) {
return; return;
} }
if (ui_netSource.integer != AS_FAVORITES) { if (ui_netSource.integer != UIAS_FAVORITES) {
if (ui_netSource.integer == AS_LOCAL) { if (ui_netSource.integer == UIAS_LOCAL) {
if (!trap_LAN_GetServerCount(ui_netSource.integer)) { if (!trap_LAN_GetServerCount(AS_LOCAL)) {
wait = qtrue; wait = qtrue;
} }
} else { } else {
if (trap_LAN_GetServerCount(ui_netSource.integer) < 0) { if (trap_LAN_GetServerCount(AS_GLOBAL) < 0) {
wait = qtrue; wait = qtrue;
} }
} }
@ -5912,7 +5971,7 @@ static void UI_DoServerRefresh( void )
} }
// if still trying to retrieve pings // if still trying to retrieve pings
if (trap_LAN_UpdateVisiblePings(ui_netSource.integer)) { if (trap_LAN_UpdateVisiblePings(UI_SourceForLAN())) {
uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 1000; uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 1000;
} else if (!wait) { } else if (!wait) {
// get the last servers in the list // get the last servers in the list
@ -5932,6 +5991,7 @@ UI_StartServerRefresh
static void UI_StartServerRefresh(qboolean full) static void UI_StartServerRefresh(qboolean full)
{ {
char *ptr; char *ptr;
int lanSource;
qtime_t q; qtime_t q;
trap_RealTime(&q); trap_RealTime(&q);
@ -5947,26 +6007,28 @@ static void UI_StartServerRefresh(qboolean full)
// clear number of displayed servers // clear number of displayed servers
uiInfo.serverStatus.numDisplayServers = 0; uiInfo.serverStatus.numDisplayServers = 0;
uiInfo.serverStatus.numPlayersOnServers = 0; uiInfo.serverStatus.numPlayersOnServers = 0;
lanSource = UI_SourceForLAN();
// mark all servers as visible so we store ping updates for them // mark all servers as visible so we store ping updates for them
trap_LAN_MarkServerVisible(ui_netSource.integer, -1, qtrue); trap_LAN_MarkServerVisible(lanSource, -1, qtrue);
// reset all the pings // reset all the pings
trap_LAN_ResetPings(ui_netSource.integer); trap_LAN_ResetPings(lanSource);
// //
if( ui_netSource.integer == AS_LOCAL ) { if( ui_netSource.integer == UIAS_LOCAL ) {
trap_Cmd_ExecuteText( EXEC_NOW, "localservers\n" ); trap_Cmd_ExecuteText( EXEC_NOW, "localservers\n" );
uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 1000; uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 1000;
return; return;
} }
uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 5000; uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 5000;
if( ui_netSource.integer == AS_GLOBAL ) { if( ui_netSource.integer >= UIAS_GLOBAL1 && 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 0 %s full empty\n", ptr)); trap_Cmd_ExecuteText( EXEC_NOW, va( "globalservers %d %s full empty\n", ui_netSource.integer-1, ptr));
} }
else { else {
trap_Cmd_ExecuteText( EXEC_NOW, va( "globalservers 0 %d full empty\n", (int)trap_Cvar_VariableValue( "protocol" ) ) ); trap_Cmd_ExecuteText( EXEC_NOW, va( "globalservers %d %d full empty\n", ui_netSource.integer-1, (int)trap_Cvar_VariableValue( "protocol" ) ) );
} }
} }
} }