diff options
author | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-08-07 23:13:07 +0000 |
---|---|---|
committer | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-08-07 23:13:07 +0000 |
commit | 08a97e2f39961a79dd57e7310626408b20c5d9e8 (patch) | |
tree | f6cebdc6e07ae0b4af5c40d84451ad5cacf073f4 /src/physics.c | |
parent | c55491b4c777c1ae835a16f8969e0e8dede9a030 (diff) |
Measure and subtract physics time from the wait
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@233 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'src/physics.c')
-rw-r--r-- | src/physics.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/physics.c b/src/physics.c index 3472cc5..91505b9 100644 --- a/src/physics.c +++ b/src/physics.c @@ -15,6 +15,8 @@ #include <SDL.h> #include <math.h> +#include <sys/time.h> +#include <time.h> #include "types.h" #include "model.h" @@ -403,9 +405,14 @@ static void physics_process(ModelInstance *obj, Uint32 dt, Game *game) { void physics_step(Game *game, Uint32 t) { Uint32 dt; + struct timeval tv; + suseconds_t us; dt = t - game->tlast; + gettimeofday(&tv, NULL); + us = tv.tv_usec; + /* Handle things specific to the lander craft */ if ( game->thrusting ) { if ( game->fuel > 0.0 ) { @@ -454,6 +461,12 @@ void physics_step(Game *game, Uint32 t) { game_check_handoff(game); game->tlast = t; + + gettimeofday(&tv, NULL); + us = tv.tv_usec - us; + + game->time_physics = us; + } |