proc tractbrake-ensure {train} {
     upvar #0 speedcurve/$train sc
+    global trainnum2train
     if {[info exists sc]} return ;# try this only once
     set sc 0
 
     }
     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} {