From: ian Date: Sun, 11 May 2008 22:27:34 +0000 (+0000) Subject: get polarity right at the crossover X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=4ceefdbfedbb3bd959e77d21a7ea584b5145c076;p=trains.git get polarity right at the crossover --- diff --git a/hostside/safety.c b/hostside/safety.c index 2320dc1..4c1dcd3 100644 --- a/hostside/safety.c +++ b/hostside/safety.c @@ -172,6 +172,8 @@ Segment *segments; * here now, pred. to have dep'd and ret'd NPV re-arrival new, defer * now absent, pred. to have arr, dep & ret'd -PV re-arrival forbidden * + * seg->tr_backwards records the sense of the _first_ passage of the train. + * * invalid/impossible combination: * train here now but never in prediction N-- * @@ -370,6 +372,7 @@ static int initpresent_nextseg(TrackLocation *t, TrackAdvanceContext *c, MovPosComb *mpc_io, const TrackLocation *before) { PredictUserContext *u= c->u; + pred_callback_debug(" initpresent_nextseg",t,c,before); t->seg->now_present= t->seg->pred_present= t->seg->will_polarise= 1; t->seg->until= 0; if (!t->seg->i->invertible) @@ -478,7 +481,8 @@ static int nose_nextseg(TrackLocation *t, TrackAdvanceContext *c, movement_ok: /* Now we definitely have a plan which sets a good route at t->seg. */ - t->seg->tr_backwards= t->backwards; + if (!t->seg->pred_vacated) + t->seg->tr_backwards= t->backwards; t->seg->pred_present= 1; t->seg->until= u->elapsed; return 0; /* yay! */ @@ -493,8 +497,8 @@ static int tail_nextseg(TrackLocation *t, TrackAdvanceContext *c, if (!before) return 0; pred_callback_debug(" tail_nextseg",t,c,before); - if (!t->seg->i->invertible) - u->noninv_tally[before->seg->tr_backwards]--; + if (!before->seg->i->invertible) + u->noninv_tally[before->backwards]--; if (before->seg->pred_vacated) return 0; /* only vacate once */ before->seg->pred_present= 0;