]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/timer.cpp
Move InspIRCd::IsValidMask() to helperfuncs.cpp
[user/henk/code/inspircd.git] / src / timer.cpp
index ab0e9456c75f24f9001a27094e7ed496f567cf95..a79105f5292d23e5ce6599619c703897f1990461 100644 (file)
@@ -14,7 +14,7 @@
 #include "inspircd.h"
 #include "timer.h"
 
-TimerManager::TimerManager() : CantDeleteHere(false)
+TimerManager::TimerManager(InspIRCd* Instance) : CantDeleteHere(false), ServerInstance(Instance)
 {
 }
 
@@ -33,7 +33,7 @@ void TimerManager::TickTimers(time_t TIME)
                 */
                for (timergroup::iterator y = x->begin(); y != x->end(); y++)
                {
-                       InspTimer* n = *y;
+                       Timer* n = *y;
                        n->Tick(TIME);
                        if (n->GetRepeat())
                        {
@@ -52,7 +52,7 @@ void TimerManager::TickTimers(time_t TIME)
        this->CantDeleteHere = false;
 }
 
-void TimerManager::DelTimer(InspTimer* T)
+void TimerManager::DelTimer(Timer* T)
 {
        if (this->CantDeleteHere)
        {
@@ -79,7 +79,7 @@ void TimerManager::DelTimer(InspTimer* T)
                timergroup* x = found->second;
                for (timergroup::iterator y = x->begin(); y != x->end(); y++)
                {
-                       InspTimer* n = *y;
+                       Timer* n = *y;
                        if (n == T)
                        {
                                DELETE(n);
@@ -104,39 +104,11 @@ void TimerManager::DelTimer(InspTimer* T)
  */
 void TimerManager::TickMissedTimers(time_t TIME)
 {
-       /** See comment above in TickTimers
-        */
-       this->CantDeleteHere = true;
-
        for (time_t n = TIME-1; n > TIME-120; n--)
-       {
-               timerlist::iterator found = Timers.find(n);
-               if (found != Timers.end())
-               {
-                       timergroup* x = found->second;
-                       for (timergroup::iterator y = x->begin(); y != x->end(); y++)
-                       {
-                               InspTimer* z = *y;
-                               z->Tick(TIME);
-                               if (z->GetRepeat())
-                               {
-                                       AddTimer(z, z->GetSecs());
-                               }
-                               else
-                               {
-                                       DELETE(z);
-                               }
-                       }
-
-                       Timers.erase(found);
-                       DELETE(x);
-               }
-       }
-
-       this->CantDeleteHere = false;
+               this->TickTimers(TIME);
 }
 
-void TimerManager::AddTimer(InspTimer* T, long secs_from_now)
+void TimerManager::AddTimer(Timer* T, long secs_from_now)
 {
        timergroup* x = NULL;
 
@@ -144,7 +116,7 @@ void TimerManager::AddTimer(InspTimer* T, long secs_from_now)
        if (!secs_from_now)
                time_to_trigger = T->GetTimer();
        else
-               time_to_trigger = secs_from_now + time(NULL);
+               time_to_trigger = secs_from_now + ServerInstance->Time();
 
        timerlist::iterator found = Timers.find(time_to_trigger);