DDraceNetwork Docs
serverbrowser.h
Go to the documentation of this file.
1/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2/* If you are missing that file, acquire a complete release at teeworlds.com. */
3#ifndef ENGINE_CLIENT_SERVERBROWSER_H
4#define ENGINE_CLIENT_SERVERBROWSER_H
5
6#include <base/hash.h>
7#include <base/system.h>
8
9#include <engine/console.h>
12
13#include <functional>
14#include <unordered_map>
15#include <unordered_set>
16
17typedef struct _json_value json_value;
18class CNetClient;
19class IConfigManager;
20class IConsole;
21class IEngine;
22class IFavorites;
23class IFriends;
26class IStorage;
27class IHttp;
28
30{
32
33public:
34 CCommunityId(const char *pCommunityId)
35 {
36 str_copy(m_aId, pCommunityId);
37 }
38
39 const char *Id() const { return m_aId; }
40
41 bool operator==(const CCommunityId &Other) const
42 {
43 return str_comp(Id(), Other.Id()) == 0;
44 }
45};
46
47template<>
48struct std::hash<CCommunityId>
49{
50 size_t operator()(const CCommunityId &Elem) const noexcept
51 {
52 return str_quickhash(Elem.Id());
53 }
54};
55
57{
59
60public:
61 CCommunityCountryName(const char *pCountryName)
62 {
63 str_copy(m_aName, pCountryName);
64 }
65
66 const char *Name() const { return m_aName; }
67
68 bool operator==(const CCommunityCountryName &Other) const
69 {
70 return str_comp(Name(), Other.Name()) == 0;
71 }
72};
73
74template<>
75struct std::hash<CCommunityCountryName>
76{
77 size_t operator()(const CCommunityCountryName &Elem) const noexcept
78 {
79 return str_quickhash(Elem.Name());
80 }
81};
82
84{
86
87public:
88 CCommunityTypeName(const char *pTypeName)
89 {
90 str_copy(m_aName, pTypeName);
91 }
92
93 const char *Name() const { return m_aName; }
94
95 bool operator==(const CCommunityTypeName &Other) const
96 {
97 return str_comp(Name(), Other.Name()) == 0;
98 }
99};
100
101template<>
102struct std::hash<CCommunityTypeName>
103{
104 size_t operator()(const CCommunityTypeName &Elem) const noexcept
105 {
106 return str_quickhash(Elem.Name());
107 }
108};
109
111{
115
116public:
117 CCommunityServer(const char *pCommunityId, const char *pCountryName, const char *pTypeName)
118 {
119 str_copy(m_aCommunityId, pCommunityId);
120 str_copy(m_aCountryName, pCountryName);
121 str_copy(m_aTypeName, pTypeName);
122 }
123
124 const char *CommunityId() const { return m_aCommunityId; }
125 const char *CountryName() const { return m_aCountryName; }
126 const char *TypeName() const { return m_aTypeName; }
127};
128
130{
131public:
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);
138 void Save(IConfigManager *pConfigManager) const;
139 const std::vector<CCommunityId> &Entries() const;
140
141private:
142 std::vector<CCommunityId> m_vEntries;
143};
144
146{
147public:
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);
154 void Save(IConfigManager *pConfigManager) const;
155
156private:
157 std::unordered_set<CCommunityId> m_Entries;
158};
159
161{
162public:
164 m_pCommunityCache(pCommunityCache)
165 {
166 }
167
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);
176 void Save(IConfigManager *pConfigManager) const;
177
178private:
180 std::unordered_map<CCommunityId, std::unordered_set<CCommunityCountryName>> m_Entries;
181};
182
184{
185public:
187 m_pCommunityCache(pCommunityCache)
188 {
189 }
190
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);
199 void Save(IConfigManager *pConfigManager) const;
200
201private:
203 std::unordered_map<CCommunityId, std::unordered_set<CCommunityTypeName>> m_Entries;
204};
205
207{
210 int m_LastType = IServerBrowser::NUM_TYPES; // initial value does not appear normally, marking uninitialized cache
212 std::vector<const CCommunity *> m_vpSelectedCommunities;
213 std::vector<const CCommunityCountry *> m_vpSelectableCountries;
214 std::vector<const CCommunityType *> m_vpSelectableTypes;
218
219public:
221 m_pServerBrowser(pServerBrowser)
222 {
223 }
224
225 void Update(bool Force) override;
226 const std::vector<const CCommunity *> &SelectedCommunities() const override { return m_vpSelectedCommunities; }
227 const std::vector<const CCommunityCountry *> &SelectableCountries() const override { return m_vpSelectableCountries; }
228 const std::vector<const CCommunityType *> &SelectableTypes() const override { return m_vpSelectableTypes; }
229 bool AnyRanksAvailable() const override { return m_AnyRanksAvailable; }
231 const char *CountryTypeFilterKey() const override { return m_pCountryTypeFilterKey; }
232};
233
235{
236public:
238 virtual ~CServerBrowser();
239
240 // interface functions
241 void Refresh(int Type, bool Force = false) override;
242 bool IsRefreshing() const override;
243 bool IsGettingServerlist() const override;
244 int LoadingProgression() const override;
245 void RequestResort() { m_NeedResort = true; }
246
247 int NumServers() const override { return m_NumServers; }
248 int Players(const CServerInfo &Item) const override;
249 int Max(const CServerInfo &Item) const override;
250 int NumSortedServers() const override { return m_NumSortedServers; }
251 int NumSortedPlayers() const override { return m_NumSortedPlayers; }
252 const CServerInfo *SortedGet(int Index) const override;
253
254 const json_value *LoadDDNetInfo();
255 void LoadDDNetInfoJson();
256 void LoadDDNetLocation();
257 void LoadDDNetServers();
258 void UpdateServerFilteredPlayers(CServerInfo *pInfo) const;
259 void UpdateServerFriends(CServerInfo *pInfo) const;
260 void UpdateServerCommunity(CServerInfo *pInfo) const;
261 void UpdateServerRank(CServerInfo *pInfo) const;
262 const char *GetTutorialServer() override;
263
264 const std::vector<CCommunity> &Communities() const override;
265 const CCommunity *Community(const char *pCommunityId) const override;
266 std::vector<const CCommunity *> SelectedCommunities() const override;
267 std::vector<const CCommunity *> FavoriteCommunities() const override;
268 std::vector<const CCommunity *> CurrentCommunities() const override;
269 unsigned CurrentCommunitiesHash() const override;
270
271 bool DDNetInfoAvailable() const override { return m_pDDNetInfo != nullptr; }
273
275 const ICommunityCache &CommunityCache() const override { return m_CommunityCache; }
284 void CleanFilters() override;
285
286 //
287 void Update();
288 void OnServerInfoUpdate(const NETADDR &Addr, int Token, const CServerInfo *pInfo);
289 void SetHttpInfo(const CServerInfo *pInfo);
290 void RequestCurrentServer(const NETADDR &Addr) const;
291 void RequestCurrentServerWithRandomToken(const NETADDR &Addr, int *pBasicToken, int *pToken) const;
292 void SetCurrentServerPing(const NETADDR &Addr, int Ping);
293
294 void SetBaseInfo(class CNetClient *pClient, const char *pNetVersion);
295 void OnInit();
296
297 void QueueRequest(CServerEntry *pEntry);
298 CServerEntry *Find(const NETADDR &Addr) override;
299 int GetCurrentType() override { return m_ServerlistType; }
300 bool IsRegistered(const NETADDR &Addr);
301
302private:
306 IEngine *m_pEngine = nullptr;
311 char m_aNetVersion[128];
312
313 bool m_RefreshingHttp = false;
316 const char *m_pHttpPrevBestUrl = nullptr;
317
321 std::unordered_map<NETADDR, int> m_ByAddr;
322
323 std::vector<CCommunity> m_vCommunities;
324 std::unordered_map<NETADDR, CCommunityServer> m_CommunityServersByAddr;
325
327
333
336
340
343
344 // used instead of g_Config.br_max_requests to get more servers
346
352
355 unsigned char m_aTokenSeed[16];
356
357 int GenerateToken(const NETADDR &Addr) const;
358 static int GetBasicToken(int Token);
359 static int GetExtraToken(int Token);
360
361 // sorting criteria
362 bool SortCompareName(int Index1, int Index2) const;
363 bool SortCompareMap(int Index1, int Index2) const;
364 bool SortComparePing(int Index1, int Index2) const;
365 bool SortCompareGametype(int Index1, int Index2) const;
366 bool SortCompareNumPlayers(int Index1, int Index2) const;
367 bool SortCompareNumClients(int Index1, int Index2) const;
368 bool SortCompareNumFriends(int Index1, int Index2) const;
369 bool SortCompareNumPlayersAndPing(int Index1, int Index2) const;
370
371 //
372 void Filter();
373 void Sort();
374 int SortHash() const;
375
376 void CleanUp();
377
378 void UpdateFromHttp();
379 CServerEntry *Add(const NETADDR *pAddrs, int NumAddrs);
380
381 void RemoveRequest(CServerEntry *pEntry);
382
383 void RequestImpl(const NETADDR &Addr, CServerEntry *pEntry, int *pBasicToken, int *pToken, bool RandomToken) const;
384
385 void RegisterCommands();
386 static void ConfigSaveCallback(IConfigManager *pConfigManager, void *pUserData);
387 static void Con_AddFavoriteCommunity(IConsole::IResult *pResult, void *pUserData);
388 static void Con_RemoveFavoriteCommunity(IConsole::IResult *pResult, void *pUserData);
389 static void Con_AddExcludedCommunity(IConsole::IResult *pResult, void *pUserData);
390 static void Con_RemoveExcludedCommunity(IConsole::IResult *pResult, void *pUserData);
391 static void Con_AddExcludedCountry(IConsole::IResult *pResult, void *pUserData);
392 static void Con_RemoveExcludedCountry(IConsole::IResult *pResult, void *pUserData);
393 static void Con_AddExcludedType(IConsole::IResult *pResult, void *pUserData);
394 static void Con_RemoveExcludedType(IConsole::IResult *pResult, void *pUserData);
395 static void Con_LeakIpAddress(IConsole::IResult *pResult, void *pUserData);
396
397 bool ValidateCommunityId(const char *pCommunityId) const;
398 bool ValidateCountryName(const char *pCountryName) const;
399 bool ValidateTypeName(const char *pTypeName) const;
400
401 void SetInfo(CServerEntry *pEntry, const CServerInfo &Info) const;
402 void SetLatency(NETADDR Addr, int Latency);
403
404 static bool ParseCommunityFinishes(CCommunity *pCommunity, const json_value &Finishes);
405 static bool ParseCommunityServers(CCommunity *pCommunity, const json_value &Servers);
406};
407
408#endif
const SHA256_DIGEST SHA256_ZEROED
Definition: hash.cpp:6
Definition: serverbrowser.h:207
const char * CountryTypeFilterKey() const override
Definition: serverbrowser.h:231
const std::vector< const CCommunity * > & SelectedCommunities() const override
Definition: serverbrowser.h:226
int m_LastType
Definition: serverbrowser.h:210
void Update(bool Force) override
Definition: serverbrowser.cpp:1746
const std::vector< const CCommunityType * > & SelectableTypes() const override
Definition: serverbrowser.h:228
std::vector< const CCommunityCountry * > m_vpSelectableCountries
Definition: serverbrowser.h:213
CCommunityCache(IServerBrowser *pServerBrowser)
Definition: serverbrowser.h:220
unsigned m_SelectedCommunitiesHash
Definition: serverbrowser.h:211
std::vector< const CCommunity * > m_vpSelectedCommunities
Definition: serverbrowser.h:212
IServerBrowser * m_pServerBrowser
Definition: serverbrowser.h:208
bool CountriesTypesFilterAvailable() const override
Definition: serverbrowser.h:230
bool m_AnyRanksAvailable
Definition: serverbrowser.h:215
SHA256_DIGEST m_InfoSha256
Definition: serverbrowser.h:209
const char * m_pCountryTypeFilterKey
Definition: serverbrowser.h:217
bool m_CountryTypesFilterAvailable
Definition: serverbrowser.h:216
const std::vector< const CCommunityCountry * > & SelectableCountries() const override
Definition: serverbrowser.h:227
bool AnyRanksAvailable() const override
Definition: serverbrowser.h:229
std::vector< const CCommunityType * > m_vpSelectableTypes
Definition: serverbrowser.h:214
Definition: serverbrowser.h:57
char m_aName[CServerInfo::MAX_COMMUNITY_COUNTRY_LENGTH]
Definition: serverbrowser.h:58
const char * Name() const
Definition: serverbrowser.h:66
CCommunityCountryName(const char *pCountryName)
Definition: serverbrowser.h:61
bool operator==(const CCommunityCountryName &Other) const
Definition: serverbrowser.h:68
Definition: serverbrowser.h:30
CCommunityId(const char *pCommunityId)
Definition: serverbrowser.h:34
char m_aId[CServerInfo::MAX_COMMUNITY_ID_LENGTH]
Definition: serverbrowser.h:31
const char * Id() const
Definition: serverbrowser.h:39
bool operator==(const CCommunityId &Other) const
Definition: serverbrowser.h:41
Definition: serverbrowser.h:111
char m_aTypeName[CServerInfo::MAX_COMMUNITY_TYPE_LENGTH]
Definition: serverbrowser.h:114
CCommunityServer(const char *pCommunityId, const char *pCountryName, const char *pTypeName)
Definition: serverbrowser.h:117
const char * TypeName() const
Definition: serverbrowser.h:126
char m_aCommunityId[CServerInfo::MAX_COMMUNITY_ID_LENGTH]
Definition: serverbrowser.h:112
char m_aCountryName[CServerInfo::MAX_COMMUNITY_COUNTRY_LENGTH]
Definition: serverbrowser.h:113
const char * CommunityId() const
Definition: serverbrowser.h:124
const char * CountryName() const
Definition: serverbrowser.h:125
Definition: serverbrowser.h:84
const char * Name() const
Definition: serverbrowser.h:93
bool operator==(const CCommunityTypeName &Other) const
Definition: serverbrowser.h:95
char m_aName[CServerInfo::MAX_COMMUNITY_TYPE_LENGTH]
Definition: serverbrowser.h:85
CCommunityTypeName(const char *pTypeName)
Definition: serverbrowser.h:88
Definition: serverbrowser.h:207
Definition: serverbrowser.h:161
void Save(IConfigManager *pConfigManager) const
Definition: serverbrowser.cpp:2097
CExcludedCommunityCountryFilterList(const ICommunityCache *pCommunityCache)
Definition: serverbrowser.h:163
bool Empty() const override
Definition: serverbrowser.cpp:2015
void Add(const char *pCountryName) override
Definition: serverbrowser.cpp:1955
void Clean(const std::vector< CCommunity > &vAllowedCommunities)
Definition: serverbrowser.cpp:2023
std::unordered_map< CCommunityId, std::unordered_set< CCommunityCountryName > > m_Entries
Definition: serverbrowser.h:180
bool Filtered(const char *pCountryName) const override
Definition: serverbrowser.cpp:2004
void Remove(const char *pCountryName) override
Definition: serverbrowser.cpp:1981
void Clear() override
Definition: serverbrowser.cpp:1995
const ICommunityCache * m_pCommunityCache
Definition: serverbrowser.h:179
Definition: serverbrowser.h:146
bool Empty() const override
Definition: serverbrowser.cpp:1915
void Save(IConfigManager *pConfigManager) const
Definition: serverbrowser.cpp:1943
void Clean(const std::vector< CCommunity > &vAllowedCommunities)
Definition: serverbrowser.cpp:1920
std::unordered_set< CCommunityId > m_Entries
Definition: serverbrowser.h:157
void Clear() override
Definition: serverbrowser.cpp:1905
void Add(const char *pCommunityId) override
Definition: serverbrowser.cpp:1895
bool Filtered(const char *pCommunityId) const override
Definition: serverbrowser.cpp:1910
void Remove(const char *pCommunityId) override
Definition: serverbrowser.cpp:1900
Definition: serverbrowser.h:184
void Clear() override
Definition: serverbrowser.cpp:2154
std::unordered_map< CCommunityId, std::unordered_set< CCommunityTypeName > > m_Entries
Definition: serverbrowser.h:203
void Add(const char *pTypeName) override
Definition: serverbrowser.cpp:2114
void Clean(const std::vector< CCommunity > &vAllowedCommunities)
Definition: serverbrowser.cpp:2182
bool Filtered(const char *pTypeName) const override
Definition: serverbrowser.cpp:2163
void Save(IConfigManager *pConfigManager) const
Definition: serverbrowser.cpp:2256
bool Empty() const override
Definition: serverbrowser.cpp:2174
void Remove(const char *pTypeName) override
Definition: serverbrowser.cpp:2140
const ICommunityCache * m_pCommunityCache
Definition: serverbrowser.h:202
CExcludedCommunityTypeFilterList(const ICommunityCache *pCommunityCache)
Definition: serverbrowser.h:186
Definition: serverbrowser.h:130
void Remove(const char *pCommunityId) override
Definition: serverbrowser.cpp:1836
bool Filtered(const char *pCommunityId) const override
Definition: serverbrowser.cpp:1850
bool Empty() const override
Definition: serverbrowser.cpp:1855
void Clear() override
Definition: serverbrowser.cpp:1845
void Clean(const std::vector< CCommunity > &vAllowedCommunities)
Definition: serverbrowser.cpp:1860
void Add(const char *pCommunityId) override
Definition: serverbrowser.cpp:1818
const std::vector< CCommunityId > & Entries() const
Definition: serverbrowser.cpp:1882
std::vector< CCommunityId > m_vEntries
Definition: serverbrowser.h:142
void Save(IConfigManager *pConfigManager) const
Definition: serverbrowser.cpp:1870
Definition: memheap.h:11
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: serverbrowser.h:251
Definition: config.h:9
Definition: console.h:45
Definition: console.h:18
Definition: engine.h:15
Definition: favorites.h:14
Definition: serverbrowser.h:241
Definition: friends.h:19
Definition: http.h:12
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
Definition: storage.h:20
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
Definition: types.h:67
Definition: hash.h:15
size_t operator()(const CCommunityCountryName &Elem) const noexcept
Definition: serverbrowser.h:77
size_t operator()(const CCommunityId &Elem) const noexcept
Definition: serverbrowser.h:50
size_t operator()(const CCommunityTypeName &Elem) const noexcept
Definition: serverbrowser.h:104
unsigned str_quickhash(const char *str)
Definition: system.cpp:4029