2
0

GameSpyBanList.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. //
  19. // Filename: GameSpyBanList.h
  20. // Author: Brian Hayes
  21. // Date: Mar 2002
  22. // Description: Maintains a list of banned nicknames/hashes/ipaddresses for GameSpy Servers
  23. //
  24. #ifndef __GAMESPYBANLIST_H__
  25. #define __GAMESPYBANLIST_H__
  26. #include "bittype.h"
  27. enum GAMESPY_KICK_STATE_ENUM
  28. {
  29. GAMESPY_KICK_STATE_INITIAL = 0, // Just connected
  30. GAMESPY_KICK_STATE_APPROVED, // This user is not in the ban list
  31. GAMESPY_KICK_STATE_BEGIN, // Give them a message before we boot him
  32. GAMESPY_KICK_STATE_KICKED, // outta here.
  33. GAMESPY_KICK_STATE_COUNT
  34. };
  35. class BanEntry : public Node<BanEntry *> {
  36. public:
  37. BanEntry(const char *name = NULL, const char *ip = NULL, const char *hash_id = NULL,
  38. const char *ip_mask = NULL, bool rtype = false);
  39. protected:
  40. char hashid[33];
  41. char nickname[40];
  42. ULONG ipaddress;
  43. ULONG ipmask;
  44. bool ruletype;
  45. public:
  46. const char *Get_Nick_Name(void) {return (const char *)nickname;}
  47. const char *Get_Hash_ID(void) {return (const char *)hashid;}
  48. ULONG Get_Ip_Address(void) {return ipaddress;}
  49. ULONG Get_Ip_Netmask(void) {return ipmask;}
  50. bool Get_Rule_Type(void) {return ruletype;}
  51. };
  52. class cGameSpyBanList
  53. {
  54. public:
  55. cGameSpyBanList();
  56. ~cGameSpyBanList();
  57. protected:
  58. List<BanEntry *> * BanList;
  59. bool Final_Player_Kick(int id);
  60. bool Begin_Player_Kick(int id);
  61. void Strip_Escapes(char *var);
  62. public:
  63. void Think(void);
  64. bool Kick_Player(int id) { return Begin_Player_Kick(id);}
  65. void Ban_User(const char *nickname, const char *challenge_response = NULL,
  66. ULONG ipaddress = 0xffffffff);
  67. bool Is_User_Banned(const char *nickname, const char *challenge_response, ULONG ipaddress);
  68. void LoadBans(void);
  69. };
  70. extern cGameSpyBanList GameSpyBanList;
  71. #endif // __GAMESPYBANLIST_H__