From 253435a709ccbfbed78a9ceff349403a1dc00eba Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 27 Jul 2008 14:00:39 +0000 Subject: [PATCH] Properly restore fdet->tr_backwards on failed direction change --- hostside/safety.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hostside/safety.c b/hostside/safety.c index 2df7bb6..56f9f54 100644 --- a/hostside/safety.c +++ b/hostside/safety.c @@ -1112,7 +1112,7 @@ ErrorCode safety_setdirection(Train *tra, int backwards, PredictUserContext u; const SegPosCombInfo *pci; Segment *oldfdet; - int oldmaxinto; + int oldmaxinto, oldfdet_trbackwards; ErrorCode ec, ec2; int r; struct timeval tnow; @@ -1144,6 +1144,7 @@ ErrorCode safety_setdirection(Train *tra, int backwards, /* right, now let's start fiddling */ oldfdet= tra->foredetect; oldmaxinto= tra->maxinto; + oldfdet_trbackwards= tra->foredetect->tr_backwards; r= trackloc_getlink(&newfdet,&c,&pci,0,-1); assert(!r); @@ -1166,7 +1167,7 @@ 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 */ + tra->foredetect->tr_backwards= oldfdet_trbackwards; ec2= predict(tra,tnow, PREDF_OLDPLAN,0,0, 0,0,(char*)"abandon reverse"); assert(!ec2); -- 2.30.2