diff options
author | orwell <orwell@bleipb.de> | 2024-04-08 21:52:32 +0200 |
---|---|---|
committer | orwell <orwell@bleipb.de> | 2024-04-08 21:52:32 +0200 |
commit | 852da6bcaeeb8c39ce73639ef64f10ebc5b127b0 (patch) | |
tree | ebd944b0b8a763b63f128e7a7bf81882a4e8c29f /advtrains_interlocking/routesetting.lua | |
parent | 9fa43cb7bfc25ba71d16c8210f0074797a7bca1a (diff) | |
parent | 1f74697e85d456e97e201cdd9edef91a2df4fc14 (diff) | |
download | advtrains-852da6bcaeeb8c39ce73639ef64f10ebc5b127b0.tar.gz advtrains-852da6bcaeeb8c39ce73639ef64f10ebc5b127b0.tar.bz2 advtrains-852da6bcaeeb8c39ce73639ef64f10ebc5b127b0.zip |
Merge branch 'new-ks-orwell' into route_prog_rework
Diffstat (limited to 'advtrains_interlocking/routesetting.lua')
-rw-r--r-- | advtrains_interlocking/routesetting.lua | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/advtrains_interlocking/routesetting.lua b/advtrains_interlocking/routesetting.lua index 64b8c25..24b3199 100644 --- a/advtrains_interlocking/routesetting.lua +++ b/advtrains_interlocking/routesetting.lua @@ -45,12 +45,17 @@ function ilrs.set_route(signal, route, try) local rtename = route.name local signalname = (ildb.get_tcbs(signal).signal_name or "") .. sigd_to_string(signal) 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 update or 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 @@ -133,9 +138,9 @@ function ilrs.set_route(signal, route, try) } if c_tcbs.signal then c_tcbs.route_committed = true - c_tcbs.aspect = route.aspect or advtrains.interlocking.GENERIC_FREE + c_tcbs.aspect = route.aspect or advtrains.interlocking.FULL_FREE c_tcbs.route_origin = signal - advtrains.interlocking.update_signal_aspect(c_tcbs) + signals[#signals+1] = c_tcbs end end -- advance @@ -143,6 +148,27 @@ function ilrs.set_route(signal, route, try) c_sigd = c_rseg.next i = i + 1 end + + -- Distant signaling + local lastsig = nil + if c_sigd then + local e_tcbs = ildb.get_tcbs(c_sigd) + local pos = e_tcbs and e_tcbs.signal + if pos then + lastsig = pos + end + end + for i = #signals, 1, -1 do + if lastsig then + local tcbs = signals[i] + local pos = tcbs.signal + local _, assigned_by = advtrains.distant.get_main(pos) + 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) + end + end return true end @@ -252,6 +278,13 @@ function ilrs.cancel_route_from(sigd) c_tcbs.route_auto = nil c_tcbs.route_origin = nil + if c_tcbs.signal then + local pos = c_tcbs.signal + local _, assigned_by = advtrains.distant.get_main(pos) + if assigned_by == "routesetting" then + advtrains.distant.unassign_dst(pos, true) + end + end advtrains.interlocking.update_signal_aspect(c_tcbs) c_ts_id = c_tcbs.ts_id @@ -331,7 +364,8 @@ function ilrs.update_route(sigd, tcbs, newrte, cancel) end else --atdebug("Committed Route:",tcbs.routeset) - has_changed_aspect = true + -- set_route now sets the signal aspects + --has_changed_aspect = true end end if has_changed_aspect then |