2713: allow empty max ping filter r=heinrich5991 a=BannZay

The inconvenieces I discovered so far:
1. You got to write 999 to "disable" this filter
2. If you try to clear this field and then type 75 then the field will contain 750 because the last zero is bugged at this point
Those are fixed

What I would like to be fixed as well (not sure if I gona do this soon):
1. Update browser servers live without refreshing. You press refresh - you receives all the servers and then you should be able (but currently not) to filter them out without pressing on "Refresh" button again but just by changing the max ping value

Co-authored-by: Andrii <bannzay3@gmail.com>
This commit is contained in:
bors[bot] 2020-09-03 00:37:47 +00:00 committed by GitHub
commit dac3c782d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View file

@ -218,7 +218,7 @@ void CServerBrowser::Filter()
{
Filtered = 1;
}
else if(g_Config.m_BrFilterPing < m_ppServerlist[i]->m_Info.m_Latency)
else if(g_Config.m_BrFilterPing && g_Config.m_BrFilterPing < m_ppServerlist[i]->m_Info.m_Latency)
Filtered = 1;
else if(g_Config.m_BrFilterCompatversion && str_comp_num(m_ppServerlist[i]->m_Info.m_aVersion, m_aNetVersion, 3) != 0)
Filtered = 1;

View file

@ -614,8 +614,9 @@ void CMenus::RenderServerbrowserFilters(CUIRect View)
UI()->DoLabelScaled(&Button, Localize("Maximum ping:"), FontSize, -1);
char aBuf[5];
str_format(aBuf, sizeof(aBuf), "%d", g_Config.m_BrFilterPing);
char aBuf[5] = "";
if(g_Config.m_BrFilterPing != 0)
str_format(aBuf, sizeof(aBuf), "%d", g_Config.m_BrFilterPing);
static float Offset = 0.0f;
DoEditBox(&g_Config.m_BrFilterPing, &EditBox, aBuf, sizeof(aBuf), FontSize, &Offset);
g_Config.m_BrFilterPing = clamp(str_toint(aBuf), 0, 999);