| 1 | #ifndef ENGINE_SERVER_NAME_BAN_H |
| 2 | #define ENGINE_SERVER_NAME_BAN_H |
| 3 | |
| 4 | #include <engine/console.h> |
| 5 | #include <engine/shared/protocol.h> |
| 6 | |
| 7 | #include <vector> |
| 8 | |
| 9 | enum |
| 10 | { |
| 11 | MAX_NAME_SKELETON_LENGTH = MAX_NAME_LENGTH * 4, |
| 12 | MAX_NAMEBAN_REASON_LENGTH = 64 |
| 13 | }; |
| 14 | |
| 15 | class CNameBan |
| 16 | { |
| 17 | public: |
| 18 | CNameBan(const char *pName, const char *pReason, int Distance, bool IsSubstring); |
| 19 | |
| 20 | char m_aName[MAX_NAME_LENGTH]; |
| 21 | char m_aReason[MAX_NAMEBAN_REASON_LENGTH]; |
| 22 | int m_aSkeleton[MAX_NAME_SKELETON_LENGTH]; |
| 23 | int m_SkeletonLength; |
| 24 | int m_Distance; |
| 25 | bool m_IsSubstring; |
| 26 | }; |
| 27 | |
| 28 | class CNameBans |
| 29 | { |
| 30 | IConsole *m_pConsole = nullptr; |
| 31 | std::vector<CNameBan> m_vNameBans; |
| 32 | |
| 33 | static void ConNameBan(IConsole::IResult *pResult, void *pUser); |
| 34 | static void ConNameUnban(IConsole::IResult *pResult, void *pUser); |
| 35 | static void ConNameBans(IConsole::IResult *pResult, void *pUser); |
| 36 | |
| 37 | public: |
| 38 | void InitConsole(IConsole *pConsole); |
| 39 | void Ban(const char *pName, const char *pReason, int Distance, bool IsSubstring); |
| 40 | void Unban(const char *pName); |
| 41 | void Dump() const; |
| 42 | const CNameBan *IsBanned(const char *pName) const; |
| 43 | }; |
| 44 | |
| 45 | #endif // ENGINE_SERVER_NAME_BAN_H |
| 46 | |