From 82ea67edb7f25c28f66fecc53819e7c570121f76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Sat, 12 Jul 2008 11:07:19 +0200 Subject: [PATCH] Fix integer underflow --- src/control_parser.c | 2 +- src/control_parser.rl | 2 +- src/path.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/control_parser.c b/src/control_parser.c index cc326de..1636642 100644 --- a/src/control_parser.c +++ b/src/control_parser.c @@ -389,7 +389,7 @@ _match: t->vehicle.turn = ctx->tm->vehicle.turn; gettimeofday(&t->started, NULL); } else { - fprintf(stderr, "time difference [ms]: %i\n", getcurts(t) - ctx->tm->ts); + /* fprintf(stderr, "time difference [ms]: %i\n", getcurts(t) - ctx->tm->ts); */ } t->last_ts = ctx->tm->ts; ctx->tm = NULL; diff --git a/src/control_parser.rl b/src/control_parser.rl index 64d13f7..5337432 100644 --- a/src/control_parser.rl +++ b/src/control_parser.rl @@ -41,7 +41,7 @@ static timestamp extract_ts(context *ctx, char *fpc) { t->vehicle.turn = ctx->tm->vehicle.turn; gettimeofday(&t->started, NULL); } else { - fprintf(stderr, "time difference [ms]: %i\n", getcurts(t) - ctx->tm->ts); + /* fprintf(stderr, "time difference [ms]: %i\n", getcurts(t) - ctx->tm->ts); */ } t->last_ts = ctx->tm->ts; ctx->tm = NULL; diff --git a/src/path.c b/src/path.c index b5af1b4..22491a6 100644 --- a/src/path.c +++ b/src/path.c @@ -61,7 +61,8 @@ void path_execute(trial* t,path* p){ now = getcurts(t); /*magic number for latency, send messages that much earlier*/ - while(tmp != NULL && now - 20 > tmp->ts){ + while(tmp != NULL && now > tmp->ts + 20){ + fprintf(stderr, "now: %u, ts: %u, turn: %i, accel: %i\n", now, tmp->ts, tmp->turn, tmp->accel); tmp = (command*) g_queue_pop_head(p->commands); switch(tmp->turn){ case TURN_HARD_LEFT: vehicle_hard_left(t); break;