mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
sort by real players/clients
This commit is contained in:
parent
d1bf48f42c
commit
0809eefc1c
|
@ -252,8 +252,12 @@ void CServerBrowserFilter::CServerFilter::Sort()
|
|||
std::stable_sort(m_pSortedServerlist, m_pSortedServerlist+m_NumSortedServers, SortWrap(this, &CServerBrowserFilter::CServerFilter::SortCompareMap));
|
||||
break;
|
||||
case IServerBrowser::SORT_NUMPLAYERS:
|
||||
std::stable_sort(m_pSortedServerlist, m_pSortedServerlist+m_NumSortedServers, SortWrap(this,
|
||||
(m_FilterInfo.m_SortHash&IServerBrowser::FILTER_SPECTATORS) ? &CServerBrowserFilter::CServerFilter::SortCompareNumPlayers : &CServerBrowserFilter::CServerFilter::SortCompareNumClients));
|
||||
if(!(m_FilterInfo.m_SortHash&IServerBrowser::FILTER_BOTS))
|
||||
std::stable_sort(m_pSortedServerlist, m_pSortedServerlist+m_NumSortedServers, SortWrap(this,
|
||||
(m_FilterInfo.m_SortHash&IServerBrowser::FILTER_SPECTATORS) ? &CServerBrowserFilter::CServerFilter::SortCompareNumPlayers : &CServerBrowserFilter::CServerFilter::SortCompareNumClients));
|
||||
else
|
||||
std::stable_sort(m_pSortedServerlist, m_pSortedServerlist+m_NumSortedServers, SortWrap(this,
|
||||
(m_FilterInfo.m_SortHash&IServerBrowser::FILTER_SPECTATORS) ? &CServerBrowserFilter::CServerFilter::SortCompareNumRealPlayers : &CServerBrowserFilter::CServerFilter::SortCompareNumRealClients));
|
||||
break;
|
||||
case IServerBrowser::SORT_GAMETYPE:
|
||||
std::stable_sort(m_pSortedServerlist, m_pSortedServerlist+m_NumSortedServers, SortWrap(this, &CServerBrowserFilter::CServerFilter::SortCompareGametype));
|
||||
|
@ -302,6 +306,15 @@ bool CServerBrowserFilter::CServerFilter::SortCompareNumPlayers(int Index1, int
|
|||
(a->m_Info.m_NumPlayers == b->m_Info.m_NumPlayers && !(a->m_Info.m_Flags&IServerBrowser::FLAG_PURE) && (b->m_Info.m_Flags&IServerBrowser::FLAG_PURE));
|
||||
}
|
||||
|
||||
bool CServerBrowserFilter::CServerFilter::SortCompareNumRealPlayers(int Index1, int Index2) const
|
||||
{
|
||||
CServerEntry *a = m_pServerBrowserFilter->m_ppServerlist[Index1];
|
||||
CServerEntry *b = m_pServerBrowserFilter->m_ppServerlist[Index2];
|
||||
// are ia allowed in vanilla ?
|
||||
return (a->m_Info.m_NumPlayers - a->m_Info.m_NumBotPlayers) < (b->m_Info.m_NumPlayers - b->m_Info.m_NumBotPlayers) ||
|
||||
((a->m_Info.m_NumPlayers - a->m_Info.m_NumBotPlayers) == (b->m_Info.m_NumPlayers - b->m_Info.m_NumBotPlayers) && !(a->m_Info.m_Flags&IServerBrowser::FLAG_PURE) && (b->m_Info.m_Flags&IServerBrowser::FLAG_PURE));
|
||||
}
|
||||
|
||||
bool CServerBrowserFilter::CServerFilter::SortCompareNumClients(int Index1, int Index2) const
|
||||
{
|
||||
CServerEntry *a = m_pServerBrowserFilter->m_ppServerlist[Index1];
|
||||
|
@ -310,6 +323,15 @@ bool CServerBrowserFilter::CServerFilter::SortCompareNumClients(int Index1, int
|
|||
(a->m_Info.m_NumClients == b->m_Info.m_NumClients && !(a->m_Info.m_Flags&IServerBrowser::FLAG_PURE) && (b->m_Info.m_Flags&IServerBrowser::FLAG_PURE));
|
||||
}
|
||||
|
||||
bool CServerBrowserFilter::CServerFilter::SortCompareNumRealClients(int Index1, int Index2) const
|
||||
{
|
||||
CServerEntry *a = m_pServerBrowserFilter->m_ppServerlist[Index1];
|
||||
CServerEntry *b = m_pServerBrowserFilter->m_ppServerlist[Index2];
|
||||
// are ia allowed in vanilla ? in spec ?
|
||||
return (a->m_Info.m_NumClients - a->m_Info.m_NumBotPlayers - a->m_Info.m_NumBotSpectators) < (b->m_Info.m_NumClients - b->m_Info.m_NumBotPlayers - b->m_Info.m_NumBotSpectators) ||
|
||||
((a->m_Info.m_NumClients - a->m_Info.m_NumBotPlayers - a->m_Info.m_NumBotSpectators) < (b->m_Info.m_NumClients - b->m_Info.m_NumBotPlayers - b->m_Info.m_NumBotSpectators) && !(a->m_Info.m_Flags&IServerBrowser::FLAG_PURE) && (b->m_Info.m_Flags&IServerBrowser::FLAG_PURE));
|
||||
}
|
||||
|
||||
// CServerBrowserFilter
|
||||
void CServerBrowserFilter::Init(IFriends *pFriends, const char *pNetVersion)
|
||||
{
|
||||
|
|
|
@ -42,7 +42,9 @@ public:
|
|||
bool SortComparePing(int Index1, int Index2) const;
|
||||
bool SortCompareGametype(int Index1, int Index2) const;
|
||||
bool SortCompareNumPlayers(int Index1, int Index2) const;
|
||||
bool SortCompareNumRealPlayers(int Index1, int Index2) const;
|
||||
bool SortCompareNumClients(int Index1, int Index2) const;
|
||||
bool SortCompareNumRealClients(int Index1, int Index2) const;
|
||||
};
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue