2017-01-20 08:36:52 -05:00
|
|
|
#pragma once
|
|
|
|
|
2017-02-14 14:43:03 -05:00
|
|
|
// This enables version filtering
|
2017-02-15 04:15:35 -05:00
|
|
|
#define VERSION_FILTER
|
2017-02-14 14:43:03 -05:00
|
|
|
|
2017-01-16 11:42:50 -05:00
|
|
|
namespace Components
|
|
|
|
{
|
|
|
|
class ServerList : public Component
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef int(SortCallback)(const void*, const void*);
|
|
|
|
|
|
|
|
class ServerInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Network::Address addr;
|
|
|
|
std::string hostname;
|
|
|
|
std::string mapname;
|
|
|
|
std::string gametype;
|
|
|
|
std::string mod;
|
|
|
|
std::string shortversion;
|
|
|
|
int clients;
|
2017-06-12 15:01:56 -04:00
|
|
|
int bots;
|
2017-01-16 11:42:50 -05:00
|
|
|
int maxClients;
|
|
|
|
bool password;
|
|
|
|
int ping;
|
|
|
|
int matchType;
|
|
|
|
int securityLevel;
|
|
|
|
bool hardcore;
|
|
|
|
bool svRunning;
|
2022-08-14 15:39:53 -04:00
|
|
|
bool aimassist;
|
|
|
|
bool voice;
|
2017-01-16 11:42:50 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
ServerList();
|
|
|
|
~ServerList();
|
|
|
|
|
2022-08-24 10:38:14 -04:00
|
|
|
static void Refresh([[maybe_unused]] const UIScript::Token& token, [[maybe_unused]] const Game::uiInfo_s* info);
|
|
|
|
static void RefreshVisibleList([[maybe_unused]] const UIScript::Token& token, [[maybe_unused]] const Game::uiInfo_s* info);
|
|
|
|
static void RefreshVisibleListInternal([[maybe_unused]] const UIScript::Token& token, [[maybe_unused]] const Game::uiInfo_s* info, bool refresh = false);
|
|
|
|
static void UpdateVisibleList([[maybe_unused]] const UIScript::Token& token, [[maybe_unused]] const Game::uiInfo_s* info);
|
2017-02-28 13:58:03 -05:00
|
|
|
static void InsertRequest(Network::Address address);
|
2022-06-04 04:56:14 -04:00
|
|
|
static void Insert(const Network::Address& address, const Utils::InfoString& info);
|
2017-01-16 11:42:50 -05:00
|
|
|
|
|
|
|
static ServerInfo* GetCurrentServer();
|
|
|
|
|
|
|
|
static bool IsFavouriteList();
|
|
|
|
static bool IsOfflineList();
|
|
|
|
static bool IsOnlineList();
|
|
|
|
|
2017-02-25 09:32:15 -05:00
|
|
|
static void Frame();
|
|
|
|
static std::vector<ServerInfo>* GetList();
|
|
|
|
|
2017-02-26 09:27:02 -05:00
|
|
|
static void UpdateVisibleInfo();
|
|
|
|
|
2022-05-03 03:01:54 -04:00
|
|
|
static bool GetMasterServer(const char* ip, int port, Game::netadr_t& address);
|
2022-10-15 16:31:16 -04:00
|
|
|
static bool UseMasterServer;
|
2022-05-03 01:17:31 -04:00
|
|
|
|
2017-01-16 11:42:50 -05:00
|
|
|
private:
|
2022-12-29 06:34:43 -05:00
|
|
|
enum class Column : int
|
2017-01-16 11:42:50 -05:00
|
|
|
{
|
|
|
|
Password,
|
|
|
|
Matchtype,
|
2022-08-14 15:39:53 -04:00
|
|
|
AimAssist,
|
|
|
|
VoiceChat,
|
2017-01-16 11:42:50 -05:00
|
|
|
Hostname,
|
|
|
|
Mapname,
|
|
|
|
Players,
|
|
|
|
Gametype,
|
|
|
|
Mod,
|
|
|
|
Ping,
|
2022-12-29 06:34:43 -05:00
|
|
|
|
|
|
|
Count
|
2017-01-16 11:42:50 -05:00
|
|
|
};
|
|
|
|
|
2022-08-19 12:35:36 -04:00
|
|
|
static constexpr auto* FavouriteFile = "players/favourites.json";
|
|
|
|
|
2017-01-16 11:42:50 -05:00
|
|
|
#pragma pack(push, 1)
|
|
|
|
union MasterEntry
|
|
|
|
{
|
|
|
|
char token[7];
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32_t ip;
|
|
|
|
uint16_t port;
|
|
|
|
};
|
|
|
|
|
2022-12-29 06:34:43 -05:00
|
|
|
bool IsEndToken() const
|
2017-01-16 11:42:50 -05:00
|
|
|
{
|
|
|
|
// End of transmission or file token
|
|
|
|
return (token[0] == 'E' && token[1] == 'O' && (token[2] == 'T' || token[2] == 'F'));
|
|
|
|
}
|
|
|
|
|
2022-12-29 06:34:43 -05:00
|
|
|
bool HasSeparator() const
|
2017-01-16 11:42:50 -05:00
|
|
|
{
|
|
|
|
return (token[6] == '\\');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
class Container
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
class ServerContainer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool sent;
|
|
|
|
int sendTime;
|
|
|
|
std::string challenge;
|
|
|
|
Network::Address target;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool awatingList;
|
|
|
|
int awaitTime;
|
|
|
|
|
|
|
|
int sentCount;
|
|
|
|
int sendCount;
|
|
|
|
|
|
|
|
Network::Address host;
|
|
|
|
std::vector<ServerContainer> servers;
|
2017-02-28 13:58:03 -05:00
|
|
|
std::recursive_mutex mutex;
|
2017-01-16 11:42:50 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned int GetServerCount();
|
|
|
|
static const char* GetServerText(unsigned int index, int column);
|
2017-06-05 10:24:57 -04:00
|
|
|
static const char* GetServerInfoText(ServerInfo* server, int column, bool sorting = false);
|
2017-01-16 11:42:50 -05:00
|
|
|
static void SelectServer(unsigned int index);
|
|
|
|
|
|
|
|
static void UpdateSource();
|
|
|
|
static void UpdateGameType();
|
|
|
|
|
|
|
|
static void SortList();
|
|
|
|
|
|
|
|
static void LoadFavourties();
|
2018-12-17 08:29:18 -05:00
|
|
|
static void StoreFavourite(const std::string& server);
|
|
|
|
static void RemoveFavourite(const std::string& server);
|
2017-01-16 11:42:50 -05:00
|
|
|
|
|
|
|
static ServerInfo* GetServer(unsigned int index);
|
|
|
|
|
2018-12-17 08:29:18 -05:00
|
|
|
static bool CompareVersion(const std::string& version1, const std::string& version2);
|
2017-02-15 08:11:36 -05:00
|
|
|
|
2017-01-16 11:42:50 -05:00
|
|
|
static int SortKey;
|
|
|
|
static bool SortAsc;
|
|
|
|
|
|
|
|
static unsigned int CurrentServer;
|
|
|
|
static Container RefreshContainer;
|
|
|
|
|
|
|
|
static std::vector<ServerInfo> OnlineList;
|
|
|
|
static std::vector<ServerInfo> OfflineList;
|
|
|
|
static std::vector<ServerInfo> FavouriteList;
|
|
|
|
|
|
|
|
static std::vector<unsigned int> VisibleList;
|
2022-04-12 17:15:50 -04:00
|
|
|
|
|
|
|
static Dvar::Var UIServerSelected;
|
|
|
|
static Dvar::Var UIServerSelectedMap;
|
|
|
|
static Dvar::Var NETServerQueryLimit;
|
|
|
|
static Dvar::Var NETServerFrames;
|
2022-05-03 02:34:57 -04:00
|
|
|
|
|
|
|
static bool IsServerListOpen();
|
2017-01-16 11:42:50 -05:00
|
|
|
};
|
|
|
|
}
|