| 1 | #ifndef ENGINE_SHARED_ECON_H |
| 2 | #define ENGINE_SHARED_ECON_H |
| 3 | |
| 4 | #include "network.h" |
| 5 | |
| 6 | #include <engine/console.h> |
| 7 | |
| 8 | class CConfig; |
| 9 | class CNetBan; |
| 10 | class ColorRGBA; |
| 11 | |
| 12 | class CEcon |
| 13 | { |
| 14 | enum |
| 15 | { |
| 16 | MAX_AUTH_TRIES = 3, |
| 17 | }; |
| 18 | |
| 19 | class CClient |
| 20 | { |
| 21 | public: |
| 22 | enum |
| 23 | { |
| 24 | STATE_EMPTY = 0, |
| 25 | STATE_CONNECTED, |
| 26 | STATE_AUTHED, |
| 27 | }; |
| 28 | |
| 29 | int m_State; |
| 30 | int64_t m_TimeConnected; |
| 31 | int m_AuthTries; |
| 32 | }; |
| 33 | CClient m_aClients[NET_MAX_CONSOLE_CLIENTS]; |
| 34 | |
| 35 | CConfig *m_pConfig; |
| 36 | IConsole *m_pConsole; |
| 37 | CNetConsole m_NetConsole; |
| 38 | |
| 39 | bool m_Ready; |
| 40 | int m_PrintCBIndex; |
| 41 | int m_UserClientId; |
| 42 | |
| 43 | static void SendLineCB(const char *pLine, void *pUserData, ColorRGBA PrintColor = {1, 1, 1, 1}); |
| 44 | static void ConLogout(IConsole::IResult *pResult, void *pUserData); |
| 45 | |
| 46 | static int NewClientCallback(int ClientId, void *pUser); |
| 47 | static int DelClientCallback(int ClientId, const char *pReason, void *pUser); |
| 48 | |
| 49 | public: |
| 50 | CEcon(); |
| 51 | IConsole *Console() { return m_pConsole; } |
| 52 | |
| 53 | void Init(CConfig *pConfig, IConsole *pConsole, CNetBan *pNetBan); |
| 54 | void Update(); |
| 55 | void Send(int ClientId, const char *pLine); |
| 56 | void Shutdown(); |
| 57 | }; |
| 58 | |
| 59 | #endif |
| 60 | |