mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 06:28:19 +00:00
Fix #1350
This commit is contained in:
parent
5b436adff8
commit
faf388b853
|
@ -147,7 +147,7 @@ bool CServerBrowser::SortCompareNumPlayers(int Index1, int Index2) const
|
|||
{
|
||||
CServerEntry *a = m_ppServerlist[Index1];
|
||||
CServerEntry *b = m_ppServerlist[Index2];
|
||||
return FilteredPlayers(a->m_Info) < FilteredPlayers(b->m_Info);
|
||||
return a->m_Info.m_NumFilteredPlayers < b->m_Info.m_NumFilteredPlayers;
|
||||
}
|
||||
|
||||
bool CServerBrowser::SortCompareNumClients(int Index1, int Index2) const
|
||||
|
@ -157,32 +157,6 @@ bool CServerBrowser::SortCompareNumClients(int Index1, int Index2) const
|
|||
return a->m_Info.m_NumClients < b->m_Info.m_NumClients;
|
||||
}
|
||||
|
||||
int CServerBrowser::FilteredPlayers(const CServerInfo &Item) const
|
||||
{
|
||||
int NumPlayers = 0;
|
||||
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
const CServerInfo::CClient &Client = Item.m_aClients[i];
|
||||
|
||||
if(Client.m_aName[0] == '\0')
|
||||
continue;
|
||||
|
||||
if(g_Config.m_BrFilterSpectators && !Client.m_Player)
|
||||
continue;
|
||||
|
||||
if(g_Config.m_BrFilterFriends && Client.m_FriendState == IFriends::FRIEND_NO)
|
||||
continue;
|
||||
|
||||
if(g_Config.m_BrFilterConnectingPlayers && str_comp(Client.m_aName, "(connecting)") == 0 && Client.m_aClan[0] == '\0' && Client.m_Country == -1 && Client.m_Score == 0)
|
||||
continue;
|
||||
|
||||
NumPlayers++;
|
||||
}
|
||||
|
||||
return NumPlayers;
|
||||
}
|
||||
|
||||
void CServerBrowser::Filter()
|
||||
{
|
||||
int i = 0, p = 0;
|
||||
|
@ -202,7 +176,7 @@ void CServerBrowser::Filter()
|
|||
{
|
||||
int Filtered = 0;
|
||||
|
||||
if(g_Config.m_BrFilterEmpty && FilteredPlayers(m_ppServerlist[i]->m_Info) == 0)
|
||||
if(g_Config.m_BrFilterEmpty && m_ppServerlist[i]->m_Info.m_NumFilteredPlayers == 0)
|
||||
Filtered = 1;
|
||||
else if(g_Config.m_BrFilterFull && Players(m_ppServerlist[i]->m_Info) == Max(m_ppServerlist[i]->m_Info))
|
||||
Filtered = 1;
|
||||
|
@ -360,10 +334,37 @@ int CServerBrowser::SortHash() const
|
|||
return i;
|
||||
}
|
||||
|
||||
void SetFilteredPlayers(const CServerInfo &Item)
|
||||
{
|
||||
Item.m_NumFilteredPlayers = 0;
|
||||
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
const CServerInfo::CClient &Client = Item.m_aClients[i];
|
||||
|
||||
if(Client.m_aName[0] == '\0')
|
||||
continue;
|
||||
|
||||
if(g_Config.m_BrFilterSpectators && !Client.m_Player)
|
||||
continue;
|
||||
|
||||
if(g_Config.m_BrFilterConnectingPlayers && str_comp(Client.m_aName, "(connecting)") == 0 && Client.m_aClan[0] == '\0' && Client.m_Country == -1 && Client.m_Score == 0)
|
||||
continue;
|
||||
|
||||
Item.m_NumFilteredPlayers++;
|
||||
}
|
||||
}
|
||||
|
||||
void CServerBrowser::Sort()
|
||||
{
|
||||
int i;
|
||||
|
||||
// fill m_NumFilteredPlayers
|
||||
for(i = 0; i < m_NumServers; i++)
|
||||
{
|
||||
SetFilteredPlayers(m_ppServerlist[i]->m_Info);
|
||||
}
|
||||
|
||||
// create filtered list
|
||||
Filter();
|
||||
|
||||
|
|
|
@ -68,8 +68,6 @@ public:
|
|||
|
||||
int NumServers() const { return m_NumServers; }
|
||||
|
||||
int FilteredPlayers(const CServerInfo &Item) const;
|
||||
|
||||
int Players(const CServerInfo &Item) const
|
||||
{
|
||||
return g_Config.m_BrFilterSpectators ? Item.m_NumPlayers : Item.m_NumClients;
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
char m_aVersion[32];
|
||||
char m_aAddress[NETADDR_MAXSTRSIZE];
|
||||
CClient m_aClients[MAX_CLIENTS];
|
||||
mutable int m_NumFilteredPlayers;
|
||||
};
|
||||
|
||||
bool IsVanilla(const CServerInfo *pInfo);
|
||||
|
@ -116,7 +117,6 @@ public:
|
|||
|
||||
virtual int NumServers() const = 0;
|
||||
|
||||
virtual int FilteredPlayers(const CServerInfo &Item) const = 0;
|
||||
virtual int Players(const CServerInfo &Item) const = 0;
|
||||
virtual int Max(const CServerInfo &Item) const = 0;
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
|||
{
|
||||
int ItemIndex = i;
|
||||
const CServerInfo *pItem = ServerBrowser()->SortedGet(ItemIndex);
|
||||
NumPlayers += ServerBrowser()->FilteredPlayers(*pItem);
|
||||
NumPlayers += pItem->m_NumFilteredPlayers;
|
||||
CUIRect Row;
|
||||
CUIRect SelectHitBox;
|
||||
|
||||
|
@ -407,7 +407,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
|||
DoButton_Icon(IMAGE_BROWSEICONS, SPRITE_BROWSE_HEART, &Icon);
|
||||
}
|
||||
|
||||
str_format(aTemp, sizeof(aTemp), "%i/%i", ServerBrowser()->FilteredPlayers(*pItem), ServerBrowser()->Max(*pItem));
|
||||
str_format(aTemp, sizeof(aTemp), "%i/%i", pItem->m_NumFilteredPlayers, ServerBrowser()->Max(*pItem));
|
||||
if(g_Config.m_BrFilterString[0] && (pItem->m_QuickSearchHit&IServerBrowser::QUICK_PLAYER))
|
||||
TextRender()->TextColor(0.4f,0.4f,1.0f,1);
|
||||
UI()->DoLabelScaled(&Button, aTemp, 12.0f, 1);
|
||||
|
|
Loading…
Reference in a new issue