]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/message.cpp
Decide that it wasn't quite appropriate :(
[user/henk/code/inspircd.git] / src / message.cpp
index eb95bde56f46aa38f50407e37c1be363daf89797..4f8e25bee7e0dc7a3370aeff581162be8ecd922d 100644 (file)
@@ -214,7 +214,7 @@ void ChangeName(userrec* user, const char* gecos)
                        return;
                FOREACH_MOD(I_OnChangeName,OnChangeName(user,gecos));
        }
-       strlcpy(user->fullname,gecos,MAXBUF);
+       strlcpy(user->fullname,gecos,MAXGECOS+1);
 }
 
 void ChangeDisplayedHost(userrec* user, const char* host)
@@ -228,6 +228,7 @@ void ChangeDisplayedHost(userrec* user, const char* host)
                FOREACH_MOD(I_OnChangeHost,OnChangeHost(user,host));
         }
        strlcpy(user->dhost,host,160);
+       WriteServ(user->fd,"396 %s %s :is now your hidden host",user->nick,user->dhost);
 }
 
 /* verify that a user's ident and nickname is valid */
@@ -243,7 +244,7 @@ int isident(const char* n)
         {
                 return 0;
         }
-        for (char* i = n; *i; i++)
+        for (char* i = (char*)n; *i; i++)
         {
                 if ((*i >= 'A') && (*i <= '}'))
                 {
@@ -269,7 +270,7 @@ int isnick(const char* n)
        {
                return 0;
        }
-       for (char* i = n; *i; i++)
+       for (char* i = (char*)n; *i; i++)
        {
                /* can occur anywhere in a nickname */
                if ((*i >= 'A') && (*i <= '}'))
@@ -324,6 +325,24 @@ char* cmode(userrec *user, chanrec *chan)
        return "";
 }
 
+int cflags(userrec *user, chanrec *chan)
+{
+       if ((!chan) || (!user))
+               return 0;
+
+       for (unsigned int i = 0; i < user->chans.size(); i++)
+       {
+               if (user->chans[i].channel)
+               {
+                       if ((!strcasecmp(user->chans[i].channel->name,chan->name)) && (chan != NULL))
+                       {
+                               return user->chans[i].uc_modes;
+                       }
+               }
+       }
+       return 0;
+}
+
 /* returns the status value for a given user on a channel, e.g. STATUS_OP for
  * op, STATUS_VOICE for voice etc. If the user has several modes set, the
  * highest mode the user has must be returned. */
@@ -406,7 +425,7 @@ void TidyBan(char *ban)
        pos_of_pling++;
        pos_of_at++;
 
-       strlcpy(NICK,temp,NICKMAX);
+       strlcpy(NICK,temp,NICKMAX-1);
        strlcpy(IDENT,pos_of_pling,IDENTMAX+1);
        strlcpy(HOST,pos_of_at,160);
 
@@ -424,6 +443,7 @@ std::string chlist(userrec *user,userrec* source)
        {
                return lst;
        }
+       bool userinvisible = (strchr(user->modes,'i'));
        for (unsigned int i = 0; i < user->chans.size(); i++)
        {
                if (user->chans[i].channel != NULL)
@@ -433,8 +453,9 @@ std::string chlist(userrec *user,userrec* source)
                                cmp = std::string(user->chans[i].channel->name) + " ";
                                if (!strstr(lst.c_str(),cmp.c_str()))
                                {
-                                       // if the channel is NOT private/secret, OR the source user is on the channel
-                                       if (((!(user->chans[i].channel->binarymodes & CM_PRIVATE)) && (!(user->chans[i].channel->binarymodes & CM_SECRET))) || (has_channel(source,user->chans[i].channel)))
+                                       // if the channel is NOT private/secret, OR the source user is on the channel, AND the user is not invisible.
+                                       // if the user is the same as the source, shortcircuit the comparison.
+                                       if ((source == user) || ((((!(user->chans[i].channel->binarymodes & CM_PRIVATE)) && (!(user->chans[i].channel->binarymodes & CM_SECRET)) && (!userinvisible)) || (has_channel(source,user->chans[i].channel)))))
                                        {
                                                lst = lst + std::string(cmode(user,user->chans[i].channel)) + std::string(user->chans[i].channel->name) + " ";
                                        }