chiark / gitweb /
get initial resolution more right
authorian <ian>
Sun, 8 Jun 2008 00:47:25 +0000 (00:47 +0000)
committerian <ian>
Sun, 8 Jun 2008 00:47:25 +0000 (00:47 +0000)
hostside/resolve.c
hostside/safety.c

index 87947d07f69107ce424bdd84e5c7ad6c9b3b47b6..c041cc671650f9b9bdadc946eab87ae3f018e3da 100644 (file)
@@ -428,7 +428,11 @@ static int findhead_nextseg(TrackLocation *t, struct TrackAdvanceContext *c,
   t->seg->tr_backwards= t->backwards;
   t->seg->resfin_done= 1;
 
-  if (!t->seg->res_detect) { u->extraspace= 0; return -1; }
+  if (!t->seg->res_detect) {
+    u->train->plan_lookahead_nsegs= 1;
+    u->extraspace= 0;
+    return -1;
+  }
   u->train->foredetect= t->seg;
   return 0;
 }
@@ -477,6 +481,7 @@ static int resolve_complete_ends_train(Train *tra) {
   t.backwards= t.seg->tr_backwards ^ tra->backwards;
 
   tra->backwards= 0;
+  tra->plan_lookahead_nsegs= 0;
 
   tc.distance= TL_DIST_INF;
   tc.nextseg= findhead_nextseg;
index e67f85ae019fd3731d3ce60290664e691387b873..485b639f473a4e12786d3c78bc1815ab19096904 100644 (file)
@@ -271,7 +271,8 @@ typedef struct {
     walk_compute_polarise:1, /* nose_nextseg still needs to worry */
     need_polarise:1, /* when we commit */
     train_polarity_inverted:1, /* right now, or if know_best, the best */
-    know_best_polarity:1; /* longest-lasting into the future */
+    know_best_polarity:1, /* longest-lasting into the future */
+    done_fdet:1; /* for report_nextseg */
   TrackLocation nose, fdet, tail;
   TrackAdvanceContext nosec, tailc, fdetc;
   TimeInterval elapsed; /* from now, minimum */
@@ -987,7 +988,7 @@ static int report_nextseg(TrackLocation *t, struct TrackAdvanceContext *c,
   char flags[6];
   int r;
 
-  if (!u->usecurrentposn) /* we've had foredetect */
+  if (u->done_fdet) /* we've had foredetect */
     if (++u->lookahead > u->train->plan_lookahead_nsegs)
       return -1;
 
@@ -1000,6 +1001,7 @@ static int report_nextseg(TrackLocation *t, struct TrackAdvanceContext *c,
   if (t->seg == u->train->foredetect) {
     strcat(flags,"!");
     u->usecurrentposn= 0;
+    u->done_fdet= 1;
   }
 
   ouprintf(" %s%s", t->backwards?"-":"", t->seg->i->pname);
@@ -1021,6 +1023,7 @@ void report_train_ownerships(Train *tra, Segment *hindmost,
   u.train= tra;
   u.hindmost= 0;
   u.usecurrentposn= !always_use_motions;
+  u.done_fdet= 0;
   
   /* Walk along the train printing its segments: */
   ouprintf("train %s has", tra->pname);