Fix minetest.after() loop between ARS->update_route->update_signal_aspect->invalidate_path

This commit is contained in:
orwell96 2020-06-05 13:39:34 +02:00
parent fb837a449a
commit 657446e163
1 changed files with 7 additions and 1 deletions

View File

@ -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