m_relay.c bugfix
authorpk910 <philipp@zoelle1.de>
Tue, 28 Jun 2011 19:11:22 +0000 (21:11 +0200)
committerpk910 <philipp@zoelle1.de>
Tue, 28 Jun 2011 19:11:22 +0000 (21:11 +0200)
ircd/m_relay.c

index 3a02764832873307f5d655b0adf0af69e319a884..fc8e1cd4ce4bb356eefa65d36b1a4e2c91563c28 100644 (file)
@@ -78,17 +78,21 @@ static void mode_a_join(struct Client* cptr, char *channel, int flags) {
 }
 
 static void mode_a_check_altchan(struct Client* sptr, char *channel) {
-       static Channel *chptrb;
+       struct Channel *chptrb;
        if (!(chptrb = FindChannel(channel))) {
-      if (((channel[0] == '&') && !feature_bool(FEAT_LOCAL_CHANNELS)) || strlen(altchan) > IRCD_MIN(CHANNELLEN, feature_int(FEAT_CHANNELLEN))) {
+      if (((channel[0] == '&') && !feature_bool(FEAT_LOCAL_CHANNELS)) || strlen(channel) > IRCD_MIN(CHANNELLEN, feature_int(FEAT_CHANNELLEN))) {
         //we don't send an error message here - that would be very strange for the user, because they normaly don't know that mode +F is set
-      } else if ((chptrb = get_channel(sptr, altchan, CGT_CREATE))) {
+      } else if ((chptrb = get_channel(sptr, channel, CGT_CREATE))) {
+           struct JoinBuf create;
+        joinbuf_init(&create, sptr, sptr, JOINBUF_TYPE_CREATE, 0, TStime());
         joinbuf_join(&create, chptrb, CHFL_CHANOP | CHFL_CHANNEL_MANAGER);
                do_names(sptr, chptrb, NAMES_ALL|NAMES_EON);
+               joinbuf_flush(&create);
          }
        } else {
          //first of all check if we may even join this channel
          int err2 = 0;
+         int flags = 0;
          if (chptrb->users == 0 && !chptrb->mode.apass[0] && !(chptrb->mode.mode & MODE_PERSIST)) {
         /* Joining a zombie channel (zannel): give ops and increment TS. */
         flags = CHFL_CHANOP;
@@ -103,9 +107,11 @@ static void mode_a_check_altchan(struct Client* sptr, char *channel) {
         err2 = ERR_NEEDREGGEDNICK;
       else if (find_ban(sptr, chptrb->banlist))
         err2 = ERR_BANNEDFROMCHAN;
-      else if (*chptrb->mode.key && (!key || strcmp(key, chptrb->mode.key)))
+      else if (*chptrb->mode.key) //Fix this!
         err2 = ERR_BADCHANNELKEY;
          if(!err2) {
+           struct JoinBuf join;
+        joinbuf_init(&join, sptr, sptr, JOINBUF_TYPE_JOIN, 0, 0);
            joinbuf_join(&join, chptrb, flags);
            del_invite(sptr, chptrb);
         if (chptrb->topic[0]) {
@@ -113,6 +119,7 @@ static void mode_a_check_altchan(struct Client* sptr, char *channel) {
           send_reply(sptr, RPL_TOPICWHOTIME, chptrb->chname, chptrb->topic_nick, chptrb->topic_time);
         }
         do_names(sptr, chptrb, NAMES_ALL|NAMES_EON); /* send /names list */
+               joinbuf_flush(&join);
          }
    }
 }
@@ -223,7 +230,8 @@ signed int ms_relay(struct Client* cptr, struct Client* sptr, signed int parc, c
         struct Client *acptr;
         struct Channel *chptr;
         if(acptr = findNUser(parv[1])) {
-         if(chptr = FindChannel(parv[3]) && chptr->mode.altchan && IsChannelName(chptr->mode.altchan) && strIsIrcCh(chptr->mode.altchan)) {
+         if(chptr = FindChannel(parv[3]) && chptr->mode.altchan && 
+            IsChannelName(chptr->mode.altchan) && strIsIrcCh(chptr->mode.altchan)) {
        mode_a_check_altchan(acptr,chptr->mode.altchan);
          }
          send_reply(acptr, ERR_JOINACCESS, parv[3]);