9
3

ChatChannel.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. CHAT_CHANNEL_TYPE_IRC
  29. };
  30. class ChatChannel {
  31. public:
  32. ChatChannel();
  33. virtual ~ChatChannel();
  34. void SetName(const char *name) {strncpy(this->name, name, CHAT_CHANNEL_MAX_NAME);}
  35. void SetPassword(const char *password) {strncpy(this->password, password, CHAT_CHANNEL_MAX_PASSWORD);}
  36. void SetType(ChatChannelType type) {this->type = type;}
  37. void SetLevelRestriction(int16 level_restriction) {this->level_restriction = level_restriction;}
  38. void SetRacesAllowed(int64 races) {this->races = races;}
  39. void SetClassesAllowed(int64 classes) {this->classes = classes;}
  40. const char * GetName() {return name;}
  41. ChatChannelType GetType() {return type;}
  42. unsigned int GetNumClients() {return clients.size();}
  43. bool HasPassword() {return password[0] != '\0';}
  44. bool PasswordMatches(const char *password) {return strncmp(this->password, password, CHAT_CHANNEL_MAX_PASSWORD) == 0;}
  45. bool CanJoinChannelByLevel(int16 level) {return level >= level_restriction;}
  46. bool CanJoinChannelByRace(int8 race_id) {return races == 0 || (1 << race_id) & races;}
  47. bool CanJoinChannelByClass(int8 class_id) {return classes == 0 || (1 << class_id) & classes;}
  48. bool IsInChannel(int32 character_id);
  49. bool JoinChannel(Client *client);
  50. bool LeaveChannel(Client *client);
  51. bool TellChannel(Client *client, const char *message, const char* name2 = 0);
  52. bool TellChannelClient(Client* to_client, const char* message, const char* name2 = 0);
  53. bool SendChannelUserList(Client *client);
  54. void SetGlobalIRCChannel(bool val) { m_globalIRCChannel = val; }
  55. bool IsGlobalIRCChannel() { return m_globalIRCChannel; }
  56. private:
  57. char name[CHAT_CHANNEL_MAX_NAME + 1];
  58. char password[CHAT_CHANNEL_MAX_PASSWORD + 1];
  59. ChatChannelType type;
  60. vector<int32> clients;
  61. int16 level_restriction;
  62. int64 races;
  63. int64 classes;
  64. bool m_globalIRCChannel;
  65. };
  66. #endif