]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_joinflood.cpp
Get rid of a bunch of memory-wasting C-style strings
[user/henk/code/inspircd.git] / src / modules / m_joinflood.cpp
index 853ddee755dcfd86ae0c1a34c9e355def75e69ab..54e221019ccd372a4c2b977c4baf91c4d8de19c3 100644 (file)
@@ -19,8 +19,6 @@
  */
 class joinfloodsettings : public classbase
 {
- private:
-       InspIRCd* ServerInstance;
  public:
        int secs;
        int joins;
@@ -29,7 +27,7 @@ class joinfloodsettings : public classbase
        int counter;
        bool locked;
 
-       joinfloodsettings(InspIRCd *Instance, int b, int c) : ServerInstance(Instance), secs(b), joins(c)
+       joinfloodsettings(int b, int c) : secs(b), joins(c)
        {
                reset = ServerInstance->Time() + secs;
                counter = 0;
@@ -87,7 +85,7 @@ class JoinFlood : public ModeHandler
 {
  public:
        SimpleExtItem<joinfloodsettings> ext;
-       JoinFlood(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'j', 1, 0, false, MODETYPE_CHANNEL, false),
+       JoinFlood(Module* Creator) : ModeHandler(Creator, 'j', PARAM_SETONLY, MODETYPE_CHANNEL),
                ext("joinflood", Creator) { }
 
        ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string &parameter)
@@ -137,7 +135,7 @@ class JoinFlood : public ModeHandler
                                        if (!f)
                                        {
                                                parameter = ConvToStr(njoins) + ":" +ConvToStr(nsecs);
-                                               f = new joinfloodsettings(ServerInstance, nsecs, njoins);
+                                               f = new joinfloodsettings(nsecs, njoins);
                                                ext.set(channel, f);
                                                channel->SetModeParam('j', parameter);
                                                return MODEACTION_ALLOW;
@@ -156,7 +154,7 @@ class JoinFlood : public ModeHandler
                                                        // new mode param, replace old with new
                                                        if ((nsecs > 0) && (njoins > 0))
                                                        {
-                                                               f = new joinfloodsettings(ServerInstance, nsecs, njoins);
+                                                               f = new joinfloodsettings(nsecs, njoins);
                                                                ext.set(channel, f);
                                                                channel->SetModeParam('j', parameter);
                                                                return MODEACTION_ALLOW;
@@ -196,8 +194,8 @@ class ModuleJoinFlood : public Module
 
  public:
 
-       ModuleJoinFlood(InspIRCd* Me)
-               : Module(Me), jf(Me, this)
+       ModuleJoinFlood()
+               : jf(this)
        {
 
                if (!ServerInstance->Modes->AddMode(&jf))
@@ -221,13 +219,13 @@ class ModuleJoinFlood : public Module
                return MOD_RES_PASSTHRU;
        }
 
-       void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent, bool created)
+       void OnUserJoin(Membership* memb, bool sync, bool created, CUList& excepts)
        {
                /* We arent interested in JOIN events caused by a network burst */
                if (sync)
                        return;
 
-               joinfloodsettings *f = jf.ext.get(channel);
+               joinfloodsettings *f = jf.ext.get(memb->chan);
 
                /* But all others are OK */
                if (f)
@@ -237,7 +235,7 @@ class ModuleJoinFlood : public Module
                        {
                                f->clear();
                                f->lock();
-                               channel->WriteChannelWithServ((char*)ServerInstance->Config->ServerName, "NOTICE %s :This channel has been closed to new users for 60 seconds because there have been more than %d joins in %d seconds.", channel->name.c_str(), f->joins, f->secs);
+                               memb->chan->WriteChannelWithServ((char*)ServerInstance->Config->ServerName.c_str(), "NOTICE %s :This channel has been closed to new users for 60 seconds because there have been more than %d joins in %d seconds.", memb->chan->name.c_str(), f->joins, f->secs);
                        }
                }
        }
@@ -249,7 +247,7 @@ class ModuleJoinFlood : public Module
 
        Version GetVersion()
        {
-               return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
+               return Version("Provides channel mode +j (join flood protection)", VF_COMMON | VF_VENDOR, API_VERSION);
        }
 };