MCPcopy Create free account
hub / github.com/ddnet/ddnet / SetLatency

Method SetLatency

src/engine/client/serverbrowser.cpp:800–834  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

798}
799
800void CServerBrowser::SetLatency(NETADDR Addr, int Latency)
801{
802 m_pPingCache->CachePing(Addr, Latency);
803
804 Addr.port = 0;
805 for(CServerEntry *pEntry : m_vpServerlist)
806 {
807 if(!pEntry->m_GotInfo)
808 {
809 continue;
810 }
811 bool Found = false;
812 for(int i = 0; i < pEntry->m_Info.m_NumAddresses; i++)
813 {
814 NETADDR Other = pEntry->m_Info.m_aAddresses[i];
815 Other.port = 0;
816 if(Addr == Other)
817 {
818 Found = true;
819 break;
820 }
821 }
822 if(!Found)
823 {
824 continue;
825 }
826 int Ping = m_pPingCache->GetPing(pEntry->m_Info.m_aAddresses, pEntry->m_Info.m_NumAddresses);
827 if(Ping == -1)
828 {
829 continue;
830 }
831 pEntry->m_Info.m_Latency = Ping;
832 pEntry->m_Info.m_LatencyIsEstimated = false;
833 }
834}
835
836CServerBrowser::CServerEntry *CServerBrowser::Add(const NETADDR *pAddrs, int NumAddrs)
837{

Callers

nothing calls this directly

Calls 2

CachePingMethod · 0.80
GetPingMethod · 0.80

Tested by

no test coverage detected