mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 12:31:54 +00:00
"Recommended" server sorting option
Sorts by reverse player count, with 0-player servers sitting empty at the far end. Breaks ties with ping instead of strcmp.
This commit is contained in:
parent
000e6e273c
commit
b009ab3c23
2 changed files with 47 additions and 8 deletions
|
|
@ -540,13 +540,14 @@ consvar_t cv_server_contact = Server("server_contact", "").onchange_noinit(Updat
|
||||||
consvar_t cv_servername = Server("servername", "Ring Racers server").onchange_noinit(Update_parameters);
|
consvar_t cv_servername = Server("servername", "Ring Racers server").onchange_noinit(Update_parameters);
|
||||||
|
|
||||||
void M_SortServerList(void);
|
void M_SortServerList(void);
|
||||||
consvar_t cv_serversort = Server("serversort", "Ping").dont_save().onchange(M_SortServerList).values({
|
consvar_t cv_serversort = Server("serversort", "Recommended").dont_save().onchange(M_SortServerList).values({
|
||||||
{0,"Ping"},
|
{-1, "Recommended"},
|
||||||
{1,"AVG. Power Level"},
|
{ 0, "Ping"},
|
||||||
{2,"Most Players"},
|
{ 1, "AVG. Power Level"},
|
||||||
{3,"Least Players"},
|
{ 2, "Most Players"},
|
||||||
{4,"Max Player Slots"},
|
{ 3, "Least Players"},
|
||||||
{5,"Gametype"},
|
{ 4, "Max Player Slots"},
|
||||||
|
{ 5, "Gametype"},
|
||||||
});
|
});
|
||||||
|
|
||||||
// show your ping on the HUD next to framerate. Defaults to warning only (shows up if your ping is > maxping)
|
// show your ping on the HUD next to framerate. Defaults to warning only (shows up if your ping is > maxping)
|
||||||
|
|
|
||||||
|
|
@ -338,13 +338,51 @@ static int ServerListEntryComparator_gametypename(const void *entry1, const void
|
||||||
int c;
|
int c;
|
||||||
if (( c = strcasecmp(sa->info.gametypename, sb->info.gametypename) ))
|
if (( c = strcasecmp(sa->info.gametypename, sb->info.gametypename) ))
|
||||||
return c;
|
return c;
|
||||||
return strcmp(sa->info.servername, sb->info.servername); \
|
return strcmp(sa->info.servername, sb->info.servername);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ServerListEntryComparator_recommended(const void *entry1, const void *entry2)
|
||||||
|
{
|
||||||
|
const serverelem_t *sa = (const serverelem_t*)entry1, *sb = (const serverelem_t*)entry2;
|
||||||
|
|
||||||
|
INT32 saseedval = sa->info.numberofplayer;
|
||||||
|
INT32 sbseedval = sb->info.numberofplayer;
|
||||||
|
|
||||||
|
// Tyron wrote the following on 25072022:
|
||||||
|
// "sort should be two parts
|
||||||
|
// top part of the list is "all non-empty servers sorted by reverse playercount", with servers above a certain reported ping marked as bad connection or whatever
|
||||||
|
// bottom part of the list is all empty servers sorted by ping"
|
||||||
|
// toast is implementing on 27082023, over a year later, because
|
||||||
|
// "fixing server join flow" is saner to do near the end
|
||||||
|
|
||||||
|
{
|
||||||
|
const UINT8 SERVER_EMPTY = 1;
|
||||||
|
|
||||||
|
// The intent with this nudge is to show you
|
||||||
|
// good games you could get a memorable Duel in,
|
||||||
|
// with the possibility to really katamari into
|
||||||
|
// something more substantial.
|
||||||
|
// By comparison, empty games are not nearly as
|
||||||
|
// fun to get going, so let's lower their SEO.
|
||||||
|
if (!saseedval)
|
||||||
|
saseedval = MAXPLAYERS + SERVER_EMPTY;
|
||||||
|
if (!sbseedval)
|
||||||
|
sbseedval = MAXPLAYERS + SERVER_EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (saseedval != sbseedval)
|
||||||
|
return saseedval - sbseedval;
|
||||||
|
|
||||||
|
return sa->info.time - sb->info.time;
|
||||||
}
|
}
|
||||||
|
|
||||||
void M_SortServerList(void)
|
void M_SortServerList(void)
|
||||||
{
|
{
|
||||||
switch(cv_serversort.value)
|
switch(cv_serversort.value)
|
||||||
{
|
{
|
||||||
|
case -1:
|
||||||
|
qsort(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_recommended);
|
||||||
|
break;
|
||||||
case 0: // Ping.
|
case 0: // Ping.
|
||||||
qsort(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_time);
|
qsort(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_time);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue