diff --git a/code/ui/ui_main.c b/code/ui/ui_main.c index 8bb35226..63d90eb6 100644 --- a/code/ui/ui_main.c +++ b/code/ui/ui_main.c @@ -114,7 +114,7 @@ static int gamecodetoui[] = {4,2,3,0,5,1,6}; static int uitogamecode[] = {4,6,2,3,1,5,7}; -static void UI_StartServerRefresh(qboolean full); +static void UI_StartServerRefresh(qboolean full, qboolean force); static void UI_StopServerRefresh( void ); static void UI_DoServerRefresh( void ); static void UI_FeederSelection(float feederID, int index); @@ -2503,9 +2503,7 @@ static qboolean UI_NetSource_HandleKey(int flags, float *special, int key) { } UI_BuildServerDisplayList(qtrue); - if (!(ui_netSource.integer >= UIAS_GLOBAL1 && ui_netSource.integer <= UIAS_GLOBAL5)) { - UI_StartServerRefresh(qtrue); - } + UI_StartServerRefresh(qtrue, qfalse); trap_Cvar_SetValue( "ui_netSource", ui_netSource.integer); return qtrue; } @@ -3277,10 +3275,10 @@ static void UI_RunMenuScript(char **args) { } else if (Q_stricmp(name, "resetScores") == 0) { UI_ClearScores(); } else if (Q_stricmp(name, "RefreshServers") == 0) { - UI_StartServerRefresh(qtrue); + UI_StartServerRefresh(qtrue, qtrue); UI_BuildServerDisplayList(qtrue); } else if (Q_stricmp(name, "RefreshFilter") == 0) { - UI_StartServerRefresh(qfalse); + UI_StartServerRefresh(qfalse, qtrue); UI_BuildServerDisplayList(qtrue); } else if (Q_stricmp(name, "RunSPDemo") == 0) { if (uiInfo.demoAvailable) { @@ -3322,9 +3320,8 @@ static void UI_RunMenuScript(char **args) { uiInfo.nextServerStatusRefresh = 0; uiInfo.nextFindPlayerRefresh = 0; } else if (Q_stricmp(name, "UpdateFilter") == 0) { - if (ui_netSource.integer == UIAS_LOCAL) { - UI_StartServerRefresh(qtrue); - } + // UpdateFilter is called when server broser menu is opened and when a favorite server is deleted. + UI_StartServerRefresh(qtrue, qfalse); UI_BuildServerDisplayList(qtrue); UI_FeederSelection(FEEDER_SERVERS, 0); } else if (Q_stricmp(name, "ServerStatus") == 0) { @@ -5949,12 +5946,22 @@ static void UI_DoServerRefresh( void ) UI_StartServerRefresh ================= */ -static void UI_StartServerRefresh(qboolean full) +static void UI_StartServerRefresh(qboolean full, qboolean force) { char *ptr; int lanSource; - qtime_t q; + + // This function is called with force=qfalse when server browser menu opens or net source changes. + // Automatically update local and favorite servers. + // Only update master server list the first time because the server info cache will be available after that. + if ( !force && ( ui_netSource.integer >= UIAS_GLOBAL1 && ui_netSource.integer <= UIAS_GLOBAL5 ) ) { + char *value = UI_Cvar_VariableString( va( "ui_lastServerRefresh_%i", ui_netSource.integer ) ); + if ( value[0] != 0 ) { + return; // should have cached list + } + } + trap_RealTime(&q); trap_Cvar_Set( va("ui_lastServerRefresh_%i", ui_netSource.integer), va("%s-%i, %i at %i:%i", MonthAbbrev[q.tm_mon],q.tm_mday, 1900+q.tm_year,q.tm_hour,q.tm_min));