summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTony J. White <tjw@tjw.org>2007-03-03 05:16:20 +0000
committerTony J. White <tjw@tjw.org>2007-03-03 05:16:20 +0000
commitf6fde24c7eef3300171eeb13683d16f63cced94d (patch)
tree8defafe56dba29dd947efb29d1cfc38ffc33b766 /src
parent04d4cd2981788a7551d2b00fd89abe625b86e324 (diff)
* in-game server browser: default to sorting by ping, refresh the
server list automatically if the list is over 1 hour old or if there are no servers in the list
Diffstat (limited to 'src')
-rw-r--r--src/ui/ui_local.h1
-rw-r--r--src/ui/ui_main.c37
2 files changed, 36 insertions, 2 deletions
diff --git a/src/ui/ui_local.h b/src/ui/ui_local.h
index 654cda4e..def61dc3 100644
--- a/src/ui/ui_local.h
+++ b/src/ui/ui_local.h
@@ -698,6 +698,7 @@ typedef struct serverStatus_s {
int numServers;
int sortKey;
int sortDir;
+ qboolean sorted;
int lastCount;
qboolean refreshActive;
int currentServer;
diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c
index a4016388..1b1daa1a 100644
--- a/src/ui/ui_main.c
+++ b/src/ui/ui_main.c
@@ -3918,6 +3918,27 @@ static void UI_RunMenuScript(char **args) {
} else if (Q_stricmp(name, "RefreshServers") == 0) {
UI_StartServerRefresh(qtrue);
UI_BuildServerDisplayList(qtrue);
+ } else if (Q_stricmp(name, "InitServerList") == 0) {
+ int time = trap_RealTime( NULL );
+ int last;
+ int sortColumn;
+
+ // set up default sorting
+ if(!uiInfo.serverStatus.sorted && Int_Parse(args, &sortColumn))
+ {
+ uiInfo.serverStatus.sortKey = sortColumn;
+ uiInfo.serverStatus.sortDir = 0;
+ }
+
+ // refresh if older than 3 days or if list is empty
+ last = atoi( UI_Cvar_VariableString( va( "ui_lastServerRefresh_%i_time",
+ ui_netSource.integer ) ) );
+ if( trap_LAN_GetServerCount( ui_netSource.integer ) < 1 ||
+ ( time - last ) > 3600 )
+ {
+ UI_StartServerRefresh(qtrue);
+ UI_BuildServerDisplayList(qtrue);
+ }
} else if (Q_stricmp(name, "RefreshFilter") == 0) {
UI_StartServerRefresh(qfalse);
UI_BuildServerDisplayList(qtrue);
@@ -4101,6 +4122,7 @@ static void UI_RunMenuScript(char **args) {
}
// make sure we sort again
UI_ServersSort(sortColumn, qtrue);
+ uiInfo.serverStatus.sorted = qtrue;
}
} else if (Q_stricmp(name, "nextSkirmish") == 0) {
UI_StartSkirmish(qtrue);
@@ -5999,6 +6021,10 @@ vmCvar_t ui_lastServerRefresh_0;
vmCvar_t ui_lastServerRefresh_1;
vmCvar_t ui_lastServerRefresh_2;
vmCvar_t ui_lastServerRefresh_3;
+vmCvar_t ui_lastServerRefresh_0_time;
+vmCvar_t ui_lastServerRefresh_1_time;
+vmCvar_t ui_lastServerRefresh_2_time;
+vmCvar_t ui_lastServerRefresh_3_time;
vmCvar_t ui_singlePlayerActive;
vmCvar_t ui_scoreAccuracy;
vmCvar_t ui_scoreImpressives;
@@ -6122,6 +6148,10 @@ static cvarTable_t cvarTable[] = {
{ &ui_lastServerRefresh_1, "ui_lastServerRefresh_1", "", CVAR_ARCHIVE},
{ &ui_lastServerRefresh_2, "ui_lastServerRefresh_2", "", CVAR_ARCHIVE},
{ &ui_lastServerRefresh_3, "ui_lastServerRefresh_3", "", CVAR_ARCHIVE},
+ { &ui_lastServerRefresh_0, "ui_lastServerRefresh_0_time", "", CVAR_ARCHIVE},
+ { &ui_lastServerRefresh_1, "ui_lastServerRefresh_1_time", "", CVAR_ARCHIVE},
+ { &ui_lastServerRefresh_2, "ui_lastServerRefresh_2_time", "", CVAR_ARCHIVE},
+ { &ui_lastServerRefresh_3, "ui_lastServerRefresh_3_time", "", CVAR_ARCHIVE},
{ &ui_singlePlayerActive, "ui_singlePlayerActive", "0", 0},
{ &ui_scoreAccuracy, "ui_scoreAccuracy", "0", CVAR_ARCHIVE},
{ &ui_scoreImpressives, "ui_scoreImpressives", "0", CVAR_ARCHIVE},
@@ -6266,9 +6296,12 @@ static void UI_StartServerRefresh(qboolean full)
{
int i;
char *ptr;
-
+ int time;
qtime_t q;
- trap_RealTime(&q);
+
+ time = trap_RealTime(&q);
+ trap_Cvar_Set( va("ui_lastServerRefresh_%i_time", ui_netSource.integer ),
+ va( "%i", time ) );
trap_Cvar_Set( va("ui_lastServerRefresh_%i", ui_netSource.integer),
va("%s-%i, %i at %i:%02i", MonthAbbrev[q.tm_mon],q.tm_mday, 1900+q.tm_year,q.tm_hour,q.tm_min));