aboutsummaryrefslogtreecommitdiff
path: root/plugins/game/game.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/game/game.c')
-rw-r--r--plugins/game/game.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/plugins/game/game.c b/plugins/game/game.c
index 5d5c31a..152a5c9 100644
--- a/plugins/game/game.c
+++ b/plugins/game/game.c
@@ -3,7 +3,6 @@
#include <unistd.h>
#include <assert.h>
#include <ctype.h>
-#include <time.h>
#include <signal.h>
#include <termios.h>
#include <math.h>
@@ -125,6 +124,11 @@ void *make_buffer(void *ptr, size_t size)
return buf;
}
+double calculate_dtime(struct timespec from, struct timespec to)
+{
+ return (double) (to.tv_sec - from.tv_sec) + (double) (to.tv_nsec - from.tv_nsec) / 1000000000.0;
+}
+
/* Game-related utility functions */
void quit()
@@ -517,7 +521,7 @@ void game()
while (running) {
clock_gettime(CLOCK_REALTIME, &ts);
- double dtime = (double) (ts.tv_sec - ts_old.tv_sec) + (double) (ts.tv_nsec - ts_old.tv_nsec) / 1000000000.0;
+ double dtime = calculate_dtime(ts_old, ts);
ts_old = ts;
bool dead = player_dead();