chiark / gitweb /
seems to be able to polarise
authorian <ian>
Sun, 4 May 2008 21:00:30 +0000 (21:00 +0000)
committerian <ian>
Sun, 4 May 2008 21:00:30 +0000 (21:00 +0000)
hostside/safety.c

index 58bb0853a9016b341bbf9846816ba2961a2322f8..69774f959497c7655ccd2884e0f6321537de52f6 100644 (file)
@@ -345,7 +345,8 @@ static int initpresent_nextseg(TrackLocation *t, TrackAdvanceContext *c,
   PredictUserContext *u= c->u;
   t->seg->now_present= t->seg->pred_present= t->seg->will_polarise= 1;
   t->seg->until= 0;
-  u->noninv_tally[!t->backwards]++; /* ! since going backwards along train */
+  if (!t->seg->i->invertible)
+    u->noninv_tally[!t->backwards]++; /* ! since going backwards along train */
   return 0;
 }
 
@@ -455,7 +456,8 @@ static int tail_nextseg(TrackLocation *t, TrackAdvanceContext *c,
 
   pred_callback_debug(" tail_nextseg",t,c);
 
-  u->noninv_tally[leaving->tr_backwards]--;
+  if (!t->seg->i->invertible)
+    u->noninv_tally[leaving->tr_backwards]--;
 
   if (t->seg->pred_vacated) return 0; /* only vacate once */
   t->seg->pred_present= 0;
@@ -599,21 +601,20 @@ static int report_nextseg(TrackLocation *t, struct TrackAdvanceContext *c,
 
   if (t->seg->det_expected)
     strcat(flags,"*");
+  if (t->seg->det_ignore)
+    strcat(flags,".");
   if (t->seg == u->train->foredetect) {
     strcat(flags,"!");
     u->usecurrentposn=u->forceusemotions;
   }
-  if (t->seg->det_ignore)
-    strcat(flags,"@");
-  if (t->seg->tr_backwards)
-    strcat(flags,"-");
 
-  oprintf(UPO," %s%s",flags,t->seg->i->pname);
+  oprintf(UPO," %s%s", t->seg->tr_backwards?"-":"", t->seg->i->pname);
 
   if (t->seg->i->n_poscombs > 1) {
     r= pred_getmovpos(t,c,mpc);  assert(!r);  assert(*mpc>=0);
     oprintf(UPO,"/%s", t->seg->i->poscombs[*mpc].pname);
   }
+  oprintf(UPO,"%s",flags);
 
   return 0;
 }
@@ -738,10 +739,25 @@ ErrorCode predict(Train *tra, int accelerate,
 
   /*----- commit to the plan -----*/
 
-  if (u.need_polarise)
+  oprintf(DUPO("safety") " predict  committing\n");
+
+  if (u.need_polarise) {
+    oprintf(DUPO("safety") " predict  polarising train_polarity=%d\n",
+           u.train_polarity_inverted),
     actual_inversions_start();
+  }
 
+  oprintf(DUPO("safety") " predict  ");
   FOR_SEG {
+    oprintf(UPO,
+           " %s%s%s%c%c%c%c",
+           seg->tr_backwards?"-":"", seg->i->pname,
+           seg->owner == tra ? "#" : "=",
+           "-N"[ seg->now_present ],
+           "-P"[ seg->pred_present ],
+           "-V"[ seg->pred_vacated ],
+           "-#"[ seg->will_polarise ]);
+
     if (seg->owner == tra) {
       seg->det_ignore= 0;
       seg->owner= 0;
@@ -757,14 +773,14 @@ ErrorCode predict(Train *tra, int accelerate,
       ec= movpos_change(seg, target, -1, reservation);
       assert(!ec);
     }
-    if (u.need_polarise) {
-      if (seg->will_polarise)
-       seg->seg_inverted= seg->tr_backwards ^ u.train_polarity_inverted;
+    if (u.need_polarise && seg->will_polarise) {
+      seg->seg_inverted= seg->tr_backwards ^ u.train_polarity_inverted;
       actual_inversions_segment(seg);
     }
     seg->now_present= seg->pred_present=
       seg->pred_vacated= seg->will_polarise= 0;
   }
+  oprintf(UPO,"\n");
 
   if (u.need_polarise)
     actual_inversions_done();