diff options
author | Y. Wang <yw05@forksworld.de> | 2022-07-03 12:45:27 +0200 |
---|---|---|
committer | Y. Wang <yw05@forksworld.de> | 2023-03-23 20:06:02 +0100 |
commit | 875968f078ef89b13afae6d02a2dabe5ea7897cb (patch) | |
tree | 5b3c43ace046b595d09291e1af0e0a0136d7e13a | |
parent | bd20da95ec5e1c113a57b7ac2c75d08b87cbf793 (diff) | |
download | advtrains-875968f078ef89b13afae6d02a2dabe5ea7897cb.tar.gz advtrains-875968f078ef89b13afae6d02a2dabe5ea7897cb.tar.bz2 advtrains-875968f078ef89b13afae6d02a2dabe5ea7897cb.zip |
Unassign distant signals when canceling route
-rw-r--r-- | advtrains_interlocking/routesetting.lua | 11 | ||||
-rw-r--r-- | advtrains_interlocking/signal_api.lua | 7 | ||||
-rw-r--r-- | advtrains_interlocking/signal_aspect_accessors.lua | 2 | ||||
-rw-r--r-- | advtrains_interlocking/signal_aspects.lua | 4 | ||||
-rw-r--r-- | advtrains_signals_japan/init.lua | 2 |
5 files changed, 21 insertions, 5 deletions
diff --git a/advtrains_interlocking/routesetting.lua b/advtrains_interlocking/routesetting.lua index f1b4455..4ce6fd3 100644 --- a/advtrains_interlocking/routesetting.lua +++ b/advtrains_interlocking/routesetting.lua @@ -113,7 +113,7 @@ 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.signal @@ -138,7 +138,7 @@ function ilrs.set_route(signal, route, try) if lastsig then local pos = signals[i] local _, assigned_by = advtrains.distant.get_main(pos) - if assigned_by ~= "manual" then + if not assigned_by or assigned_by == "routesetting" then advtrains.distant.assign(lastsig, signals[i], "routesetting") end end @@ -251,6 +251,13 @@ function ilrs.cancel_route_from(sigd) c_tcbs.route_origin = nil advtrains.interlocking.update_signal_aspect(c_tcbs) + 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) + end + end c_ts_id = c_tcbs.ts_id if not c_tcbs then diff --git a/advtrains_interlocking/signal_api.lua b/advtrains_interlocking/signal_api.lua index 1fd4e34..eec70f9 100644 --- a/advtrains_interlocking/signal_api.lua +++ b/advtrains_interlocking/signal_api.lua @@ -176,6 +176,11 @@ advtrains.interlocking.GENERIC_FREE = { shunt = false, dst = false, } +advtrains.interlocking.FULL_FREE = { + main = -1, + shunt = false, + proceed_as_main = true, +} local function convert_aspect_if_necessary(asp) if type(asp.main) == "table" then @@ -212,7 +217,7 @@ end function advtrains.interlocking.signal_after_dig(pos) -- clear influence point - advtrains.interlocking.db.clear_ip_by_signalpos(pos) + advtrains.interlocking.signal_clear_aspect(pos) advtrains.distant.unassign_all(pos, true) end diff --git a/advtrains_interlocking/signal_aspect_accessors.lua b/advtrains_interlocking/signal_aspect_accessors.lua index 02a03ea..bdbb803 100644 --- a/advtrains_interlocking/signal_aspect_accessors.lua +++ b/advtrains_interlocking/signal_aspect_accessors.lua @@ -103,9 +103,9 @@ local function set_aspect(pos, asp) local newasp, aspval = adjust_aspect(pos, asp) set_supposed_aspect(pos, newasp) ndef.advtrains.set_aspect(pos, node, aspval) + I.signal_on_aspect_changed(pos) local aspect_changed = A.not_equalp(oldasp, newasp) if aspect_changed then - I.signal_on_aspect_changed(pos) D.update_main(pos) end end diff --git a/advtrains_interlocking/signal_aspects.lua b/advtrains_interlocking/signal_aspects.lua index 2866ae1..5c4948b 100644 --- a/advtrains_interlocking/signal_aspects.lua +++ b/advtrains_interlocking/signal_aspects.lua @@ -32,6 +32,8 @@ local function register_type2(def) t.label = label t.main = asp.main + t.shunt = asp.shunt + t.proceed_as_main = asp.proceed_as_main mainasps[idx] = t mainasps[name] = idx end @@ -87,6 +89,8 @@ local function type2main_to_type1(name, asp) local t = { main = asptbl.main, + shunt = asptbl.shunt, + proceed_as_main = asptbl.proceed_as_main, type2name = asp, type2group = name, dst = dst, diff --git a/advtrains_signals_japan/init.lua b/advtrains_signals_japan/init.lua index 9ccf66b..2062a21 100644 --- a/advtrains_signals_japan/init.lua +++ b/advtrains_signals_japan/init.lua @@ -321,7 +321,7 @@ local function process_signal(name, sigdata, isrpt) tt[#tt+1] = string.format("0,%d=(advtrains_hud_bg.png\\^[colorize\\:%s)", lightcount-1, color) end tx[aspname] = table.concat(tt, ":") - type2def.main[idx] = {name = asp.name, label = S(aspnames[asp.name]), main = asp.main or false} + type2def.main[idx] = {name = asp.name, label = S(aspnames[asp.name]), main = asp.main, proceed_as_main = true} end local invimg = { string.format("[combine:%dx%d", lightcount*4+1, lightcount*4+1), |