]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_messageflood.cpp
Attach to events and register services in init()
[user/henk/code/inspircd.git] / src / modules / m_messageflood.cpp
index e0b30163c28c5af598e895c69973167ad4ff8e08..a2fdc115ef9b65bc0c35fc946b8035f4ec1da267 100644 (file)
@@ -75,8 +75,6 @@ class MsgFlood : public ModeHandler
 
        ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
        {
-               floodsettings *f = ext.get(channel);
-
                if (adding)
                {
                        std::string::size_type colon = parameter.find(':');
@@ -97,6 +95,7 @@ class MsgFlood : public ModeHandler
                                return MODEACTION_DENY;
                        }
 
+                       floodsettings* f = ext.get(channel);
                        if ((f) && (nlines == f->lines) && (nsecs == f->secs) && (ban == f->ban))
                                // mode params match
                                return MODEACTION_DENY;
@@ -108,15 +107,13 @@ class MsgFlood : public ModeHandler
                }
                else
                {
-                       if (f)
-                       {
-                               ext.unset(channel);
-                               channel->SetModeParam('f', "");
-                               return MODEACTION_ALLOW;
-                       }
-               }
+                       if (!channel->IsModeSet('f'))
+                               return MODEACTION_DENY;
 
-               return MODEACTION_DENY;
+                       ext.unset(channel);
+                       channel->SetModeParam('f', "");
+                       return MODEACTION_ALLOW;
+               }
        }
 };
 
@@ -128,6 +125,10 @@ class ModuleMsgFlood : public Module
 
        ModuleMsgFlood()
                : mf(this)
+       {
+       }
+
+       void init()
        {
                if (!ServerInstance->Modes->AddMode(&mf))
                        throw ModuleException("Could not add new modes!");