channel.hpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #ifndef CHANNEL_HPP
  4. #define CHANNEL_HPP
  5. #include <common/cbasetypes.hpp>
  6. #include <common/mmo.hpp>
  7. //namespace rA {
  8. class map_session_data;
  9. struct mmo_guild;
  10. struct DBMap;
  11. #define CHAN_NAME_LENGTH 20
  12. #define CHAN_MSG_LENGTH 150
  13. enum Channel_Opt {
  14. CHAN_OPT_NONE = 0, ///< None
  15. CHAN_OPT_ANNOUNCE_SELF = 0x01, ///< Shows info when player joined/left channel to self
  16. CHAN_OPT_ANNOUNCE_JOIN = 0x02, ///< Shows info if player joined the channel
  17. CHAN_OPT_ANNOUNCE_LEAVE = 0x04, ///< Shows info if player left the channel
  18. CHAN_OPT_MSG_DELAY = 0x08, ///< Enables chat delay
  19. CHAN_OPT_COLOR_OVERRIDE = 0x10, ///< Enables color channel be override by player's font color
  20. CHAN_OPT_CAN_CHAT = 0x20, ///< Allows player to chat in the channel
  21. CHAN_OPT_CAN_LEAVE = 0x40, ///< Allows player to leave the channel
  22. CHAN_OPT_AUTOJOIN = 0x80, ///< Player will be autojoined to the channel
  23. CHAN_OPT_BASE = CHAN_OPT_ANNOUNCE_SELF|CHAN_OPT_MSG_DELAY|CHAN_OPT_CAN_CHAT|CHAN_OPT_CAN_LEAVE,
  24. };
  25. enum Channel_Type {
  26. CHAN_TYPE_PUBLIC = 0, ///< Config file made
  27. CHAN_TYPE_PRIVATE = 1, ///< User's channel
  28. CHAN_TYPE_MAP = 2, ///< Local map
  29. CHAN_TYPE_ALLY = 3, ///< Guild + its alliance
  30. };
  31. struct Channel {
  32. //unsigned short id; ///< Channel ID (unused yet)
  33. char name[CHAN_NAME_LENGTH]; ///< Channel Name
  34. char pass[CHAN_NAME_LENGTH]; ///< Password
  35. char alias[CHAN_NAME_LENGTH]; ///< Channel display name
  36. enum Channel_Type type; ///< Channel type @see enum Channel_Type
  37. unsigned long color; ///< Channel color in BGR
  38. unsigned char opt; ///< Channel options @see enum Channel_Opt
  39. unsigned short msg_delay; ///< Chat delay in miliseconds
  40. uint32 char_id; ///< If CHAN_TYPE_PRIVATE, owner is char_id of channel creator
  41. uint16 m; ///< If CHAN_TYPE_MAP, owner is map id
  42. int gid; ///< If CHAN_TYPE_ALLY, owner is first logged guild_id
  43. DBMap *users; ///< List of users
  44. DBMap *banned; ///< List of banned chars -> char_id
  45. unsigned short group_count; ///< Number of group id
  46. unsigned short *groups; ///< List of group id, only these groups can join the channel
  47. };
  48. struct chan_banentry {
  49. uint32 char_id;
  50. char char_name[NAME_LENGTH];
  51. };
  52. extern chan_banentry chan_banentry;
  53. struct Channel_Config {
  54. unsigned long *colors; ///< List of available colors
  55. char **colors_name; ///< Name list of available colors
  56. unsigned char colors_count; ///< Number of available colors
  57. /// Private channel default configs
  58. struct {
  59. unsigned char opt; ///< Options @see enum Channel_Opt
  60. unsigned long color; ///< Default color
  61. uint32 delay; ///< Message delay
  62. unsigned short max_member; ///< Max member for each channel
  63. unsigned allow : 1; ///< Allow private channel creation?
  64. unsigned ban : 1; ///< Allow player to ban
  65. unsigned kick : 1; ///< Allow player to kick
  66. unsigned color_override : 1; ///< Owner cannot change the color_override
  67. unsigned change_delay : 1; ///< Owner cannot change the delay
  68. } private_channel;
  69. struct Channel map_tmpl; ///< Map channel default config
  70. struct Channel ally_tmpl; ///< Alliance channel default config
  71. bool closing; ///< Server is closing
  72. };
  73. extern struct Channel_Config channel_config;
  74. DBMap* channel_get_db(void);
  75. struct Channel* channel_create(struct Channel *tmp_chan);
  76. struct Channel* channel_create_simple(char *name, char *pass, enum Channel_Type chantype, uint32 owner);
  77. int channel_delete(struct Channel *channel, bool force);
  78. int channel_join(struct Channel *channel, map_session_data *sd);
  79. int channel_mjoin(map_session_data *sd);
  80. int channel_gjoin(map_session_data *sd, int flag);
  81. int channel_ajoin(struct mmo_guild &g);
  82. int channel_clean(struct Channel *channel, map_session_data *sd, int flag);
  83. int channel_pcquit(map_session_data *sd, int type);
  84. unsigned long channel_getColor(const char *color_str);
  85. int channel_send(struct Channel *channel, map_session_data *sd, const char *msg);
  86. void channel_read_config(void);
  87. int channel_chk(char *name, char *pass, int type);
  88. struct Channel* channel_name2channel(char *chname, map_session_data *sd, int flag);
  89. int channel_haspc(struct Channel *channel,map_session_data *sd);
  90. int channel_haspcbanned(struct Channel *channel,map_session_data *sd);
  91. int channel_pc_haschan(map_session_data *sd, struct Channel *channel);
  92. int channel_display_list(map_session_data *sd, const char *option);
  93. void channel_autojoin(map_session_data *sd);
  94. bool channel_pccheckgroup(struct Channel *channel, int group_id);
  95. int channel_pccreate(map_session_data *sd, char *chname, char *pass);
  96. int channel_pcdelete(map_session_data *sd, char *chname);
  97. int channel_pcjoin(map_session_data *sd, char *chname, char *pass);
  98. int channel_pcleave(map_session_data *sd, char *chname);
  99. int channel_pccolor(map_session_data *sd, char *chname, char *color);
  100. int channel_pcbind(map_session_data *sd, char *chname);
  101. int channel_pcunbind(map_session_data *sd);
  102. int channel_pcban(map_session_data *sd, char *chname, char *pname, int flag);
  103. int channel_pckick(map_session_data *sd, char *chname, char *pname);
  104. int channel_pcsetopt(map_session_data *sd, char *chname, const char *option, const char *val);
  105. void do_init_channel(void);
  106. void do_final_channel(void);
  107. #endif /* CHANNEL_HPP */