diff --git a/include/h.h b/include/h.h index 2e92e86a1..4e47fd0c3 100644 --- a/include/h.h +++ b/include/h.h @@ -923,6 +923,7 @@ extern MODVAR int debugfd; extern void convert_to_absolute_path(char **path, const char *reldir); extern int has_user_mode(Client *acptr, char mode); extern int has_channel_mode(Channel *channel, char mode); +extern int has_channel_mode_raw(Cmode_t m, char mode); extern Cmode_t get_extmode_bitbychar(char m); extern long find_user_mode(char mode); extern void start_listeners(void); diff --git a/src/channel.c b/src/channel.c index 83ed80c8a..529c8a072 100644 --- a/src/channel.c +++ b/src/channel.c @@ -581,6 +581,18 @@ int has_channel_mode(Channel *channel, char mode) return 0; /* Not found */ } +/** Returns 1 if channel has this mode is set and 0 if not */ +int has_channel_mode_raw(Cmode_t m, char mode) +{ + Cmode *cm; + + for (cm=channelmodes; cm; cm = cm->next) + if ((cm->letter == mode) && (m & cm->mode)) + return 1; + + return 0; /* Not found */ +} + /** Get the extended channel mode 'bit' value (eg: 0x20) by character (eg: 'Z') */ Cmode_t get_extmode_bitbychar(char m) { diff --git a/src/modules/sjoin.c b/src/modules/sjoin.c index 243cb99e7..509be2b1b 100644 --- a/src/modules/sjoin.c +++ b/src/modules/sjoin.c @@ -662,6 +662,18 @@ CMD_FUNC(cmd_sjoin) parabuf[0] = '\0'; b = 1; + /* Check if we had +s and it became +p, then revert it silently (as it is no-change) */ + if (has_channel_mode_raw(oldmode.mode, 's') && has_channel_mode(channel, 'p')) + { + /* stay +s ! */ + long mode_p = get_extmode_bitbychar('p'); + long mode_s = get_extmode_bitbychar('s'); + channel->mode.mode &= ~mode_p; + channel->mode.mode |= mode_s; + /* TODO: all the code of above would ideally be in a module */ + } + /* (And the other condition, +p to +s, is already handled below by the generic code) */ + /* First, check if we had something that is now gone * note that: oldmode.* = us, channel->mode.* = merged. */ @@ -683,20 +695,6 @@ CMD_FUNC(cmd_sjoin) } } -#if 0 - // FIXME: fix this case of +p/+s merging... which should end up in +s: - // can use get_extmode_bitbychar() or shit but probably should call a hook (or sjoin thingy) instead? - - /* Check if we had +s and it became +p, then revert it... */ - if ((oldmode.mode & MODE_SECRET) && (channel->mode.mode & MODE_PRIVATE)) - { - /* stay +s ! */ - channel->mode.mode &= ~MODE_PRIVATE; - channel->mode.mode |= MODE_SECRET; - Addsingle('p'); /* - */ - queue_s = 1; - } -#endif if (b > 1) { Addsingle('+');