]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspircd.cpp
Left figure from output
[user/henk/code/inspircd.git] / src / inspircd.cpp
index 744a5ece94e711e234d10e8321a0e4c2ace6a80e..a92a8ffdcb02177e7712814b0c7eea475b18c546 100644 (file)
@@ -716,39 +716,33 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri
 
        log(DEBUG,"Passed channel checks");
        
-       for (int index =0; index != MAXCHANS; index++)
+       for (unsigned int index =0; index < user->chans.size(); index++)
        {
-               log(DEBUG,"Check location %d",index);
                if (user->chans[index].channel == NULL)
                {
-                       log(DEBUG,"Adding into their channel list at location %d",index);
-
-                       if (created == 2) 
-                       {
-                               /* first user in is given ops */
-                               user->chans[index].uc_modes = UCMODE_OP;
-                       }
-                       else
-                       {
-                               user->chans[index].uc_modes = 0;
-                       }
-                       user->chans[index].channel = Ptr;
-                       Ptr->AddUser((char*)user);
-                       WriteChannel(Ptr,user,"JOIN :%s",Ptr->name);
-                       
-                       log(DEBUG,"Sent JOIN to client");
-
-                       if (Ptr->topicset)
-                       {
-                               WriteServ(user->fd,"332 %s %s :%s", user->nick, Ptr->name, Ptr->topic);
-                               WriteServ(user->fd,"333 %s %s %s %lu", user->nick, Ptr->name, Ptr->setby, (unsigned long)Ptr->topicset);
-                       }
-                       userlist(user,Ptr);
-                       WriteServ(user->fd,"366 %s %s :End of /NAMES list.", user->nick, Ptr->name);
-                       //WriteServ(user->fd,"324 %s %s +%s",user->nick, Ptr->name,chanmodes(Ptr));
-                       //WriteServ(user->fd,"329 %s %s %lu", user->nick, Ptr->name, (unsigned long)Ptr->created);
-                       FOREACH_MOD OnUserJoin(user,Ptr);
-                       return Ptr;
+                       return ForceChan(Ptr,user->chans[index],user,created);
+               }
+       }
+       /* XXX: If the user is an oper here, we can just extend their user->chans vector by one
+        * and put the channel in here. Same for remote users which are not bound by
+        * the channel limits. Otherwise, nope, youre boned.
+        */
+       if (strcasecmp(user->server,ServerName))
+       {
+               ucrec a;
+               chanrec* c = ForceChan(Ptr,a,user,created);
+               user->chans.push_back(a);
+               return c;
+       }
+       else if (strchr(user->modes,'o'))
+       {
+               /* Oper allows extension up to the OPERMAXCHANS value */
+               if (user->chans.size() < OPERMAXCHANS)
+               {
+                       ucrec a;
+                       chanrec* c = ForceChan(Ptr,a,user,created);
+                       user->chans.push_back(a);
+                       return c;
                }
        }
        log(DEBUG,"add_channel: user channel max exceeded: %s %s",user->nick,cname);
@@ -756,6 +750,32 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri
        return NULL;
 }
 
+chanrec* ForceChan(chanrec* Ptr,ucrec &a,userrec* user, int created)
+{
+       if (created == 2)
+       {
+               /* first user in is given ops */
+               a.uc_modes = UCMODE_OP;
+       }
+       else
+       {
+               a.uc_modes = 0;
+       }
+       a.channel = Ptr;
+       Ptr->AddUser((char*)user);
+       WriteChannel(Ptr,user,"JOIN :%s",Ptr->name);
+       log(DEBUG,"Sent JOIN to client");
+       if (Ptr->topicset)
+       {
+               WriteServ(user->fd,"332 %s %s :%s", user->nick, Ptr->name, Ptr->topic);
+               WriteServ(user->fd,"333 %s %s %s %lu", user->nick, Ptr->name, Ptr->setby, (unsigned long)Ptr->topicset);
+       }
+       userlist(user,Ptr);
+       WriteServ(user->fd,"366 %s %s :End of /NAMES list.", user->nick, Ptr->name);
+       FOREACH_MOD OnUserJoin(user,Ptr);
+       return Ptr;
+}
+
 /* remove a channel from a users record, and remove the record from memory
  * if the channel has become empty */
 
@@ -784,7 +804,7 @@ chanrec* del_channel(userrec *user, const char* cname, const char* reason, bool
        FOREACH_MOD OnUserPart(user,Ptr);
        log(DEBUG,"del_channel: removing: %s %s",user->nick,Ptr->name);
        
-       for (int i =0; i != MAXCHANS; i++)
+       for (unsigned int i =0; i < user->chans.size(); i++)
        {
                /* zap it from the channel list of the user */
                if (user->chans[i].channel == Ptr)
@@ -879,7 +899,7 @@ void kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason)
 
        FOREACH_MOD OnUserKick(src,user,Ptr,reason);
 
-       for (int i =0; i != MAXCHANS; i++)
+       for (unsigned int i =0; i < user->chans.size(); i++)
        {
                /* zap it from the channel list of the user */
                if (user->chans[i].channel)
@@ -1443,11 +1463,11 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip)
        clientlist[tempnick]->sendqmax = class_sqmax;
        clientlist[tempnick]->recvqmax = class_rqmax;
 
+       ucrec a;
+       a.channel = NULL;
+       a.uc_modes = 0;
        for (int i = 0; i < MAXCHANS; i++)
-       {
-               clientlist[tempnick]->chans[i].channel = NULL;
-               clientlist[tempnick]->chans[i].uc_modes = 0;
-       }
+               clientlist[tempnick]->chans.push_back(a);
 
        if (clientlist.size() > SoftLimit)
        {