Added a quick connect menu option which joins the client to the most populated server with a ping under 50. Mod/gamedir is not considered.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2448 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
8f14e5ab9f
commit
17962a3ac7
3 changed files with 107 additions and 4 deletions
|
@ -1499,10 +1499,101 @@ void M_Menu_ServerList2_f(void)
|
||||||
Master_SetSortField(SLKEY_PING, true);
|
Master_SetSortField(SLKEY_PING, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float quickconnecttimeout;
|
||||||
|
|
||||||
|
void M_QuickConnect_PreDraw(menu_t *menu)
|
||||||
|
{
|
||||||
|
serverinfo_t *best = NULL;
|
||||||
|
serverinfo_t *s;
|
||||||
|
NET_CheckPollSockets(); //see if we were told something important.
|
||||||
|
CL_QueryServers();
|
||||||
|
|
||||||
|
if (Sys_DoubleTime() > quickconnecttimeout)
|
||||||
|
{
|
||||||
|
for (s = firstserver; s; s = s->next)
|
||||||
|
{
|
||||||
|
if (!s->maxplayers) //no response?
|
||||||
|
continue;
|
||||||
|
if (s->players == s->maxplayers)
|
||||||
|
continue; //server is full already
|
||||||
|
if (s->special & SS_PROXY)
|
||||||
|
continue; //don't quickconnect to a proxy. thier player counts are often wrong (especially with qtv)
|
||||||
|
if (s->ping < 50) //don't like servers with too high a ping
|
||||||
|
{
|
||||||
|
if (s->players > 0)
|
||||||
|
{
|
||||||
|
if (best)
|
||||||
|
if (best->players > s->players)
|
||||||
|
continue; //go for the one with most players
|
||||||
|
best = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (best)
|
||||||
|
{
|
||||||
|
Con_Printf("Quick connect found %s (gamedir %s, players %i/%i, ping %ims)\n", best->name, best->gamedir, best->players, best->maxplayers, best->ping);
|
||||||
|
|
||||||
|
if (best->special & SS_NETQUAKE)
|
||||||
|
Cbuf_AddText(va("nqconnect %s\n", NET_AdrToString(best->adr)), RESTRICT_LOCAL);
|
||||||
|
else
|
||||||
|
Cbuf_AddText(va("join %s\n", NET_AdrToString(best->adr)), RESTRICT_LOCAL);
|
||||||
|
|
||||||
|
M_ToggleMenu_f();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//retry
|
||||||
|
MasterInfo_Begin();
|
||||||
|
|
||||||
|
quickconnecttimeout = Sys_DoubleTime() + 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qboolean M_QuickConnect_Key (int key, menu_t *menu)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void M_QuickConnect_Remove (menu_t *menu)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
qboolean M_QuickConnect_Cancel (menuoption_t *opt, menu_t *menu, int key)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void M_QuickConnect_DrawStatus (int x, int y, menucustom_t *ths, menu_t *menu)
|
||||||
|
{
|
||||||
|
Draw_String(x, y, va("Polling, %i secs\n", (int)(quickconnecttimeout - Sys_DoubleTime() + 0.9)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void M_QuickConnect_f(void)
|
||||||
|
{
|
||||||
|
menucustom_t *cust;
|
||||||
|
menu_t *menu;
|
||||||
|
|
||||||
|
key_dest = key_menu;
|
||||||
|
m_state = m_complex;
|
||||||
|
|
||||||
|
MasterInfo_Begin();
|
||||||
|
|
||||||
|
quickconnecttimeout = Sys_DoubleTime() + 5;
|
||||||
|
|
||||||
|
menu = M_CreateMenu(sizeof(serverlist_t));
|
||||||
|
menu->event = M_QuickConnect_PreDraw;
|
||||||
|
menu->key = M_QuickConnect_Key;
|
||||||
|
menu->remove = M_QuickConnect_Remove;
|
||||||
|
|
||||||
|
cust = MC_AddCustom(menu, 64, 64, NULL);
|
||||||
|
cust->draw = M_QuickConnect_DrawStatus;
|
||||||
|
cust->common.height = 8;
|
||||||
|
cust->common.width = vid.width-8;
|
||||||
|
|
||||||
|
MC_AddCommand(menu, 64, 128, "Refresh", SL_DoRefresh);
|
||||||
|
MC_AddCommand(menu, 64, 136, "Cancel", M_QuickConnect_Cancel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ void M_Menu_MultiPlayer_f (void)
|
||||||
|
|
||||||
menu->selecteditem = (menuoption_t*)
|
menu->selecteditem = (menuoption_t*)
|
||||||
MC_AddConsoleCommand (menu, 64, 40, "Join network server", "menu_slist\n");
|
MC_AddConsoleCommand (menu, 64, 40, "Join network server", "menu_slist\n");
|
||||||
|
MC_AddConsoleCommand (menu, 64, 40, "Quick Connect", "quickconnect qw\n");
|
||||||
MC_AddConsoleCommand (menu, 64, 48, "Start network server", "menu_newmulti\n");
|
MC_AddConsoleCommand (menu, 64, 48, "Start network server", "menu_newmulti\n");
|
||||||
MC_AddConsoleCommand (menu, 64, 56, "Player setup", "menu_setup\n");
|
MC_AddConsoleCommand (menu, 64, 56, "Player setup", "menu_setup\n");
|
||||||
MC_AddConsoleCommand (menu, 64, 64, "Demos", "menu_demo\n");
|
MC_AddConsoleCommand (menu, 64, 64, "Demos", "menu_demo\n");
|
||||||
|
@ -47,10 +48,11 @@ void M_Menu_MultiPlayer_f (void)
|
||||||
mgt=32;
|
mgt=32;
|
||||||
menu->selecteditem = (menuoption_t*)
|
menu->selecteditem = (menuoption_t*)
|
||||||
MC_AddConsoleCommandQBigFont (menu, 72, mgt, "Join A Game ", "menu_slist\n");mgt+=20;
|
MC_AddConsoleCommandQBigFont (menu, 72, mgt, "Join A Game ", "menu_slist\n");mgt+=20;
|
||||||
MC_AddConsoleCommandQBigFont (menu, 72, 52, "Old Browser ", "menu_serversold\n");mgt+=20;
|
MC_AddConsoleCommandQBigFont (menu, 72, mgt, "Quick Connect", "quickconnect qw\n");mgt+=20;
|
||||||
MC_AddConsoleCommandQBigFont (menu, 72, 72, "New Server ", "menu_newmulti\n");mgt+=20;
|
MC_AddConsoleCommandQBigFont (menu, 72, mgt, "Old Browser ", "menu_serversold\n");mgt+=20;
|
||||||
MC_AddConsoleCommandQBigFont (menu, 72, 92, "Player Setup", "menu_setup\n");mgt+=20;
|
MC_AddConsoleCommandQBigFont (menu, 72, mgt, "New Server ", "menu_newmulti\n");mgt+=20;
|
||||||
MC_AddConsoleCommandQBigFont (menu, 72, 112, "Demos ", "menu_demo\n");mgt+=20;
|
MC_AddConsoleCommandQBigFont (menu, 72, mgt, "Player Setup", "menu_setup\n");mgt+=20;
|
||||||
|
MC_AddConsoleCommandQBigFont (menu, 72, mgt, "Demos ", "menu_demo\n");mgt+=20;
|
||||||
|
|
||||||
menu->cursoritem = (menuoption_t*)MC_AddCursor(menu, 54, 32);
|
menu->cursoritem = (menuoption_t*)MC_AddCursor(menu, 54, 32);
|
||||||
return;
|
return;
|
||||||
|
@ -82,6 +84,11 @@ void M_Menu_MultiPlayer_f (void)
|
||||||
b->common.height = 20/2+2;
|
b->common.height = 20/2+2;
|
||||||
b->common.width = p?p->width:320;
|
b->common.width = p?p->width:320;
|
||||||
|
|
||||||
|
b = MC_AddConsoleCommand(menu, 72, 112, "", "quickconnect qw\n");
|
||||||
|
MC_AddWhiteText(menu, 72, 112+20/2-6, "Quick Connect", false);
|
||||||
|
b->common.height = 20/2+2;
|
||||||
|
b->common.width = p?p->width:320;
|
||||||
|
|
||||||
menu->cursoritem = (menuoption_t*)MC_AddCursor(menu, 54, 32);
|
menu->cursoritem = (menuoption_t*)MC_AddCursor(menu, 54, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -809,6 +809,7 @@ void M_Menu_Quit_f (void)
|
||||||
/* Menu Subsystem */
|
/* Menu Subsystem */
|
||||||
|
|
||||||
void M_Menu_ServerList2_f(void);
|
void M_Menu_ServerList2_f(void);
|
||||||
|
void M_QuickConnect_f(void);
|
||||||
|
|
||||||
void M_Menu_MediaFiles_f (void);
|
void M_Menu_MediaFiles_f (void);
|
||||||
void M_Menu_FPS_f (void);
|
void M_Menu_FPS_f (void);
|
||||||
|
@ -866,6 +867,8 @@ void M_Init_Internal (void)
|
||||||
#ifdef WEBCLIENT
|
#ifdef WEBCLIENT
|
||||||
Cmd_AddRemCommand ("menu_download", Menu_DownloadStuff_f);
|
Cmd_AddRemCommand ("menu_download", Menu_DownloadStuff_f);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Cmd_AddRemCommand ("quickconnect", M_QuickConnect_f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void M_DeInit_Internal (void)
|
void M_DeInit_Internal (void)
|
||||||
|
@ -909,6 +912,8 @@ void M_DeInit_Internal (void)
|
||||||
Cmd_RemoveCommand ("menu_particlesets");
|
Cmd_RemoveCommand ("menu_particlesets");
|
||||||
|
|
||||||
Cmd_RemoveCommand ("menu_download");
|
Cmd_RemoveCommand ("menu_download");
|
||||||
|
|
||||||
|
Cmd_RemoveCommand ("quickconnect");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FPS_Preset_f(void);
|
void FPS_Preset_f(void);
|
||||||
|
|
Loading…
Reference in a new issue