]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_nickflood.cpp
Change /CHECK <#channel> to correctly report timestamp since it might have been TS...
[user/henk/code/inspircd.git] / src / modules / m_nickflood.cpp
index 72e2831dae4f827aae4cc95c06bf305b667c41d9..10ae40cb752c69859246f3e5d5aa6a69d939733a 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
  */
 class nickfloodsettings : public classbase
 {
+ private:
+       InspIRCd* ServerInstance;
  public:
-
        int secs;
        int nicks;
        time_t reset;
        time_t unlocktime;
        int counter;
        bool locked;
-       InspIRCd* ServerInstance;
-
-       nickfloodsettings() : secs(0), nicks(0) {};
 
-       nickfloodsettings(int b, int c) : secs(b), nicks(c)
+       nickfloodsettings(InspIRCd *Instance, int b, int c) : ServerInstance(Instance), secs(b), nicks(c)
        {
-               reset = time(NULL) + secs;
+               reset = Instance->Time() + secs;
                counter = 0;
                locked = false;
        };
@@ -41,10 +39,10 @@ class nickfloodsettings : public classbase
        void addnick()
        {
                counter++;
-               if (time(NULL) > reset)
+               if (ServerInstance->Time() > reset)
                {
                        counter = 0;
-                       reset = time(NULL) + secs;
+                       reset = ServerInstance->Time() + secs;
                }
        }
 
@@ -62,7 +60,7 @@ class nickfloodsettings : public classbase
        {
                if (locked)
                {
-                       if (time(NULL) > unlocktime)
+                       if (ServerInstance->Time() > unlocktime)
                        {
                                locked = false;
                                return false;
@@ -78,7 +76,7 @@ class nickfloodsettings : public classbase
        void lock()
        {
                locked = true;
-               unlocktime = time(NULL) + 60;
+               unlocktime = ServerInstance->Time() + 60;
        }
 
 };
@@ -144,7 +142,7 @@ class NickFlood : public ModeHandler
                                        if (!channel->GetExt("nickflood", dummy))
                                        {
                                                parameter = ConvToStr(nnicks) + ":" +ConvToStr(nsecs);
-                                               nickfloodsettings *f = new nickfloodsettings(nsecs,nnicks);
+                                               nickfloodsettings *f = new nickfloodsettings(ServerInstance, nsecs, nnicks);
                                                channel->Extend("nickflood", f);
                                                channel->SetMode('F', true);
                                                channel->SetModeParam('F', parameter.c_str(), true);
@@ -167,7 +165,7 @@ class NickFlood : public ModeHandler
                                                                nickfloodsettings* f;
                                                                channel->GetExt("nickflood", f);
                                                                delete f;
-                                                               f = new nickfloodsettings(nsecs, nnicks);
+                                                               f = new nickfloodsettings(ServerInstance, nsecs, nnicks);
                                                                channel->Shrink("nickflood");
                                                                channel->Extend("nickflood", f);
                                                                channel->SetModeParam('F', cur_param.c_str(), false);