estimate tic (2)
authorLaurent Mazet <mazet@softndesign.org>
Mon, 2 Sep 2024 21:51:11 +0000 (23:51 +0200)
committerLaurent Mazet <mazet@softndesign.org>
Mon, 2 Sep 2024 21:51:11 +0000 (23:51 +0200)
time.c

diff --git a/time.c b/time.c
index 8ecebf4cf013c50579dd1122cde93fecade3fdab..7760d331a22ca346035ee53d25527f105a3c6339 100644 (file)
--- a/time.c
+++ b/time.c
@@ -29,7 +29,7 @@ int isovertime (timeval_t *t)
     struct timeval _c;
     struct timeval *c = &_c;
     gettimeofday (c, NULL);
-    VERBOSE (INFO, FILE *log = fopen ("snake.log", "a"); long msec = (c->tv_sec == t->tv_sec) ? ((long)c->tv_usec - (long)t->tv_usec) : ((long)t->tv_usec - (long)c->tv_usec); fprintf (log, "diff: %ld\n", msec / 1000); fclose (log));
+    VERBOSE (INFO, FILE *log = fopen ("snake.log", "a"); long msec = (c->tv_usec - t->tv_usec) / 1000; if (c->tv_sec != t->tv_sec) msec += 1000; fprintf (log, "diff: %ld\n", msec); fclose (log));
     return ((t->tv_sec < c->tv_sec) || ((t->tv_sec == c->tv_sec) && ( t->tv_usec < c->tv_usec)));
 }