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

Method GetTutorialServer

src/engine/client/serverbrowser.cpp:1698–1724  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1696}
1697
1698const char *CServerBrowser::GetTutorialServer()
1699{
1700 const CCommunity *pCommunity = Community(COMMUNITY_DDNET);
1701 if(pCommunity == nullptr)
1702 return nullptr;
1703
1704 const char *pBestAddr = nullptr;
1705 int BestLatency = std::numeric_limits<int>::max();
1706 for(const auto &Country : pCommunity->Countries())
1707 {
1708 for(const auto &Server : Country.Servers())
1709 {
1710 if(str_comp(Server.TypeName(), "Tutorial") != 0)
1711 continue;
1712 const CServerEntry *pEntry = Find(Server.Address());
1713 if(!pEntry)
1714 continue;
1715 if(pEntry->m_Info.m_NumPlayers > pEntry->m_Info.m_MaxPlayers - 10)
1716 continue;
1717 if(pEntry->m_Info.m_Latency >= BestLatency)
1718 continue;
1719 BestLatency = pEntry->m_Info.m_Latency;
1720 pBestAddr = pEntry->m_Info.m_aAddress;
1721 }
1722 }
1723 return pBestAddr;
1724}
1725
1726bool CServerBrowser::IsRefreshing() const
1727{

Callers 2

RenderMethod · 0.80
RenderPopupFullscreenMethod · 0.80

Calls 3

str_compFunction · 0.85
TypeNameMethod · 0.45
AddressMethod · 0.45

Tested by

no test coverage detected