Use time_since() and time_until() instead of open-coded variants
Use these helpers in the places where we're calling get_time() and comparing it against a single struct timeval.
This commit is contained in:
@@ -1847,7 +1847,7 @@ int in_join_list(char *chan, int server)
|
|||||||
|
|
||||||
void channel_sync(struct joinlist *tmp, char *channel)
|
void channel_sync(struct joinlist *tmp, char *channel)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
double synch_time = time_since(&tmp->tv);
|
||||||
|
|
||||||
if (tmp->gotinfo & GOTNEW)
|
if (tmp->gotinfo & GOTNEW)
|
||||||
{
|
{
|
||||||
@@ -1860,10 +1860,9 @@ void channel_sync(struct joinlist *tmp, char *channel)
|
|||||||
my_send_to_server(tmp->server, "MODE %s :%s", channel, chanmode);
|
my_send_to_server(tmp->server, "MODE %s :%s", channel, chanmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
get_time(&tv);
|
|
||||||
set_display_target(channel, LOG_CRAP);
|
set_display_target(channel, LOG_CRAP);
|
||||||
if (do_hook(CHANNEL_SYNCH_LIST, "%s %1.3f", channel, BX_time_diff(tmp->tv,tv)))
|
if (do_hook(CHANNEL_SYNCH_LIST, "%s %1.3f", channel, synch_time))
|
||||||
bitchsay("Join to %s was synched in %1.3f secs!!", channel, BX_time_diff(tmp->tv,tv));
|
bitchsay("Join to %s was synched in %1.3f secs!!", channel, synch_time);
|
||||||
#ifdef WANT_USERLIST
|
#ifdef WANT_USERLIST
|
||||||
delay_check_auto(channel);
|
delay_check_auto(channel);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -822,14 +822,12 @@ static void p_quit(char *from, char **ArgList)
|
|||||||
static int sping_reply(char *from, char *sping_dest, int server)
|
static int sping_reply(char *from, char *sping_dest, int server)
|
||||||
{
|
{
|
||||||
char buff[50];
|
char buff[50];
|
||||||
struct timeval timenow;
|
|
||||||
Sping *tmp = get_server_sping(server, sping_dest);
|
Sping *tmp = get_server_sping(server, sping_dest);
|
||||||
|
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
get_time(&timenow);
|
snprintf(buff, sizeof buff, "%2.4f", time_since(&tmp->in_sping));
|
||||||
snprintf(buff, sizeof buff, "%2.4f", BX_time_diff(tmp->in_sping, timenow));
|
|
||||||
|
|
||||||
reset_display_target();
|
reset_display_target();
|
||||||
put_it("%s", convert_output_format("$G Server pong from %W$0%n $1 seconds", "%s %s", from, buff));
|
put_it("%s", convert_output_format("$G Server pong from %W$0%n $1 seconds", "%s %s", from, buff));
|
||||||
|
|||||||
@@ -457,7 +457,6 @@ char *function_timer(char *n, char *args)
|
|||||||
char *ref = next_arg(args, &args);
|
char *ref = next_arg(args, &args);
|
||||||
TimerList *t = NULL;
|
TimerList *t = NULL;
|
||||||
double time_left;
|
double time_left;
|
||||||
struct timeval current;
|
|
||||||
|
|
||||||
if (ref && *ref)
|
if (ref && *ref)
|
||||||
t = get_timer(ref);
|
t = get_timer(ref);
|
||||||
@@ -465,8 +464,7 @@ char *function_timer(char *n, char *args)
|
|||||||
if (!t)
|
if (!t)
|
||||||
return m_strdup(empty_string);
|
return m_strdup(empty_string);
|
||||||
|
|
||||||
get_time(¤t);
|
time_left = time_until(&t->time);
|
||||||
time_left = BX_time_diff(current, t->time);
|
|
||||||
if (time_left < 0)
|
if (time_left < 0)
|
||||||
time_left = 0.0;
|
time_left = 0.0;
|
||||||
|
|
||||||
@@ -597,9 +595,6 @@ static char *schedule_timer (TimerList *ntimer)
|
|||||||
return ntimer->ref;
|
return ntimer->ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct timeval current;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TimerTimeout: Called from irc_io to help create the timeout
|
* TimerTimeout: Called from irc_io to help create the timeout
|
||||||
* part of the call to select.
|
* part of the call to select.
|
||||||
@@ -614,12 +609,11 @@ time_t TimerTimeout (void)
|
|||||||
;
|
;
|
||||||
else
|
else
|
||||||
t = MAGIC_TIMEOUT;
|
t = MAGIC_TIMEOUT;
|
||||||
get_time(¤t);
|
|
||||||
if (!PendingTimers)
|
if (!PendingTimers)
|
||||||
timeout_in = tclTimerTimeout(MAGIC_TIMEOUT);
|
timeout_in = tclTimerTimeout(MAGIC_TIMEOUT);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
timeout_in = (time_t)(BX_time_diff(current, PendingTimers->time) * 1000);
|
timeout_in = (time_t)(time_until(&PendingTimers->time) * 1000);
|
||||||
timeout_in = (time_t)(tclTimerTimeout((timeout_in < 0) ? 0 : timeout_in));
|
timeout_in = (time_t)(tclTimerTimeout((timeout_in < 0) ? 0 : timeout_in));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user