From 657446e16346f9b9f21344b3591e7103bbf7c2c8 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Fri, 5 Jun 2020 13:39:34 +0200 Subject: Fix minetest.after() loop between ARS->update_route->update_signal_aspect->invalidate_path --- advtrains_interlocking/routesetting.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/advtrains_interlocking/routesetting.lua b/advtrains_interlocking/routesetting.lua index 7c4d14c..1c9ee5a 100644 --- a/advtrains_interlocking/routesetting.lua +++ b/advtrains_interlocking/routesetting.lua @@ -282,6 +282,7 @@ end -- cancel: true in combination with newrte=nil causes cancellation of the current route. function ilrs.update_route(sigd, tcbs, newrte, cancel) --atdebug("Update_Route for",sigd,tcbs.signal_name) + local has_changed_aspect = false if tcbs.route_origin and not sigd_equal(tcbs.route_origin, sigd) then --atdebug("Signal not in control, held by",tcbs.signal_name) return @@ -293,6 +294,7 @@ function ilrs.update_route(sigd, tcbs, newrte, cancel) end tcbs.route_committed = nil tcbs.aspect = nil + has_changed_aspect = true tcbs.routeset = nil tcbs.route_auto = nil tcbs.route_rsn = nil @@ -320,9 +322,13 @@ function ilrs.update_route(sigd, tcbs, newrte, cancel) end else --atdebug("Committed Route:",tcbs.routeset) + has_changed_aspect = true end end - advtrains.interlocking.update_signal_aspect(tcbs) + if has_changed_aspect then + -- FIX: prevent an minetest.after() loop caused by update_signal_aspect dispatching path invalidation, which in turn calls ARS again + advtrains.interlocking.update_signal_aspect(tcbs) + end advtrains.interlocking.update_player_forms(sigd) end -- cgit v1.2.3