chiark / gitweb /
do not crash if we go out of Run with reserved movements - tell safety we're quitting
authorian <ian>
Sun, 11 May 2008 22:04:32 +0000 (22:04 +0000)
committerian <ian>
Sun, 11 May 2008 22:04:32 +0000 (22:04 +0000)
hostside/safety.c
hostside/safety.h
hostside/startup.c

index 851ed8a73216dbd11797f59aadf947d2459e9383..2320dc138dfa83adaff2892cacddc0a038d08c88 100644 (file)
@@ -977,3 +977,13 @@ ErrorCode safety_check_movposchange(Segment *seg,
   }
   return 0;
 }
+
+void safety_abandon_run(void) {
+  SEG_IV;
+
+  FOR_SEG {
+    if (seg->moving) continue;
+    movpos_unreserve(seg->motion);
+    seg->motion= 0;
+  }
+}
index 7ce4ffa086ccbc2e4bddb45c8cb66e66acb90550..d256c4d90d9995a6b0fe9a3974c2b475aef0d300 100644 (file)
@@ -123,6 +123,7 @@ void report_train_ownerships(Train *tra, Segment *furthest,
   /* ... for use by things which update these only, which
    * is basically safety.c and resolve.c */
 
+void safety_abandon_run(void);
 
 /*========== movpos.c ==========*/
 /*
index d933df1b226dc0d0976ee92372c9882fcef79e29..7e33d0cedf2ddce2fd1059b19e620b5f90b914dd 100644 (file)
@@ -87,8 +87,10 @@ static void sta_goto(StartupState new_state) {
 
   if (new_state < Sta_Run)
     choreographers_all_abandon();
-  if (new_state < Sta_Finalising)
+  if (new_state < Sta_Finalising) {
+    safety_abandon_run();
     motions_all_abandon();
+  }
 
   piob.l= 0;
   switch (new_state) {