From 35a690b04057f9407cd44e9881ae47fa41c0c7f2 Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 20 Jul 2008 17:37:18 +0000 Subject: [PATCH] get directions right (for the benefit of setdirection) --- hostside/safety.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hostside/safety.c b/hostside/safety.c index a8b2abd..39043b0 100644 --- a/hostside/safety.c +++ b/hostside/safety.c @@ -427,6 +427,7 @@ static int initpresent_nextseg(TrackLocation *t, TrackAdvanceContext *c, 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->tr_backwards= !t->backwards; t->seg->until= 0; if (!t->seg->i->invertible) u->noninv_tally[!t->backwards]++; /* ! since going backwards along train */ @@ -1120,8 +1121,11 @@ ErrorCode safety_setdirection(Train *tra, int backwards, oldmaxinto= tra->maxinto; r= trackloc_getlink(&newfdet,&c,&pci,0,-1); assert(!r); + tra->foredetect= newfdet.seg; tra->maxinto= pci->dist - newfdet.remain; + tra->backwards ^= 1; + newfdet.seg->tr_backwards ^= 1; ec= predict(tra,tnow, PREDF_NEWPLAN,0,0, ppc,ppcu); if (!ec) { @@ -1136,6 +1140,9 @@ ErrorCode safety_setdirection(Train *tra, int backwards, tra->foredetect= oldfdet; tra->maxinto= oldmaxinto; + tra->backwards ^= 1; + newfdet.seg->tr_backwards ^= 1; /* in case it's the same as oldfdet */ + ec2= predict(tra,tnow, 0,0,0, 0,(char*)"abandon reverse"); assert(!ec2); -- 2.30.2