]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_timedbans.cpp
Fix memory leak and invalid vtable location on unload of m_sslinfo
[user/henk/code/inspircd.git] / src / modules / m_timedbans.cpp
index e18bca6a5ee9a386b09d7742af256bce937ebb8f..cab7f8f6ec5a898828c94f3ccb71dd09d0977f0d 100644 (file)
@@ -33,9 +33,8 @@ timedbans TimedBanList;
 class CommandTban : public Command
 {
  public:
-       CommandTban (InspIRCd* Instance) : Command(Instance,"TBAN", 0, 3)
+       CommandTban (InspIRCd* Instance, Module* Creator) : Command(Instance, Creator,"TBAN", 0, 3)
        {
-               this->source = "m_timedbans.so";
                syntax = "<channel> <duration> <banmask>";
                TRANSLATE4(TR_TEXT, TR_TEXT, TR_TEXT, TR_END);
        }
@@ -112,14 +111,12 @@ class CommandTban : public Command
 
 class ModuleTimedBans : public Module
 {
-       CommandTban* mycommand;
+       CommandTban cmd;
  public:
        ModuleTimedBans(InspIRCd* Me)
-               : Module(Me)
+               : Module(Me), cmd(Me, this)
        {
-
-               mycommand = new CommandTban(ServerInstance);
-               ServerInstance->AddCommand(mycommand);
+               ServerInstance->AddCommand(&cmd);
                TimedBanList.clear();
                Implementation eventlist[] = { I_OnDelBan, I_OnBackgroundTimer };
                ServerInstance->Modules->Attach(eventlist, this, 2);
@@ -130,7 +127,7 @@ class ModuleTimedBans : public Module
                TimedBanList.clear();
        }
 
-       virtual int OnDelBan(User* source, Channel* chan, const std::string &banmask)
+       virtual ModResult OnDelBan(User* source, Channel* chan, const std::string &banmask)
        {
                irc::string listitem = banmask.c_str();
                irc::string thischan = chan->name.c_str();
@@ -144,7 +141,7 @@ class ModuleTimedBans : public Module
                                break;
                        }
                }
-               return 0;
+               return MOD_RES_PASSTHRU;
        }
 
        virtual void OnBackgroundTimer(time_t curtime)
@@ -153,20 +150,20 @@ class ModuleTimedBans : public Module
                {
                        if (curtime > i->expire)
                        {
-                               std::string chan = i->mask;
+                               std::string chan = i->channel;
                                std::string mask = i->mask;
                                Channel* cr = ServerInstance->FindChan(chan);
                                i = TimedBanList.erase(i);
                                if (cr)
                                {
                                        std::vector<std::string> setban;
-                                       setban.push_back(safei->channel);
+                                       setban.push_back(chan);
                                        setban.push_back("-b");
                                        setban.push_back(mask);
 
                                        CUList empty;
-                                       std::string expiry = "*** Timed ban on " + safei->mask + " expired.";
-                                       cr->WriteChannelWithServ(ServerInstance->FakeClient, true, '@', empty, "NOTICE %s :%s", cr->name.c_str(), expiry.c_str());
+                                       std::string expiry = "*** Timed ban on " + chan + " expired.";
+                                       cr->WriteAllExcept(ServerInstance->FakeClient, true, '@', empty, "NOTICE %s :%s", cr->name.c_str(), expiry.c_str());
                                        ServerInstance->PI->SendChannelNotice(cr, '@', expiry);
                                        if (ServerInstance->Config->AllowHalfop)
                                        {