From f00e76d30a86acf0f18bcde5647eedd50de50569 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 10 Sep 2010 20:31:31 -0400 Subject: Added Anope::CurTime to keep us from calling time() everywhere --- include/anope.h | 5 +++++ include/channels.h | 4 ++-- include/modules.h | 2 +- include/regchannel.h | 4 ++-- include/services.h | 2 +- include/sockets.h | 11 +++++++++++ include/timers.h | 4 ++-- 7 files changed, 24 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/anope.h b/include/anope.h index a2cdc2d06..51a80a598 100644 --- a/include/anope.h +++ b/include/anope.h @@ -288,6 +288,11 @@ namespace Anope static const char *const compiled = __TIME__ " " __DATE__; + /** The current system time, which is pretty close to being accurate. + * Use this unless you need very specific time checks + */ + static time_t CurTime = time(NULL); + extern CoreExport string Version(); extern CoreExport string Build(); diff --git a/include/channels.h b/include/channels.h index ec886c9ca..73c97d3aa 100644 --- a/include/channels.h +++ b/include/channels.h @@ -23,7 +23,7 @@ struct UserData void Clear() { - last_use = last_start = time(NULL); + last_use = last_start = Anope::CurTime; lines = times = 0; lastline.clear(); } @@ -77,7 +77,7 @@ class CoreExport Channel : public Extensible, public Flags * @param name The channel name * @param ts The time the channel was created */ - Channel(const Anope::string &nname, time_t ts = time(NULL)); + Channel(const Anope::string &nname, time_t ts = Anope::CurTime); /** Default destructor */ diff --git a/include/modules.h b/include/modules.h index e1675c7e6..60a16a978 100644 --- a/include/modules.h +++ b/include/modules.h @@ -1237,7 +1237,7 @@ class CallBack : public Timer private: Module *m; public: - CallBack(Module *mod, long time_from_now, time_t now = time(NULL), bool repeating = false) : Timer(time_from_now, now, repeating), m(mod) + CallBack(Module *mod, long time_from_now, time_t now = Anope::CurTime, bool repeating = false) : Timer(time_from_now, now, repeating), m(mod) { m->CallBacks.push_back(this); } diff --git a/include/regchannel.h b/include/regchannel.h index 80b25abfb..fb6810220 100644 --- a/include/regchannel.h +++ b/include/regchannel.h @@ -171,7 +171,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags