1#ifndef ENGINE_SHARED_SERVERINFO_H
2#define ENGINE_SHARED_SERVERINFO_H
3
4#include "protocol.h"
5
6#include <engine/map.h>
7#include <engine/serverbrowser.h>
8
9typedef struct _json_value json_value;
10class CServerInfo;
11
12class CServerInfo2
13{
14public:
15 class CClient
16 {
17 public:
18 char m_aName[MAX_NAME_LENGTH];
19 char m_aClan[MAX_CLAN_LENGTH];
20 int m_Country;
21 int m_Score;
22 bool m_IsPlayer;
23 bool m_IsAfk;
24 // skin info 0.6
25 char m_aSkin[MAX_SKIN_LENGTH];
26 bool m_CustomSkinColors;
27 int m_CustomSkinColorBody;
28 int m_CustomSkinColorFeet;
29 // skin info 0.7
30 char m_aaSkin7[protocol7::NUM_SKINPARTS][protocol7::MAX_SKIN_LENGTH];
31 bool m_aUseCustomSkinColor7[protocol7::NUM_SKINPARTS];
32 int m_aCustomSkinColor7[protocol7::NUM_SKINPARTS];
33 };
34
35 CClient m_aClients[SERVERINFO_MAX_CLIENTS];
36 int m_MaxClients;
37 int m_NumClients; // Indirectly serialized.
38 int m_MaxPlayers;
39 int m_NumPlayers; // Not serialized.
40 CServerInfo::EClientScoreKind m_ClientScoreKind;
41 bool m_Passworded;
42 char m_aGameType[16];
43 char m_aName[64];
44 char m_aMapName[MAX_MAP_LENGTH];
45 char m_aVersion[32];
46 bool m_RequiresLogin;
47
48 bool operator==(const CServerInfo2 &Other) const;
49 bool operator!=(const CServerInfo2 &Other) const { return !(*this == Other); }
50 static bool FromJson(CServerInfo2 *pOut, const json_value *pJson);
51 static bool FromJsonRaw(CServerInfo2 *pOut, const json_value *pJson);
52 bool Validate() const;
53 void ToJson(char *pBuffer, int BufferSize) const;
54
55 operator CServerInfo() const;
56};
57
58bool ParseCrc(unsigned int *pResult, const char *pString);
59
60#endif // ENGINE_SHARED_SERVERINFO_H
61