X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ircd%2Fchannel.c;h=355b99d958b3063e4fb37f553c61dc86021f6adc;hb=b168d1cf9ec654e8a47b94c3c79c833ce650a721;hp=e591dda3a524cff95e8f7ce74e2fc2e4f51e5f8e;hpb=732e409035898ddc9af5a44067b454b598a39106;p=ircu2.10.12-pk.git diff --git a/ircd/channel.c b/ircd/channel.c index e591dda..355b99d 100644 --- a/ircd/channel.c +++ b/ircd/channel.c @@ -2049,6 +2049,20 @@ modebuf_mode_client(struct ModeBuf *mbuf, unsigned int mode, modebuf_flush_int(mbuf, 0); } +/** Check a channel for join-delayed members. + * @param[in] chan Channel to search. + * @return Non-zero if any members are join-delayed; false if none are. + */ +static int +find_delayed_joins(const struct Channel *chan) +{ + const struct Membership *memb; + for (memb = chan->members; memb; memb = memb->next_member) + if (IsDelayedJoin(memb)) + return 1; + return 0; +} + /** The exported binding for modebuf_flush() * * @param mbuf The mode buffer to flush. @@ -2058,19 +2072,22 @@ modebuf_mode_client(struct ModeBuf *mbuf, unsigned int mode, int modebuf_flush(struct ModeBuf *mbuf) { - struct Membership *memb; - - /* Check if MODE_WASDELJOINS should be set */ - if (!(mbuf->mb_channel->mode.mode & (MODE_DELJOINS | MODE_WASDELJOINS)) - && (mbuf->mb_rem & MODE_DELJOINS)) { - for (memb = mbuf->mb_channel->members; memb; memb = memb->next_member) { - if (IsDelayedJoin(memb)) { - mbuf->mb_channel->mode.mode |= MODE_WASDELJOINS; - mbuf->mb_add |= MODE_WASDELJOINS; - mbuf->mb_rem &= ~MODE_WASDELJOINS; - break; - } - } + /* Check if MODE_WASDELJOINS should be set: */ + /* Must be set if going -D and some clients are hidden */ + if ((mbuf->mb_rem & MODE_DELJOINS) + && !(mbuf->mb_channel->mode.mode & (MODE_DELJOINS | MODE_WASDELJOINS)) + && find_delayed_joins(mbuf->mb_channel)) { + mbuf->mb_channel->mode.mode |= MODE_WASDELJOINS; + mbuf->mb_add |= MODE_WASDELJOINS; + mbuf->mb_rem &= ~MODE_WASDELJOINS; + } + /* Must be cleared if +D is set */ + if ((mbuf->mb_add & MODE_DELJOINS) + && ((mbuf->mb_channel->mode.mode & (MODE_WASDELJOINS | MODE_WASDELJOINS)) + == (MODE_WASDELJOINS | MODE_WASDELJOINS))) { + mbuf->mb_channel->mode.mode &= ~MODE_WASDELJOINS; + mbuf->mb_add &= ~MODE_WASDELJOINS; + mbuf->mb_rem |= MODE_WASDELJOINS; } return modebuf_flush_int(mbuf, 1); @@ -3138,10 +3155,6 @@ mode_parse_mode(struct ParseState *state, int *flag_p) state->add &= ~MODE_SECRET; state->del |= MODE_SECRET; } - if (flag_p[0] & MODE_DELJOINS) { - state->add &= ~MODE_WASDELJOINS; - state->del |= MODE_WASDELJOINS; - } } else { state->add &= ~flag_p[0]; state->del |= flag_p[0]; @@ -3576,18 +3589,9 @@ void RevealDelayedJoin(struct Membership *member) void CheckDelayedJoins(struct Channel *chan) { - struct Membership *memb2; - - if (chan->mode.mode & MODE_WASDELJOINS) { - for (memb2=chan->members;memb2;memb2=memb2->next_member) - if (IsDelayedJoin(memb2)) - break; - - if (!memb2) { - /* clear +d */ - chan->mode.mode &= ~MODE_WASDELJOINS; - sendcmdto_channel_butserv_butone(&his, CMD_MODE, chan, NULL, 0, - "%H -d", chan); - } + if ((chan->mode.mode & MODE_WASDELJOINS) && !find_delayed_joins(chan)) { + chan->mode.mode &= ~MODE_WASDELJOINS; + sendcmdto_channel_butserv_butone(&his, CMD_MODE, chan, NULL, 0, + "%H -d", chan); } }