3181: Fix combined player/ping sorting function r=def- a=trml

Fixes #3109.

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: trml <trml@users.noreply.github.com>
This commit is contained in:
bors[bot] 2020-10-24 06:35:17 +00:00 committed by GitHub
commit 414f3d2ea4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -170,10 +170,10 @@ bool CServerBrowser::SortCompareNumPlayersAndPing(int Index1, int Index2) const
if(a->m_Info.m_NumFilteredPlayers == b->m_Info.m_NumFilteredPlayers) if(a->m_Info.m_NumFilteredPlayers == b->m_Info.m_NumFilteredPlayers)
return a->m_Info.m_Latency > b->m_Info.m_Latency; return a->m_Info.m_Latency > b->m_Info.m_Latency;
if(a->m_Info.m_NumFilteredPlayers == 0 || b->m_Info.m_NumFilteredPlayers == 0) else if(a->m_Info.m_NumFilteredPlayers == 0 || b->m_Info.m_NumFilteredPlayers == 0 || a->m_Info.m_Latency / 100 == b->m_Info.m_Latency / 100)
return a->m_Info.m_NumFilteredPlayers == 0; return a->m_Info.m_NumFilteredPlayers < b->m_Info.m_NumFilteredPlayers;
else else
return a->m_Info.m_NumFilteredPlayers - (a->m_Info.m_Latency / 100) * MAX_CLIENTS < b->m_Info.m_NumFilteredPlayers - (b->m_Info.m_Latency / 100) * MAX_CLIENTS; return a->m_Info.m_Latency > b->m_Info.m_Latency;
} }
void CServerBrowser::Filter() void CServerBrowser::Filter()