create serverbrowser entry only after broadcast token check

This commit is contained in:
Andrii 2020-09-03 02:51:33 +03:00
parent 197fe955e1
commit 836c56aeb5

View file

@ -596,7 +596,25 @@ void CServerBrowser::Set(const NETADDR &Addr, int Type, int Token, const CServer
} }
pEntry = Find(Addr); pEntry = Find(Addr);
if(m_ServerlistType != IServerBrowser::TYPE_LAN)
if(m_ServerlistType == IServerBrowser::TYPE_LAN)
{
NETADDR Broadcast;
mem_zero(&Broadcast, sizeof(Broadcast));
Broadcast.type = m_pNetClient->NetType()|NETTYPE_LINK_BROADCAST;
int Token = GenerateToken(Broadcast);
bool Drop = false;
Drop = Drop || BasicToken != GetBasicToken(Token);
Drop = Drop || (pInfo->m_Type == SERVERINFO_EXTENDED && ExtraToken != GetExtraToken(Token));
if(Drop)
{
return;
}
if(!pEntry)
pEntry = Add(Addr);
}
else
{ {
if(!pEntry) if(!pEntry)
{ {
@ -611,34 +629,16 @@ void CServerBrowser::Set(const NETADDR &Addr, int Type, int Token, const CServer
return; return;
} }
} }
if(!pEntry)
pEntry = Add(Addr); SetInfo(pEntry, *pInfo);
if(pEntry) if (m_ServerlistType == IServerBrowser::TYPE_LAN)
pEntry->m_Info.m_Latency = minimum(static_cast<int>((time_get()-m_BroadcastTime)*1000/time_freq()), 999);
else if (pEntry->m_RequestTime > 0)
{ {
if(m_ServerlistType == IServerBrowser::TYPE_LAN) pEntry->m_Info.m_Latency = minimum(static_cast<int>((time_get()-pEntry->m_RequestTime)*1000/time_freq()), 999);
{ pEntry->m_RequestTime = -1; // Request has been answered
NETADDR Broadcast;
mem_zero(&Broadcast, sizeof(Broadcast));
Broadcast.type = m_pNetClient->NetType()|NETTYPE_LINK_BROADCAST;
int Token = GenerateToken(Broadcast);
bool Drop = false;
Drop = Drop || BasicToken != GetBasicToken(Token);
Drop = Drop || (pInfo->m_Type == SERVERINFO_EXTENDED && ExtraToken != GetExtraToken(Token));
if(Drop)
{
return;
}
}
SetInfo(pEntry, *pInfo);
if (m_ServerlistType == IServerBrowser::TYPE_LAN)
pEntry->m_Info.m_Latency = minimum(static_cast<int>((time_get()-m_BroadcastTime)*1000/time_freq()), 999);
else if (pEntry->m_RequestTime > 0)
{
pEntry->m_Info.m_Latency = minimum(static_cast<int>((time_get()-pEntry->m_RequestTime)*1000/time_freq()), 999);
pEntry->m_RequestTime = -1; // Request has been answered
}
RemoveRequest(pEntry);
} }
RemoveRequest(pEntry);
} }
Sort(); Sort();