]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/mode.cpp
Proper fix for clients that send a nickprefix on their commands (the rfc says they...
[user/henk/code/inspircd.git] / src / mode.cpp
index 0229eddb12a288e6b9ee46be49ceb06873964508..b983165979ec55dae0c2c4433cfce97ef1bc43ef 100644 (file)
@@ -246,6 +246,12 @@ void ModeParser::DisplayCurrentModes(userrec *user, userrec* targetuser, chanrec
        }
        else if (targetuser)
        {
+               if (targetuser->Visibility && !targetuser->Visibility->VisibleTo(user))
+               {
+                       user->WriteServ("401 %s %s :No such nick/channel",user->nick, text);
+                       return;
+               }
+
                if ((targetuser == user) || (*user->oper))
                {
                        /* Display user's current mode string */
@@ -291,6 +297,8 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
                
                while (mode && *mode)
                {
+                       unsigned char mletter = *mode;
+
                        if (*mode == '+')
                        {
                                mode++;
@@ -300,9 +308,9 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
                        /* Ensure the user doesnt request the same mode twice,
                         * so they cant flood themselves off out of idiocy.
                         */
-                       if (!sent[*mode])
+                       if (!sent[mletter])
                        {
-                               sent[*mode] = true;
+                               sent[mletter] = true;
                        }
                        else
                        {
@@ -310,17 +318,17 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
                                continue;
                        }
 
-                       if (ServerInstance->Config->HideModeLists[*mode] && (targetchannel->GetStatus(user) < STATUS_HOP))
-                       {
-                               user->WriteServ("482 %s %s :Only half-operators and above may view the +%c list",user->nick, targetchannel->name, *mode++);
-                               continue;
-                       }
-
                        ModeHandler *mh = this->FindMode(*mode, MODETYPE_CHANNEL);
                        bool display = true;
 
                        if ((mh) && (mh->IsListMode()))
                        {
+                               if (ServerInstance->Config->HideModeLists[mletter] && (targetchannel->GetStatus(user) < STATUS_HOP))
+                               {
+                                       user->WriteServ("482 %s %s :Only half-operators and above may view the +%c list",user->nick, targetchannel->name, *mode++);
+                                       continue;
+                               }
+
                                /** See below for a description of what craq this is :D
                                 */
                                unsigned char handler_id = (*mode - 65) | mask;
@@ -488,6 +496,7 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
                                                                
                                                                for (ModeWatchIter watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++)
                                                                {
+                                                                       ServerInstance->Log(DEBUG,"Call mode watcher");
                                                                        if ((*watchers)->BeforeMode(user, targetuser, targetchannel, parameter, adding, type) == false)
                                                                        {
                                                                                abort = true;
@@ -504,13 +513,28 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
                                                                if (abort)
                                                                        continue;
                                                        }
+                                                       else
+                                                       {
+                                                               /* Fix by brain: mode watchers not being called for parameterless modes */
+                                                               for (ModeWatchIter watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++)
+                                                               {
+                                                                       if ((*watchers)->BeforeMode(user, targetuser, targetchannel, parameter, adding, type) == false)
+                                                                       {
+                                                                               abort = true;
+                                                                               break;
+                                                                       }
+                                                               }
+
+                                                               if (abort)
+                                                                       continue;
+                                                       }
 
                                                        /* It's an oper only mode, check if theyre an oper. If they arent,
                                                         * eat any parameter that  came with the mode, and continue to next
                                                         */
                                                        if ((IS_LOCAL(user)) && (modehandlers[handler_id]->NeedsOper()) && (!*user->oper))
                                                        {
-                                                               user->WriteServ("481 %s :Permission Denied- Only IRC operators may %sset %s mode %c", user->nick,
+                                                               user->WriteServ("481 %s :Permission Denied - Only IRC operators may %sset %s mode %c", user->nick,
                                                                                adding ? "" : "un", type == MODETYPE_CHANNEL ? "channel" : "user",
                                                                                modehandlers[handler_id]->GetModeChar());
                                                                continue;
@@ -923,6 +947,7 @@ bool ModeParser::AddModeWatcher(ModeWatcher* mw)
        pos = (mw->GetModeChar()-65) | mask;
 
        modewatchers[pos].push_back(mw);
+
        return true;
 }