chiark / gitweb /
Do not increment lookahead before !!done_fdet (!)
authorian <ian>
Sun, 27 Jul 2008 15:17:15 +0000 (15:17 +0000)
committerian <ian>
Sun, 27 Jul 2008 15:17:15 +0000 (15:17 +0000)
hostside/safety.c

index 14f4704399341cec9b72fbb3b3ba75bd73a80ff0..95ef1adb2fc2278a3b5ce28e50effd44fe558345 100644 (file)
@@ -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;