chiark / gitweb /
Properly restore fdet->tr_backwards on failed direction change
authorian <ian>
Sun, 27 Jul 2008 14:00:39 +0000 (14:00 +0000)
committerian <ian>
Sun, 27 Jul 2008 14:00:39 +0000 (14:00 +0000)
hostside/safety.c

index 2df7bb6be0e618c667a0863345706f59f5c493fd..56f9f548730f15eec5f29234c7dbce9ea6a43753 100644 (file)
@@ -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);