diff --git a/source/src/serverbrowser.cpp b/source/src/serverbrowser.cpp index bba64fdf..cd9cf79e 100644 --- a/source/src/serverbrowser.cpp +++ b/source/src/serverbrowser.cpp @@ -452,15 +452,28 @@ void checkpings() } } +VARP(serversort, 0, 0, 1); + int sicompare(serverinfo **ap, serverinfo **bp) { serverinfo *a = *ap, *b = *bp; if((a->protocol==PROTOCOL_VERSION) > (b->protocol==PROTOCOL_VERSION)) return -1; if((b->protocol==PROTOCOL_VERSION) > (a->protocol==PROTOCOL_VERSION)) return 1; - if(a->numplayers == 0 && b->numplayers > 0) return 1; - if(a->numplayers > 0 && b->numplayers == 0) return -1; - if(a->ping>b->ping) return 1; - if(a->pingping) return -1; + if(!a->numplayers && b->numplayers) return 1; + if(a->numplayers && !b->numplayers) return -1; + loopi(2) + { + if(serversort == i) + { + if(a->ping>b->ping) return 1; + if(a->pingping) return -1; + } + else + { + if(a->numplayers>b->numplayers) return 1; + if(a->numplayersnumplayers) return -1; + } + } int namecmp = strcmp(a->name, b->name); if(namecmp) return namecmp; if(a->port>b->port) return 1;