Automatic dst unassignment; respect tcbs.nodst

This commit is contained in:
Y. Wang 2022-07-03 15:54:14 +02:00
parent 4a3d442601
commit 6ae0615309
No known key found for this signature in database
GPG Key ID: 54A05DDF18D7A0EB
2 changed files with 12 additions and 1 deletions

View File

@ -46,12 +46,16 @@ function ilrs.set_route(signal, route, try)
local signalname = ildb.get_tcbs(signal).signal_name
local c_tcbs, c_ts_id, c_ts, c_rseg, c_lckp
local signals = {}
local nodst
while c_sigd and i<=#route do
c_tcbs = ildb.get_tcbs(c_sigd)
if not c_tcbs then
if not try then atwarn("Did not find TCBS",c_sigd,"while setting route",rtename,"of",signal) end
return false, "No TCB found at "..sigd_to_string(c_sigd)..". Please reconfigure route!"
end
if i == 1 then
nodst = c_tcbs.nodst
end
c_ts_id = c_tcbs.ts_id
if not c_ts_id then
if not try then atwarn("Encountered End-Of-Interlocking while setting route",rtename,"of",signal) end
@ -138,7 +142,7 @@ function ilrs.set_route(signal, route, try)
local tcbs = signals[i]
local pos = tcbs.signal
local _, assigned_by = advtrains.distant.get_main(pos)
if not assigned_by or assigned_by == "routesetting" then
if (not nodst) and (not assigned_by or assigned_by == "routesetting") then
advtrains.distant.assign(lastsig, pos, "routesetting", true)
end
advtrains.interlocking.update_signal_aspect(tcbs, i ~= 1)

View File

@ -91,6 +91,13 @@ local function setsection(tid, train, ts_id, ts, sigd)
tcbs.route_comitted = nil -- TODO compatibility cleanup
tcbs.aspect = nil
tcbs.route_origin = nil
if tcbs.signal then
local spos = tcbs.signal
local _, setter = advtrains.distant.get_main(spos)
if setter == "routesetting" then
advtrains.distant.unassign_dst(spos, true)
end
end
advtrains.interlocking.update_signal_aspect(tcbs)
if tcbs.signal and sigd_equal(ts.route.entry, ts.route.origin) then
if tcbs.route_auto and tcbs.routeset then