X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Ftimer.cpp;h=00be97b6c0e7d20b05f7074a8d90c8c5ff1f3c27;hb=fe67c13ddf8f546bed95a9904679b3f32c708cd9;hp=f098a5e6b5f78b6ea6285c58c9bad657ceb11530;hpb=d9d99cd02dadf34bfcc220734ba0c422f0acb3e6;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/timer.cpp b/src/timer.cpp index f098a5e6b..00be97b6c 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -1,10 +1,14 @@ /* * InspIRCd -- Internet Relay Chat Daemon * + * Copyright (C) 2017 Sadie Powell + * Copyright (C) 2013-2014 Attila Molnar + * Copyright (C) 2012 Robby + * Copyright (C) 2009 Uli Schlachter + * Copyright (C) 2009 Daniel De Graaf * Copyright (C) 2008 Robin Burchell + * Copyright (C) 2007, 2010 Craig Edwards * Copyright (C) 2007 Dennis Friis - * Copyright (C) 2006-2007 Craig Edwards - * Copyright (C) 2006 Oliver Lupton * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public @@ -20,22 +24,26 @@ */ -/* $Core */ - #include "inspircd.h" -#include "timer.h" -void Timer::SetInterval(time_t newinterval) +void Timer::SetInterval(unsigned int newinterval) { - ServerInstance->Timers->DelTimer(this); + ServerInstance->Timers.DelTimer(this); secs = newinterval; SetTrigger(ServerInstance->Time() + newinterval); - ServerInstance->Timers->AddTimer(this); + ServerInstance->Timers.AddTimer(this); +} + +Timer::Timer(unsigned int secs_from_now, bool repeating) + : trigger(ServerInstance->Time() + secs_from_now) + , secs(secs_from_now) + , repeat(repeating) +{ } Timer::~Timer() { - ServerInstance->Timers->DelTimer(this); + ServerInstance->Timers.DelTimer(this); } void TimerManager::TickTimers(time_t TIME) @@ -49,8 +57,9 @@ void TimerManager::TickTimers(time_t TIME) Timers.erase(i++); if (!t->Tick(TIME)) - delete t; - else if (t->GetRepeat()) + continue; + + if (t->GetRepeat()) { t->SetTrigger(TIME + t->GetInterval()); AddTimer(t);