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 | |
9 | typedef struct _json_value json_value; |
10 | class CServerInfo; |
11 | |
12 | class CServerInfo2 |
13 | { |
14 | public: |
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 | char m_aSkin[24 + 1]; |
25 | bool m_CustomSkinColors; |
26 | int m_CustomSkinColorBody; |
27 | int m_CustomSkinColorFeet; |
28 | }; |
29 | |
30 | CClient m_aClients[SERVERINFO_MAX_CLIENTS]; |
31 | int m_MaxClients; |
32 | int m_NumClients; // Indirectly serialized. |
33 | int m_MaxPlayers; |
34 | int m_NumPlayers; // Not serialized. |
35 | CServerInfo::EClientScoreKind m_ClientScoreKind; |
36 | bool m_Passworded; |
37 | char m_aGameType[16]; |
38 | char m_aName[64]; |
39 | char m_aMapName[MAX_MAP_LENGTH]; |
40 | char m_aVersion[32]; |
41 | bool m_RequiresLogin; |
42 | |
43 | bool operator==(const CServerInfo2 &Other) const; |
44 | bool operator!=(const CServerInfo2 &Other) const { return !(*this == Other); } |
45 | static bool FromJson(CServerInfo2 *pOut, const json_value *pJson); |
46 | static bool FromJsonRaw(CServerInfo2 *pOut, const json_value *pJson); |
47 | bool Validate() const; |
48 | void ToJson(char *pBuffer, int BufferSize) const; |
49 | |
50 | operator CServerInfo() const; |
51 | }; |
52 | |
53 | bool ParseCrc(unsigned int *pResult, const char *pString); |
54 | |
55 | #endif // ENGINE_SHARED_SERVERINFO_H |
56 | |