]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modes/umode_i.cpp
Small api change with wide reaching effects in modules - Allows modification of whats...
[user/henk/code/inspircd.git] / src / modes / umode_i.cpp
index 08af105cabbc3a05d0565dfdf2eab8f15fa3a808..5a93273757e0a7e7f8323f5e31e9c1404149ab92 100644 (file)
@@ -1,10 +1,23 @@
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
+ *
+ *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
+ * This program is free but copyrighted software; see
+ *            the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
 #include "inspircd.h"
 #include "mode.h"
 #include "channels.h"
 #include "users.h"
 #include "modes/umode_i.h"
 
-ModeUserInvisible::ModeUserInvisible() : ModeHandler('i', 0, 0, false, MODETYPE_USER, false)
+ModeUserInvisible::ModeUserInvisible(InspIRCd* Instance) : ModeHandler(Instance, 'i', 0, 0, false, MODETYPE_USER, false)
 {
 }
 
@@ -12,14 +25,21 @@ ModeAction ModeUserInvisible::OnModeChange(userrec* source, userrec* dest, chanr
 {
        /* Only opers can change other users modes */
        if ((source != dest) && (!*source->oper))
-               return MODEACTION_ALLOW;
+               return MODEACTION_DENY;
 
        /* Set the bitfields */
-       adding ? dest->modebits |= UM_INVISIBLE : dest->modebits &= ~UM_INVISIBLE;
-
-       /* Use the bitfields to build the user's mode string */
-       ModeParser::BuildModeString(dest);
+       if (dest->modes[UM_INVISIBLE] != adding)
+       {
+               dest->modes[UM_INVISIBLE] = adding;
+               this->count += (adding ? 1: -1);
+               return MODEACTION_ALLOW;
+       }
 
        /* Allow the change */
-       return MODEACTION_ALLOW;
+       return MODEACTION_DENY;
+}
+
+unsigned int ModeUserInvisible::GetCount()
+{
+       return count;
 }