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_SRVBROWSE_H
4 #define ENGINE_CLIENT_SRVBROWSE_H
6 #include <engine/serverbrowser.h>
8 class CServerBrowser
: public IServerBrowser
19 CServerEntry
*m_pNextIp
; // ip hashed list
21 CServerEntry
*m_pPrevReq
; // request list
22 CServerEntry
*m_pNextReq
;
32 // interface functions
33 void Refresh(int Type
);
34 bool IsRefreshing() const;
35 bool IsRefreshingMasters() const;
36 int LoadingProgression() const;
38 int NumServers() const { return m_NumServers
; }
40 int NumSortedServers() const { return m_NumSortedServers
; }
41 const CServerInfo
*SortedGet(int Index
) const;
43 bool IsFavorite(const NETADDR
&Addr
) const;
44 void AddFavorite(const NETADDR
&Addr
);
45 void RemoveFavorite(const NETADDR
&Addr
);
48 void Update(bool ForceResort
);
49 void Set(const NETADDR
&Addr
, int Type
, int Token
, const CServerInfo
*pInfo
);
50 void Request(const NETADDR
&Addr
) const;
52 void SetBaseInfo(class CNetClient
*pClient
, const char *pNetVersion
);
55 CNetClient
*m_pNetClient
;
56 IMasterServer
*m_pMasterServer
;
57 class IConsole
*m_pConsole
;
58 class IFriends
*m_pFriends
;
59 char m_aNetVersion
[128];
61 CHeap m_ServerlistHeap
;
62 CServerEntry
**m_ppServerlist
;
63 int *m_pSortedServerlist
;
65 NETADDR m_aFavoriteServers
[MAX_FAVORITES
];
66 int m_NumFavoriteServers
;
68 CServerEntry
*m_aServerlistIp
[256]; // ip hash list
70 CServerEntry
*m_pFirstReqServer
; // request list
71 CServerEntry
*m_pLastReqServer
;
76 int m_NumSortedServers
;
77 int m_NumSortedServersCapacity
;
79 int m_NumServerCapacity
;
82 char m_aFilterString
[64];
83 char m_aFilterGametypeString
[128];
85 // the token is to keep server refresh separated from each other
89 int64 m_BroadcastTime
;
92 bool SortCompareName(int Index1
, int Index2
) const;
93 bool SortCompareMap(int Index1
, int Index2
) const;
94 bool SortComparePing(int Index1
, int Index2
) const;
95 bool SortCompareGametype(int Index1
, int Index2
) const;
96 bool SortCompareNumPlayers(int Index1
, int Index2
) const;
97 bool SortCompareNumClients(int Index1
, int Index2
) const;
102 int SortHash() const;
104 CServerEntry
*Find(const NETADDR
&Addr
);
105 CServerEntry
*Add(const NETADDR
&Addr
);
107 void RemoveRequest(CServerEntry
*pEntry
);
108 void QueueRequest(CServerEntry
*pEntry
);
110 void RequestImpl(const NETADDR
&Addr
, CServerEntry
*pEntry
) const;
112 void SetInfo(CServerEntry
*pEntry
, const CServerInfo
&Info
);
114 static void ConfigSaveCallback(IConfig
*pConfig
, void *pUserData
);