chiark / gitweb /
gui: read "train * is *" from .record into trainnum2train global array
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 13 Feb 2011 19:32:20 +0000 (19:32 +0000)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 13 Feb 2011 19:32:20 +0000 (19:32 +0000)
hostside/gui

index 2472e721d83cd58f9d0692678ba0a9729c575b7e..78297c609eddbb8f0623a2f3213c24eb0f24ee73 100755 (executable)
@@ -756,6 +756,7 @@ proc tractbrake-userinput {train tract brake speedw} {
 
 proc tractbrake-ensure {train} {
     upvar #0 speedcurve/$train sc
+    global trainnum2train
     if {[info exists sc]} return ;# try this only once
     set sc 0
 
@@ -771,12 +772,21 @@ proc tractbrake-ensure {train} {
     }
     while {[llength $sc] <= 126} { lappend sc x }
     while {[gets $f l] >= 0} {
-       if {![regexp {^train (\S+) step (\d+)=([0-9.]+)$} $l \
-                 dummy tr step velocity]} continue
-       if {[string compare $tr $train] || $step<=0 || $step>126} {
-           error "bad velocity line $l ?" {} {TRACTBRAKE SKIP}
+       if {[regexp {^train (\S+) step (\d+)=([0-9.]+)$} $l \
+                dummy tr step velocity]} {
+           if {[string compare $tr $train] || $step<=0 || $step>126} {
+               error "bad velocity line $train $l ?"
+           }
+           set sc [lreplace $sc $step $step $velocity]
+       } elseif {[regexp {^train (\S+) is (\d+) } $l \
+                      dummy tr trainnum]} {
+           if {[string compare $tr $train]} {
+               error "bad train line $train $l ?"
+           }
+           set trainnum2train($trainnum) $tr
+       } else {
+           # fine, whatever
        }
-       set sc [lreplace $sc $step $step $velocity]
     }
     close $f
     if {[lsearch -exact $sc x]>=0} {