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