]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modes/umode_i.cpp
Add counter system for umodes to get rid of some O(n)
[user/henk/code/inspircd.git] / src / modes / umode_i.cpp
index 584a12ff5af043d7f1088b08fe2f1f2122b93df6..e3f81c52907a38cac04f209f93443b6617b9652c 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)
 {
 }
 
@@ -18,9 +31,15 @@ ModeAction ModeUserInvisible::OnModeChange(userrec* source, userrec* dest, chanr
        if (dest->modes[UM_INVISIBLE] != adding)
        {
                dest->modes[UM_INVISIBLE] = adding;
+               this->count += (adding ? 1: -1);
                return MODEACTION_ALLOW;
        }
 
        /* Allow the change */
        return MODEACTION_DENY;
 }
+
+unsigned int GetCount()
+{
+       return count;
+}