+ switch (flag) {
+ case FLAG_HIDDENHOST:
+ /* Local users cannot set +x unless FEAT_HOST_HIDING is true. */
+ if (MyConnect(cptr) && !feature_bool(FEAT_HOST_HIDING))
+ return 0;
+ break;
+ case FLAG_ACCOUNT:
+ /* Invalidate all bans against the user so we check them again */
+ for (chan = (cli_user(cptr))->channel; chan;
+ chan = chan->next_channel)
+ ClearBanValid(chan);
+ break;
+ default:
+ return 0;
+ }
+
+ SetFlag(cptr, flag);
+ if (!HasFlag(cptr, FLAG_HIDDENHOST) || !HasFlag(cptr, FLAG_ACCOUNT))
+ return 0;
+
+ sendcmdto_common_channels_butone(cptr, CMD_QUIT, cptr, ":Registered");
+ ircd_snprintf(0, cli_user(cptr)->host, HOSTLEN, "%s.%s",
+ cli_user(cptr)->account, feature_str(FEAT_HIDDEN_HOST));
+
+ /* ok, the client is now fully hidden, so let them know -- hikari */
+ if (MyConnect(cptr))
+ send_reply(cptr, RPL_HOSTHIDDEN, cli_user(cptr)->host);
+
+ /*
+ * Go through all channels the client was on, rejoin him
+ * and set the modes, if any
+ */
+ for (chan = cli_user(cptr)->channel; chan; chan = chan->next_channel)
+ {
+ if (IsZombie(chan))
+ continue;
+ /* Send a JOIN unless the user's join has been delayed. */
+ if (!IsDelayedJoin(chan))
+ sendcmdto_channel_butserv_butone(cptr, CMD_JOIN, chan->channel, cptr, 0,
+ "%H", chan->channel);
+ if (IsChanOp(chan) && HasVoice(chan))
+ sendcmdto_channel_butserv_butone(&his, CMD_MODE, chan->channel, cptr, 0,
+ "%H +ov %C %C", chan->channel, cptr,
+ cptr);
+ else if (IsChanOp(chan) || HasVoice(chan))
+ sendcmdto_channel_butserv_butone(&his, CMD_MODE, chan->channel, cptr, 0,
+ "%H +%c %C", chan->channel, IsChanOp(chan) ? 'o' : 'v', cptr);
+ }
+ return 0;
+}
+
+/** Set a user's mode. This function checks that \a cptr is trying to
+ * set his own mode, prevents local users from setting inappropriate
+ * modes through this function, and applies any other side effects of
+ * a successful mode change.