mirror of
https://github.com/anope/anope.git
synced 2026-07-05 18:03:13 +02:00
Added Anope::CurTime to keep us from calling time() everywhere
This commit is contained in:
@@ -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();
|
||||
|
||||
+2
-2
@@ -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<ChannelFlags>
|
||||
* @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
|
||||
*/
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
* @param t The time the akick was added, defaults to now
|
||||
* @param lu The time the akick was last used, defaults to never
|
||||
*/
|
||||
AutoKick *AddAkick(const Anope::string &user, NickCore *akicknc, const Anope::string &reason, time_t t = time(NULL), time_t lu = 0);
|
||||
AutoKick *AddAkick(const Anope::string &user, NickCore *akicknc, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0);
|
||||
|
||||
/** Add an akick entry to the channel by reason
|
||||
* @param user The user who added the akick
|
||||
@@ -180,7 +180,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
* @param t The time the akick was added, defaults to now
|
||||
* @param lu The time the akick was last used, defaults to never
|
||||
*/
|
||||
AutoKick *AddAkick(const Anope::string &user, const Anope::string &mask, const Anope::string &reason, time_t t = time(NULL), time_t lu = 0);
|
||||
AutoKick *AddAkick(const Anope::string &user, const Anope::string &mask, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0);
|
||||
|
||||
/** Get an entry from the channel akick list
|
||||
* @param index The index in the akick vector
|
||||
|
||||
+1
-1
@@ -509,7 +509,7 @@ class CoreExport HostInfo
|
||||
* @param creator Who created the vhost
|
||||
* @param time When the vhost was craated
|
||||
*/
|
||||
void SetVhost(const Anope::string &ident, const Anope::string &host, const Anope::string &creator, time_t created = time(NULL));
|
||||
void SetVhost(const Anope::string &ident, const Anope::string &host, const Anope::string &creator, time_t created = Anope::CurTime);
|
||||
|
||||
/** Remove a users vhost
|
||||
**/
|
||||
|
||||
@@ -60,8 +60,19 @@ union CoreExport sockaddrs
|
||||
/* The same as above but not */
|
||||
inline bool operator!=(const sockaddrs &other) const { return !(*this == other); }
|
||||
|
||||
/** The equivalent of inet_pton
|
||||
* @param type AF_INET or AF_INET6
|
||||
* @param address The address to place in the sockaddr structures
|
||||
* @param pport An option port to include in the sockaddr structures
|
||||
* @throws A socket exception if given invalid IPs
|
||||
*/
|
||||
void pton(int type, const Anope::string &address, int pport = 0);
|
||||
|
||||
/** The equivalent of inet_ntop
|
||||
* @param type AF_INET or AF_INET6
|
||||
* @param address The in_addr or in_addr6 structure
|
||||
* @throws A socket exception if given an invalid structure
|
||||
*/
|
||||
void ntop(int type, const void *src);
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ class CoreExport Timer : public Extensible
|
||||
* @param now The time now
|
||||
* @param repeating Repeat this timer every time_from_now if this is true
|
||||
*/
|
||||
Timer(long time_from_now, time_t now = time(NULL), bool repeating = false);
|
||||
Timer(long time_from_now, time_t now = Anope::CurTime, bool repeating = false);
|
||||
|
||||
/** Default destructor, removes the timer from the list
|
||||
*/
|
||||
@@ -103,7 +103,7 @@ class CoreExport TimerManager : public Extensible
|
||||
/** Tick all pending timers
|
||||
* @param ctime The current time
|
||||
*/
|
||||
static void TickTimers(time_t ctime = time(NULL));
|
||||
static void TickTimers(time_t ctime = Anope::CurTime);
|
||||
|
||||
/** Compares two timers
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user