From 438a83bd03f19300049b6fade1ab37f8ffacf567 Mon Sep 17 00:00:00 2001 From: orwell Date: Tue, 22 Jul 2025 23:16:16 +0200 Subject: Introduce separate selector ARS rules to disambiguate multi stop pos in same track even for TT trains, meanwhile rework stoprail form again --- advtrains_line_automation/line_functions.lua | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'advtrains_line_automation/line_functions.lua') diff --git a/advtrains_line_automation/line_functions.lua b/advtrains_line_automation/line_functions.lua index a3be879..4873b77 100644 --- a/advtrains_line_automation/line_functions.lua +++ b/advtrains_line_automation/line_functions.lua @@ -197,7 +197,8 @@ local function should_stop(pos, stdata, train) -- train not on a timetable local ars = stdata.ars -- vyhovuje vlak ARS pravidlům? - local result = ars and (ars.default or advtrains.interlocking.ars_check_rule_match(ars, train)) + local mspec,mdef = advtrains.interlocking.ars_check_rule_match(ars, train) + local result = (mspec or mdef) and true if result then return "true" else @@ -588,10 +589,26 @@ function al.get_line_status(train) return ls, linevar_def end +local function check_selector_ars(train, stdata) + local ars = stdata.selector_ars + if not ars then + return true + end + -- vyhovuje vlak ARS pravidlům? + local mspec,mdef = advtrains.interlocking.ars_check_rule_match(ars, train) + return (mspec or mdef) and true +end + function al.on_train_approach(pos, train_id, train, index) if train.path_cn[index] ~= 1 then return end -- špatný směr local pe = advtrains.encode_pos(pos) local stdata = advtrains.lines.stops[pe] + if stdata == nil then + return -- neplatná zastávka + end + if not check_selector_ars(train, stdata) then + return -- does not consider stop pos here + end if should_stop(pos, stdata, train) ~= nil then advtrains.lzb_add_checkpoint(train, index, 2, nil) if train.line_status.linevar == nil then @@ -630,6 +647,13 @@ function al.on_train_enter(pos, train_id, train, index) if train.path_cn[index] ~= 1 then return end -- špatný směr local pe = advtrains.encode_pos(pos) local stdata = advtrains.lines.stops[pe] + if stdata == nil then + return -- neplatná zastávka + end + if not check_selector_ars(train, stdata) then + return -- does not consider stop pos here + end + local stn = stdata.stn or "" local rwtime = assert(rwt.to_secs(rwt.get_time())) local ls, linevar_def = al.get_line_status(train) -- cgit v1.2.3