Fix integer underflow

This commit is contained in:
Stefan Bühler 2008-07-12 11:07:19 +02:00
parent 2a5f92a16c
commit 82ea67edb7
3 changed files with 4 additions and 3 deletions

View File

@ -389,7 +389,7 @@ _match:
t->vehicle.turn = ctx->tm->vehicle.turn; t->vehicle.turn = ctx->tm->vehicle.turn;
gettimeofday(&t->started, NULL); gettimeofday(&t->started, NULL);
} else { } 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; t->last_ts = ctx->tm->ts;
ctx->tm = NULL; ctx->tm = NULL;

View File

@ -41,7 +41,7 @@ static timestamp extract_ts(context *ctx, char *fpc) {
t->vehicle.turn = ctx->tm->vehicle.turn; t->vehicle.turn = ctx->tm->vehicle.turn;
gettimeofday(&t->started, NULL); gettimeofday(&t->started, NULL);
} else { } 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; t->last_ts = ctx->tm->ts;
ctx->tm = NULL; ctx->tm = NULL;

View File

@ -61,7 +61,8 @@ void path_execute(trial* t,path* p){
now = getcurts(t); now = getcurts(t);
/*magic number for latency, send messages that much earlier*/ /*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); tmp = (command*) g_queue_pop_head(p->commands);
switch(tmp->turn){ switch(tmp->turn){
case TURN_HARD_LEFT: vehicle_hard_left(t); break; case TURN_HARD_LEFT: vehicle_hard_left(t); break;