aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell <orwell@bleipb.de>2025-01-07 22:55:50 +0100
committerorwell <orwell@bleipb.de>2025-01-07 22:55:50 +0100
commit2e575ee761cfdbc86afead28f2bbcb05fc20e616 (patch)
tree5dd48b5a2f6ac4ac55be2b098471b90b82a43dc7
parentee5236459a9fa54919306bf5277bd3f798a859ca (diff)
downloadadvtrains-2e575ee761cfdbc86afead28f2bbcb05fc20e616.tar.gz
advtrains-2e575ee761cfdbc86afead28f2bbcb05fc20e616.tar.bz2
advtrains-2e575ee761cfdbc86afead28f2bbcb05fc20e616.zip
Fix crash with missing section in routesetting, correctly clear ARS table when empty
-rw-r--r--advtrains_interlocking/ars.lua2
-rw-r--r--advtrains_interlocking/routesetting.lua5
-rw-r--r--advtrains_interlocking/train_sections.lua4
3 files changed, 7 insertions, 4 deletions
diff --git a/advtrains_interlocking/ars.lua b/advtrains_interlocking/ars.lua
index b3065ee..eb10497 100644
--- a/advtrains_interlocking/ars.lua
+++ b/advtrains_interlocking/ars.lua
@@ -52,7 +52,7 @@ function il.ars_to_text(arstab)
end
function il.text_to_ars(t)
- if t=="" then
+ if not string.match(t, "%S+") then
return nil
elseif t=="*" then
return {default=true}
diff --git a/advtrains_interlocking/routesetting.lua b/advtrains_interlocking/routesetting.lua
index 15c42aa..28c8c3c 100644
--- a/advtrains_interlocking/routesetting.lua
+++ b/advtrains_interlocking/routesetting.lua
@@ -66,7 +66,10 @@ function ilrs.set_route(signal, route, try)
c_rseg = route[i]
c_lckp = {}
- if c_ts.route then
+ if not c_ts then
+ if not try then atwarn("Encountered ts missing during a real run of routesetting routine, at ts=",c_ts_id,"while setting route",rtename,"of",signal) end
+ return false, "Section '"..(c_ts_id).."' not found!", c_ts_id, nil
+ elseif c_ts.route then
if not try then atwarn("Encountered ts lock during a real run of routesetting routine, at ts=",c_ts_id,"while setting route",rtename,"of",signal) end
return false, "Section '"..(c_ts.name or c_ts_id).."' already has route set from "..sigd_to_string(c_ts.route.origin)..":\n"..c_ts.route.rsn, c_ts_id, nil
end
diff --git a/advtrains_interlocking/train_sections.lua b/advtrains_interlocking/train_sections.lua
index 48e3342..3dda7e8 100644
--- a/advtrains_interlocking/train_sections.lua
+++ b/advtrains_interlocking/train_sections.lua
@@ -83,7 +83,7 @@ local function setsection(tid, train, ts_id, ts, sigd)
-- route setting - clear route state
if ts.route then
--atdebug(tid,"enters",ts_id,"examining Routestate",ts.route)
- if not sigd_equal(ts.route.entry, sigd) then
+ if sigd and not sigd_equal(ts.route.entry, sigd) then
-- Train entered not from the route. Locate origin and cancel route!
atwarn("Train",tid,"hit route",ts.route.rsn,"!")
advtrains.interlocking.route.cancel_route_from(ts.route.origin)
@@ -173,7 +173,7 @@ advtrains.te_register_on_create(function(id, train)
if ts_id then
local ts = ildb.get_ts(ts_id)
if ts then
- setsection(id, train, ts_id, ts, origin)
+ setsection(id, train, ts_id, ts, nil)
else
atwarn("While placing train, TS didnt exist ",ts_id)
end