mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
Sorted server list, sl_sortby 0 = by name, sl_sortby 1 = by ping
This commit is contained in:
parent
aa825853bf
commit
75fe232052
1 changed files with 47 additions and 2 deletions
|
@ -50,6 +50,7 @@
|
||||||
#ifdef HAVE_WINDOWS_H
|
#ifdef HAVE_WINDOWS_H
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "QF/cmd.h"
|
#include "QF/cmd.h"
|
||||||
|
@ -68,9 +69,11 @@ server_entry_t *slist;
|
||||||
server_entry_t *all_slist;
|
server_entry_t *all_slist;
|
||||||
server_entry_t *fav_slist;
|
server_entry_t *fav_slist;
|
||||||
int which_slist;
|
int which_slist;
|
||||||
|
|
||||||
int slist_last_details;
|
int slist_last_details;
|
||||||
|
|
||||||
|
cvar_t *sl_sortby;
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
S_Refresh (server_entry_t *slrefresh)
|
S_Refresh (server_entry_t *slrefresh)
|
||||||
{
|
{
|
||||||
|
@ -359,12 +362,52 @@ void timepassed (double time1, double *time2)
|
||||||
*time2 -= time1;
|
*time2 -= time1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SL_Sort (server_entry_t *sort)
|
||||||
|
{
|
||||||
|
server_entry_t *p;
|
||||||
|
server_entry_t *q;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
if (!sort)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (p = sort; p->next; p = p->next)
|
||||||
|
{
|
||||||
|
for (q = p->next; q; q = q->next)
|
||||||
|
{
|
||||||
|
if (sl_sortby->int_val)
|
||||||
|
{
|
||||||
|
if ((q->pongback) && (p->pongback > q->pongback))
|
||||||
|
{
|
||||||
|
SL_Swap(p,q);
|
||||||
|
q = p;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
i = 0;
|
||||||
|
while ((p->desc[i] != '\0') && (q->desc[i] != '\0') && (toupper(p->desc[i]) == toupper(q->desc[i])))
|
||||||
|
i++;
|
||||||
|
if (toupper(p->desc[i]) > toupper(q->desc[i]))
|
||||||
|
{
|
||||||
|
Con_Printf("%i <-> %s <-> %s\n", i, p->desc, q->desc);
|
||||||
|
SL_Swap(p,q);
|
||||||
|
q = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SL_Con_List (server_entry_t *sldata)
|
SL_Con_List (server_entry_t *sldata)
|
||||||
{
|
{
|
||||||
int serv;
|
int serv;
|
||||||
server_entry_t *cp;
|
server_entry_t *cp;
|
||||||
|
|
||||||
|
SL_Sort (sldata);
|
||||||
|
|
||||||
for(serv = 0; serv < SL_Len (sldata); serv++)
|
for(serv = 0; serv < SL_Len (sldata); serv++)
|
||||||
{
|
{
|
||||||
cp = SL_Get_By_Num (sldata, serv);
|
cp = SL_Get_By_Num (sldata, serv);
|
||||||
|
@ -554,6 +597,8 @@ void SList_Init (void)
|
||||||
all_slist = NULL;
|
all_slist = NULL;
|
||||||
which_slist = 0;
|
which_slist = 0;
|
||||||
Cmd_AddCommand("slist",SL_Command,"console commands to access server list\n");
|
Cmd_AddCommand("slist",SL_Command,"console commands to access server list\n");
|
||||||
|
sl_sortby = Cvar_Get ("sl_sortby", "0", CVAR_ARCHIVE, NULL, "0 = sort by name, 1 = sort by ping");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in a new issue