]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_safelist.cpp
AMD64 warning 'fix' which tested fine when I added it seems to now...stop things...
[user/henk/code/inspircd.git] / src / modules / m_safelist.cpp
index 127990051ca0e5026fd3523adddc7b024ef55d87..fb5513fe25ca2cde1c73e06d9d06345d6c37049d 100644 (file)
@@ -97,26 +97,35 @@ class ListTimer : public InspTimer
                                                WriteServ(u->fd,"321 %s Channel :Users Name",u->nick);
                                         chan = Srv->GetChannelIndex(ld->list_position);
                                         /* spool details */
-                                        if (chan)
+                                       bool has_user = (chan && chan->HasUser(u));
+                                        if ((chan) && (((!(chan->modes[CM_PRIVATE])) && (!(chan->modes[CM_SECRET]))) || (has_user)))
                                         {
                                                 /* Increment total plus linefeed */
-                                                int counter = snprintf(buffer,MAXBUF,"322 %s %s %d :[+%s] %s",u->nick,chan->name,usercount_i(chan),chanmodes(chan,has_channel(u,chan)),chan->topic);
-                                                amount_sent += counter + 4 + Srv->GetServerName().length();
-                                                log(DEBUG,"m_safelist.so: Sent %ld of safe %ld / 2",amount_sent,u->sendqmax);
-                                                WriteServ_NoFormat(u->fd,buffer);
+                                               long users = usercount_i(chan);
+                                               /* If there are only invisible users on the channel, dont show it */
+                                               if (users)
+                                               {
+                                                       int counter = snprintf(buffer,MAXBUF,"322 %s %s %ld :[+%s] %s",u->nick,chan->name,users,chanmodes(chan,has_user),chan->topic);
+                                                       amount_sent += counter + 4 + Srv->GetServerName().length();
+                                                       log(DEBUG,"m_safelist.so: Sent %ld of safe %ld / 4",amount_sent,u->sendqmax);
+                                                       WriteServ_NoFormat(u->fd,buffer);
+                                               }
                                         }
                                         else
                                         {
-                                                if (!ld->list_ended)
-                                                {
-                                                        ld->list_ended = true;
-                                                        WriteServ(u->fd,"323 %s :End of channel list.",u->nick);
-                                                }
+                                               if (!chan)
+                                               {
+                                                       if (!ld->list_ended)
+                                                       {
+                                                               ld->list_ended = true;
+                                                               WriteServ(u->fd,"323 %s :End of channel list.",u->nick);
+                                                       }
+                                               }
                                         }
 
                                         ld->list_position++;
                                 }
-                                while ((chan != NULL) && (amount_sent < (u->sendqmax / 2)));
+                                while ((chan != NULL) && (amount_sent < (u->sendqmax / 4)));
                         }
                 }
 
@@ -157,7 +166,7 @@ class ModuleSafeList : public Module
         * OnPreCommand()
         *   Intercept the LIST command.
         */ 
-       virtual int OnPreCommand(std::string command, char **parameters, int pcnt, userrec *user, bool validated)
+       virtual int OnPreCommand(const std::string &command, char **parameters, int pcnt, userrec *user, bool validated)
        {
                /* If the command doesnt appear to be valid, we dont want to mess with it. */
                if (!validated)
@@ -246,7 +255,7 @@ class ModuleSafeList : public Module
                output.append(" SAFELIST");
        }
 
-       virtual void OnUserQuit(userrec* user, std::string message)
+       virtual void OnUserQuit(userrec* user, const std::string &message)
        {
                this->OnCleanup(TYPE_USER,user);
        }