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

Method Add

src/engine/client/serverbrowser.cpp:836–871  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

834}
835
836CServerBrowser::CServerEntry *CServerBrowser::Add(const NETADDR *pAddrs, int NumAddrs)
837{
838 // create new pEntry
839 CServerEntry *pEntry = m_ServerlistHeap.Allocate<CServerEntry>();
840 mem_zero(pEntry, sizeof(CServerEntry));
841
842 // set the info
843 mem_copy(pEntry->m_Info.m_aAddresses, pAddrs, NumAddrs * sizeof(pAddrs[0]));
844 pEntry->m_Info.m_NumAddresses = NumAddrs;
845
846 pEntry->m_Info.m_Latency = 999;
847 pEntry->m_Info.m_HasRank = CServerInfo::RANK_UNAVAILABLE;
848 ServerBrowserFormatAddresses(pEntry->m_Info.m_aAddress, sizeof(pEntry->m_Info.m_aAddress), pEntry->m_Info.m_aAddresses, pEntry->m_Info.m_NumAddresses);
849 UpdateServerCommunity(&pEntry->m_Info);
850 str_copy(pEntry->m_Info.m_aName, pEntry->m_Info.m_aAddress, sizeof(pEntry->m_Info.m_aName));
851
852 // check if it's a favorite
853 pEntry->m_Info.m_Favorite = m_pFavorites->IsFavorite(pEntry->m_Info.m_aAddresses, pEntry->m_Info.m_NumAddresses);
854 pEntry->m_Info.m_FavoriteAllowPing = m_pFavorites->IsPingAllowed(pEntry->m_Info.m_aAddresses, pEntry->m_Info.m_NumAddresses);
855
856 int ServerIndex = m_vpServerlist.size();
857 for(int i = 0; i < NumAddrs; i++)
858 {
859 m_ByAddr[pAddrs[i]] = ServerIndex;
860 }
861
862 // add to list
863 pEntry->m_Info.m_ServerIndex = ServerIndex;
864 if(m_vpServerlist.capacity() == 0)
865 {
866 m_vpServerlist.reserve(128);
867 }
868 m_vpServerlist.push_back(pEntry);
869
870 return pEntry;
871}
872
873CServerBrowser::CServerEntry *CServerBrowser::ReplaceEntry(CServerEntry *pEntry, const NETADDR *pAddrs, int NumAddrs)
874{

Callers 4

Con_AddExcludedTypeMethod · 0.45

Calls 11

mem_zeroFunction · 0.85
mem_copyFunction · 0.85
IsSubsetEqualsFunction · 0.85
IsPingAllowedMethod · 0.80
beginMethod · 0.80
CountryTypeFilterKeyMethod · 0.80
endMethod · 0.80
str_copyFunction · 0.50
IsFavoriteMethod · 0.45
NameMethod · 0.45

Tested by

no test coverage detected