From dd883c5b5ec29e11a78d215d8627f71840051eac Mon Sep 17 00:00:00 2001 From: "Y. Wang" Date: Fri, 30 Aug 2024 21:57:19 +0000 Subject: Clear tcbs.route_rsn when a route is set This appears to fix the issue where route_rsn is not cleared and later shown on the train HUD even when the route is set. Note that this only works if the route is (successfully) set after this patch is applied - it does not clear route_rsn for routes that are already set. How to test: * Set a conflicting route for the train. * Set a route for the train. Note that a message appears on the train HUD explaining that the route cannot be set (this is also the current behavior without the patch). * Cancel the conflicting route. Note that the message on the train HUD is cleared. --- advtrains_interlocking/routesetting.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'advtrains_interlocking/routesetting.lua') diff --git a/advtrains_interlocking/routesetting.lua b/advtrains_interlocking/routesetting.lua index 67efaea..381fa26 100644 --- a/advtrains_interlocking/routesetting.lua +++ b/advtrains_interlocking/routesetting.lua @@ -113,6 +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.route_rsn = nil c_tcbs.route_origin = signal advtrains.interlocking.update_signal_aspect(c_tcbs) end -- cgit v1.2.3 From 8b9eb2a96d9c1c425ff9014fdf27c82526d8376b Mon Sep 17 00:00:00 2001 From: 1F616EMO Date: Sun, 29 Sep 2024 06:43:27 +0800 Subject: Fix update_route receiving invalid route ID in after() --- advtrains_interlocking/routesetting.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'advtrains_interlocking/routesetting.lua') diff --git a/advtrains_interlocking/routesetting.lua b/advtrains_interlocking/routesetting.lua index 381fa26..fd6d595 100644 --- a/advtrains_interlocking/routesetting.lua +++ b/advtrains_interlocking/routesetting.lua @@ -292,7 +292,13 @@ function ilrs.update_route(sigd, tcbs, newrte, cancel) end if newrte then tcbs.routeset = newrte end --atdebug("Setting:",tcbs.routeset) - local succ, rsn, cbts, cblk = ilrs.set_route(sigd, tcbs.routes[tcbs.routeset]) + local succ, rsn, cbts, cblk + if tcbs.routes[tcbs.routeset] then + succ, rsn, cbts, cblk = ilrs.set_route(sigd, tcbs.routes[tcbs.routeset]) + else + succ = false + rsn = attrans("Route state changed.") + end if not succ then tcbs.route_rsn = rsn --atdebug("Routesetting failed:",rsn) -- cgit v1.2.3