From: ian Date: Sun, 27 Jul 2008 15:17:15 +0000 (+0000) Subject: Do not increment lookahead before !!done_fdet (!) X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=7d261934d68de7d5a19e84ec7a228e9f55754675;p=trains.git Do not increment lookahead before !!done_fdet (!) --- diff --git a/hostside/safety.c b/hostside/safety.c index 14f4704..95ef1ad 100644 --- a/hostside/safety.c +++ b/hostside/safety.c @@ -281,7 +281,7 @@ typedef struct { double maxspeed; Segment *hindmost, *furthest, *desire_move; int desire_movposcomb; - int lookahead; + int lookahead, reportcount; PredictionProblemCallback *problem_callback; void *problem_callback_u; @@ -1021,14 +1021,14 @@ static int report_nextseg(TrackLocation *t, struct TrackAdvanceContext *c, char flags[6]; int r; - u->lookahead++; - if (u->lookahead > NUM_SEGMENTS * 2) { + u->reportcount++; + if (u->reportcount > NUM_SEGMENTS * 2) { ouprintf(" [... infinite loop!]\n"); abort(); } if (u->done_fdet) /* we've had foredetect */ - if (u->lookahead > u->train->plan_lookahead_nsegs) + if (++u->lookahead > u->train->plan_lookahead_nsegs) return -1; flags[0]= 0;