diff options
author | Y. Wang <yw05@forksworld.de> | 2022-07-03 15:54:14 +0200 |
---|---|---|
committer | Y. Wang <yw05@forksworld.de> | 2023-03-23 20:06:02 +0100 |
commit | 6ae0615309bd5862a7480686ccba01a24b69356b (patch) | |
tree | 311482d116e78df0549da6b3afa950ea627f3da6 | |
parent | 4a3d442601a800e28a274026392461bd1a7cb127 (diff) | |
download | advtrains-6ae0615309bd5862a7480686ccba01a24b69356b.tar.gz advtrains-6ae0615309bd5862a7480686ccba01a24b69356b.tar.bz2 advtrains-6ae0615309bd5862a7480686ccba01a24b69356b.zip |
Automatic dst unassignment; respect tcbs.nodst
-rw-r--r-- | advtrains_interlocking/routesetting.lua | 6 | ||||
-rw-r--r-- | advtrains_interlocking/train_sections.lua | 7 |
2 files changed, 12 insertions, 1 deletions
diff --git a/advtrains_interlocking/routesetting.lua b/advtrains_interlocking/routesetting.lua index 857a681..e792d28 100644 --- a/advtrains_interlocking/routesetting.lua +++ b/advtrains_interlocking/routesetting.lua @@ -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) diff --git a/advtrains_interlocking/train_sections.lua b/advtrains_interlocking/train_sections.lua index 757f36a..ec7f95f 100644 --- a/advtrains_interlocking/train_sections.lua +++ b/advtrains_interlocking/train_sections.lua @@ -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 |