9
3

ChatChannel.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator 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. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef CHAT_CHATCHANNEL_H_
  17. #define CHAT_CHATCHANNEL_H_
  18. #include "../../common/types.h"
  19. #include "../client.h"
  20. #include <vector>
  21. using namespace std;
  22. #define CHAT_CHANNEL_MAX_NAME 100
  23. #define CHAT_CHANNEL_MAX_PASSWORD 100
  24. enum ChatChannelType {
  25. CHAT_CHANNEL_TYPE_NONE = 0,
  26. CHAT_CHANNEL_TYPE_WORLD,
  27. CHAT_CHANNEL_TYPE_CUSTOM
  28. };
  29. class ChatChannel {
  30. public:
  31. ChatChannel();
  32. virtual ~ChatChannel();
  33. void SetName(const char *name) {strncpy(this->name, name, CHAT_CHANNEL_MAX_NAME);}
  34. void SetPassword(const char *password) {strncpy(this->password, password, CHAT_CHANNEL_MAX_PASSWORD);}
  35. void SetType(ChatChannelType type) {this->type = type;}
  36. void SetLevelRestriction(int16 level_restriction) {this->level_restriction = level_restriction;}
  37. void SetRacesAllowed(int64 races) {this->races = races;}
  38. void SetClassesAllowed(int64 classes) {this->classes = classes;}
  39. const char * GetName() {return name;}
  40. ChatChannelType GetType() {return type;}
  41. unsigned int GetNumClients() {return clients.size();}
  42. bool HasPassword() {return password[0] != '\0';}
  43. bool PasswordMatches(const char *password) {return strncmp(this->password, password, CHAT_CHANNEL_MAX_PASSWORD) == 0;}
  44. bool CanJoinChannelByLevel(int16 level) {return level >= level_restriction;}
  45. bool CanJoinChannelByRace(int8 race_id) {return races == 0 || (1 << race_id) & races;}
  46. bool CanJoinChannelByClass(int8 class_id) {return classes == 0 || (1 << class_id) & classes;}
  47. bool IsInChannel(int32 character_id);
  48. bool JoinChannel(Client *client);
  49. bool LeaveChannel(Client *client);
  50. bool TellChannel(Client *client, const char *message, const char* name2 = 0);
  51. bool TellChannelClient(Client* to_client, const char* message, const char* name2 = 0);
  52. bool SendChannelUserList(Client *client);
  53. private:
  54. char name[CHAT_CHANNEL_MAX_NAME + 1];
  55. char password[CHAT_CHANNEL_MAX_PASSWORD + 1];
  56. ChatChannelType type;
  57. vector<int32> clients;
  58. int16 level_restriction;
  59. int64 races;
  60. int64 classes;
  61. };
  62. #endif