3#ifndef ENGINE_CLIENT_SERVERBROWSER_H
4#define ENGINE_CLIENT_SERVERBROWSER_H
14#include <unordered_map>
15#include <unordered_set>
117 CCommunityServer(
const char *pCommunityId,
const char *pCountryName,
const char *pTypeName)
132 void Add(
const char *pCommunityId)
override;
133 void Remove(
const char *pCommunityId)
override;
134 void Clear()
override;
135 bool Filtered(
const char *pCommunityId)
const override;
136 bool Empty()
const override;
137 void Clean(
const std::vector<CCommunity> &vAllowedCommunities);
139 const std::vector<CCommunityId> &
Entries()
const;
148 void Add(
const char *pCommunityId)
override;
149 void Remove(
const char *pCommunityId)
override;
150 void Clear()
override;
151 bool Filtered(
const char *pCommunityId)
const override;
152 bool Empty()
const override;
153 void Clean(
const std::vector<CCommunity> &vAllowedCommunities);
168 void Add(
const char *pCountryName)
override;
169 void Add(
const char *pCommunityId,
const char *pCountryName);
170 void Remove(
const char *pCountryName)
override;
171 void Remove(
const char *pCommunityId,
const char *pCountryName);
172 void Clear()
override;
173 bool Filtered(
const char *pCountryName)
const override;
174 bool Empty()
const override;
175 void Clean(
const std::vector<CCommunity> &vAllowedCommunities);
180 std::unordered_map<CCommunityId, std::unordered_set<CCommunityCountryName>>
m_Entries;
191 void Add(
const char *pTypeName)
override;
192 void Add(
const char *pCommunityId,
const char *pTypeName);
193 void Remove(
const char *pTypeName)
override;
194 void Remove(
const char *pCommunityId,
const char *pTypeName);
195 void Clear()
override;
196 bool Filtered(
const char *pTypeName)
const override;
197 bool Empty()
const override;
198 void Clean(
const std::vector<CCommunity> &vAllowedCommunities);
203 std::unordered_map<CCommunityId, std::unordered_set<CCommunityTypeName>>
m_Entries;
225 void Update(
bool Force)
override;
241 void Refresh(
int Type,
bool Force =
false)
override;
264 const std::vector<CCommunity> &
Communities()
const override;
const SHA256_DIGEST SHA256_ZEROED
Definition: hash.cpp:6
Definition: network.h:511
Definition: serverbrowser.h:235
int NumServers() const override
Definition: serverbrowser.h:247
CFavoriteCommunityFilterList & FavoriteCommunitiesFilter() override
Definition: serverbrowser.h:276
static void Con_RemoveExcludedType(IConsole::IResult *pResult, void *pUserData)
Definition: serverbrowser.cpp:195
CExcludedCommunityFilterList & CommunitiesFilter() override
Definition: serverbrowser.h:277
CExcludedCommunityCountryFilterList m_CountriesFilter
Definition: serverbrowser.h:331
int64_t m_BroadcastTime
Definition: serverbrowser.h:354
void OnServerInfoUpdate(const NETADDR &Addr, int Token, const CServerInfo *pInfo)
Definition: serverbrowser.cpp:880
static bool ParseCommunityServers(CCommunity *pCommunity, const json_value &Servers)
Definition: serverbrowser.cpp:1347
IFavorites * m_pFavorites
Definition: serverbrowser.h:308
static void Con_RemoveFavoriteCommunity(IConsole::IResult *pResult, void *pUserData)
Definition: serverbrowser.cpp:138
void RemoveRequest(CServerEntry *pEntry)
Definition: serverbrowser.cpp:642
bool IsGettingServerlist() const override
Definition: serverbrowser.cpp:1637
int Players(const CServerInfo &Item) const override
Definition: serverbrowser.cpp:308
CCommunityCache m_CommunityCache
Definition: serverbrowser.h:328
static void ConfigSaveCallback(IConfigManager *pConfigManager, void *pUserData)
Definition: serverbrowser.cpp:120
int m_ServerlistType
Definition: serverbrowser.h:353
void RequestCurrentServer(const NETADDR &Addr) const
Definition: serverbrowser.cpp:1062
bool SortCompareName(int Index1, int Index2) const
Definition: serverbrowser.cpp:345
int LoadingProgression() const override
Definition: serverbrowser.cpp:1642
void UpdateFromHttp()
Definition: serverbrowser.cpp:1077
int GenerateToken(const NETADDR &Addr) const
Definition: serverbrowser.cpp:325
SHA256_DIGEST DDNetInfoSha256() const override
Definition: serverbrowser.h:272
static void Con_LeakIpAddress(IConsole::IResult *pResult, void *pUserData)
Definition: serverbrowser.cpp:205
const CExcludedCommunityTypeFilterList & TypesFilter() const override
Definition: serverbrowser.h:283
void UpdateServerRank(CServerInfo *pInfo) const
Definition: serverbrowser.cpp:1598
void SetLatency(NETADDR Addr, int Latency)
Definition: serverbrowser.cpp:800
void LoadDDNetServers()
Definition: serverbrowser.cpp:1432
IConfigManager * m_pConfigManager
Definition: serverbrowser.h:304
void UpdateServerFriends(CServerInfo *pInfo) const
Definition: serverbrowser.cpp:1567
const char * m_pHttpPrevBestUrl
Definition: serverbrowser.h:316
int m_CurrentMaxRequests
Definition: serverbrowser.h:345
bool IsRefreshing() const override
Definition: serverbrowser.cpp:1632
int * m_pSortedServerlist
Definition: serverbrowser.h:320
void LoadDDNetLocation()
Definition: serverbrowser.cpp:1334
IServerBrowserPingCache * m_pPingCache
Definition: serverbrowser.h:315
bool IsRegistered(const NETADDR &Addr)
Definition: serverbrowser.cpp:2284
const CCommunity * Community(const char *pCommunityId) const override
Definition: serverbrowser.cpp:1679
const ICommunityCache & CommunityCache() const override
Definition: serverbrowser.h:275
void SetBaseInfo(class CNetClient *pClient, const char *pNetVersion)
Definition: serverbrowser.cpp:85
const CServerInfo * SortedGet(int Index) const override
Definition: serverbrowser.cpp:318
static bool ParseCommunityFinishes(CCommunity *pCommunity, const json_value &Finishes)
Definition: serverbrowser.cpp:1417
void CleanUp()
Definition: serverbrowser.cpp:1185
std::unordered_map< NETADDR, int > m_ByAddr
Definition: serverbrowser.h:321
int m_NumRequests
Definition: serverbrowser.h:339
CServerEntry * m_pFirstReqServer
Definition: serverbrowser.h:337
std::vector< CCommunity > m_vCommunities
Definition: serverbrowser.h:323
CServerEntry ** m_ppServerlist
Definition: serverbrowser.h:319
unsigned CurrentCommunitiesHash() const override
Definition: serverbrowser.cpp:1735
void UpdateServerCommunity(CServerInfo *pInfo) const
Definition: serverbrowser.cpp:1580
CFavoriteCommunityFilterList m_FavoriteCommunitiesFilter
Definition: serverbrowser.h:329
IFriends * m_pFriends
Definition: serverbrowser.h:307
void RegisterCommands()
Definition: serverbrowser.cpp:106
CServerEntry * m_pLastReqServer
Definition: serverbrowser.h:338
int m_NumSortedServers
Definition: serverbrowser.h:347
void Filter()
Definition: serverbrowser.cpp:413
int NumSortedPlayers() const override
Definition: serverbrowser.h:251
bool SortComparePing(int Index1, int Index2) const
Definition: serverbrowser.cpp:361
int NumSortedServers() const override
Definition: serverbrowser.h:250
void SetInfo(CServerEntry *pEntry, const CServerInfo &Info) const
Definition: serverbrowser.cpp:726
SHA256_DIGEST m_DDNetInfoSha256
Definition: serverbrowser.h:335
CServerEntry * Add(const NETADDR *pAddrs, int NumAddrs)
Definition: serverbrowser.cpp:836
IStorage * m_pStorage
Definition: serverbrowser.h:309
const std::vector< CCommunity > & Communities() const override
Definition: serverbrowser.cpp:1674
int m_NumSortedServersCapacity
Definition: serverbrowser.h:348
CExcludedCommunityTypeFilterList m_TypesFilter
Definition: serverbrowser.h:332
void RequestResort()
Definition: serverbrowser.h:245
CExcludedCommunityCountryFilterList & CountriesFilter() override
Definition: serverbrowser.h:278
bool SortCompareNumFriends(int Index1, int Index2) const
Definition: serverbrowser.cpp:389
bool SortCompareMap(int Index1, int Index2) const
Definition: serverbrowser.cpp:354
void RequestImpl(const NETADDR &Addr, CServerEntry *pEntry, int *pBasicToken, int *pToken, bool RandomToken) const
Definition: serverbrowser.cpp:1012
std::unordered_map< NETADDR, CCommunityServer > m_CommunityServersByAddr
Definition: serverbrowser.h:324
int SortHash() const
Definition: serverbrowser.cpp:595
std::vector< const CCommunity * > CurrentCommunities() const override
Definition: serverbrowser.cpp:1716
void RequestCurrentServerWithRandomToken(const NETADDR &Addr, int *pBasicToken, int *pToken) const
Definition: serverbrowser.cpp:1067
int m_NumSortedPlayers
Definition: serverbrowser.h:349
void Refresh(int Type, bool Force=false) override
Definition: serverbrowser.cpp:955
bool SortCompareNumClients(int Index1, int Index2) const
Definition: serverbrowser.cpp:382
static int GetBasicToken(int Token)
Definition: serverbrowser.cpp:335
void QueueRequest(CServerEntry *pEntry)
Definition: serverbrowser.cpp:672
void UpdateServerFilteredPlayers(CServerInfo *pInfo) const
Definition: serverbrowser.cpp:1554
void CleanFilters() override
Definition: serverbrowser.cpp:2273
bool DDNetInfoAvailable() const override
Definition: serverbrowser.h:271
virtual ~CServerBrowser()
Definition: serverbrowser.cpp:73
int Max(const CServerInfo &Item) const override
Definition: serverbrowser.cpp:313
IEngine * m_pEngine
Definition: serverbrowser.h:306
std::vector< const CCommunity * > SelectedCommunities() const override
Definition: serverbrowser.cpp:1687
static void Con_AddFavoriteCommunity(IConsole::IResult *pResult, void *pUserData)
Definition: serverbrowser.cpp:129
CNetClient * m_pNetClient
Definition: serverbrowser.h:303
const json_value * LoadDDNetInfo()
Definition: serverbrowser.cpp:1291
int m_NumServers
Definition: serverbrowser.h:350
char m_aNetVersion[128]
Definition: serverbrowser.h:311
static void Con_RemoveExcludedCountry(IConsole::IResult *pResult, void *pUserData)
Definition: serverbrowser.cpp:175
CExcludedCommunityTypeFilterList & TypesFilter() override
Definition: serverbrowser.h:279
bool SortCompareNumPlayersAndPing(int Index1, int Index2) const
Definition: serverbrowser.cpp:400
int m_NumServerCapacity
Definition: serverbrowser.h:351
const CExcludedCommunityCountryFilterList & CountriesFilter() const override
Definition: serverbrowser.h:282
const CFavoriteCommunityFilterList & FavoriteCommunitiesFilter() const override
Definition: serverbrowser.h:280
IHttp * m_pHttpClient
Definition: serverbrowser.h:310
json_value * m_pDDNetInfo
Definition: serverbrowser.h:334
void SetHttpInfo(const CServerInfo *pInfo)
int m_Sorthash
Definition: serverbrowser.h:342
bool m_NeedResort
Definition: serverbrowser.h:341
bool ValidateCountryName(const char *pCountryName) const
Definition: serverbrowser.cpp:298
const char * GetTutorialServer() override
Definition: serverbrowser.cpp:1604
void OnInit()
Definition: serverbrowser.cpp:101
void LoadDDNetInfoJson()
Definition: serverbrowser.cpp:1304
CServerBrowser()
Definition: serverbrowser.cpp:52
static void Con_RemoveExcludedCommunity(IConsole::IResult *pResult, void *pUserData)
Definition: serverbrowser.cpp:156
bool SortCompareNumPlayers(int Index1, int Index2) const
Definition: serverbrowser.cpp:375
CServerEntry * Find(const NETADDR &Addr) override
Definition: serverbrowser.cpp:662
CExcludedCommunityFilterList m_CommunitiesFilter
Definition: serverbrowser.h:330
IConsole * m_pConsole
Definition: serverbrowser.h:305
static void Con_AddExcludedCommunity(IConsole::IResult *pResult, void *pUserData)
Definition: serverbrowser.cpp:147
CHeap m_ServerlistHeap
Definition: serverbrowser.h:318
bool SortCompareGametype(int Index1, int Index2) const
Definition: serverbrowser.cpp:368
bool ValidateTypeName(const char *pTypeName) const
Definition: serverbrowser.cpp:303
static void Con_AddExcludedType(IConsole::IResult *pResult, void *pUserData)
Definition: serverbrowser.cpp:185
IServerBrowserHttp * m_pHttp
Definition: serverbrowser.h:314
bool m_RefreshingHttp
Definition: serverbrowser.h:313
void Update()
Definition: serverbrowser.cpp:1199
bool ValidateCommunityId(const char *pCommunityId) const
Definition: serverbrowser.cpp:293
void Sort()
Definition: serverbrowser.cpp:612
unsigned char m_aTokenSeed[16]
Definition: serverbrowser.h:355
void SetCurrentServerPing(const NETADDR &Addr, int Ping)
Definition: serverbrowser.cpp:1072
static int GetExtraToken(int Token)
Definition: serverbrowser.cpp:340
static void Con_AddExcludedCountry(IConsole::IResult *pResult, void *pUserData)
Definition: serverbrowser.cpp:165
ICommunityCache & CommunityCache() override
Definition: serverbrowser.h:274
int m_OwnLocation
Definition: serverbrowser.h:326
std::vector< const CCommunity * > FavoriteCommunities() const override
Definition: serverbrowser.cpp:1700
int GetCurrentType() override
Definition: serverbrowser.h:299
const CExcludedCommunityFilterList & CommunitiesFilter() const override
Definition: serverbrowser.h:281
Definition: serverbrowser.h:23
@ LOC_UNKNOWN
Definition: serverbrowser.h:27
@ MAX_COMMUNITY_ID_LENGTH
Definition: serverbrowser.h:59
@ MAX_COMMUNITY_TYPE_LENGTH
Definition: serverbrowser.h:61
@ MAX_COMMUNITY_COUNTRY_LENGTH
Definition: serverbrowser.h:60
Definition: favorites.h:14
Definition: serverbrowser.h:241
Definition: serverbrowser_http.h:11
Definition: serverbrowser_ping_cache.h:9
Definition: serverbrowser.h:302
Definition: serverbrowser.h:263
static constexpr const char * COMMUNITY_ALL
Definition: serverbrowser.h:322
@ NUM_TYPES
Definition: serverbrowser.h:295
struct _json_value json_value
Definition: serverbrowser.h:17
int str_comp(const char *a, const char *b)
Definition: system.cpp:2933
int str_copy(char *dst, const char *src, int dst_size)
Definition: system.cpp:2720
unsigned str_quickhash(const char *str)
Definition: system.cpp:4029