iw4x-client/iw4/Components/ServerList.hpp

95 lines
1.6 KiB
C++
Raw Normal View History

2015-12-27 22:02:30 -05:00
namespace Components
{
class ServerList : public Component
{
public:
struct ServerInfo
{
Network::Address Addr;
bool Visible;
std::string Hostname;
std::string Mapname;
std::string Gametype;
std::string Mod;
int Clients;
int MaxClients;
bool Password;
int Ping;
int MatchType;
bool Hardcore;
};
ServerList();
~ServerList();
const char* GetName() { return "ServerList"; };
static void Refresh();
static void Insert(Network::Address address, Utils::InfoString info);
private:
enum Column
{
Password,
Hostname,
Mapname,
Players,
Gametype,
Ping,
};
2015-12-28 08:53:20 -05:00
#pragma pack(push, 1)
union MasterEntry
{
char Token[7];
struct
{
uint32_t IP;
uint16_t Port;
};
bool IsEndToken()
{
2015-12-28 09:46:08 -05:00
// End of transmission or file token
return (Token[0] == 'E' && Token[1] == 'O' && (Token[2] == 'T' || Token[2] == 'F'));
2015-12-28 08:53:20 -05:00
}
bool HasSeparator()
{
return (Token[6] == '\\');
}
};
#pragma pack(pop)
2015-12-27 22:02:30 -05:00
struct Container
{
struct ServerContainer
{
bool Sent;
int SendTime;
std::string Challenge;
Network::Address Target;
};
2015-12-28 11:52:13 -05:00
bool AwatingList;
int AwaitTime;
2015-12-28 09:46:08 -05:00
int SentCount;
int SendCount;
2015-12-28 11:52:13 -05:00
2015-12-27 22:02:30 -05:00
Network::Address Host;
std::vector<ServerContainer> Servers;
std::mutex Mutex;
};
static int GetServerCount();
static const char* GetServerText(int index, int column);
static void SelectServer(int index);
2015-12-28 09:46:08 -05:00
static void Frame();
2015-12-28 08:08:46 -05:00
static unsigned int CurrentServer;
2015-12-27 22:02:30 -05:00
static Container RefreshContainer;
static std::vector<ServerInfo> OnlineList;
};
}