Fix crashes:
1. when train hit a route, nil access to already cancelled route caused crash 2. fix crash when trying to ensure_init a train that doesn't exist
This commit is contained in:
parent
144e1fc4e0
commit
c8788e6ca7
|
@ -222,6 +222,12 @@ local callbacks_remove, run_callbacks_remove = mkcallback("remove")
|
||||||
-- - save files were loaded
|
-- - save files were loaded
|
||||||
-- Additionally, this gets called outside the step cycle to initialize and/or remove a train, then occ_write_mode is set.
|
-- Additionally, this gets called outside the step cycle to initialize and/or remove a train, then occ_write_mode is set.
|
||||||
function advtrains.train_ensure_init(id, train)
|
function advtrains.train_ensure_init(id, train)
|
||||||
|
if not train then
|
||||||
|
atwarn("train_ensure_init: Called with id =",id,"but a nil train!")
|
||||||
|
atwarn(debug.traceback())
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
train.dirty = true
|
train.dirty = true
|
||||||
if train.no_step then return nil end
|
if train.no_step then return nil end
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ local function setsection(tid, train, ts_id, ts, sigd)
|
||||||
atwarn("Train",tid,"hit route",ts.route.rsn,"!")
|
atwarn("Train",tid,"hit route",ts.route.rsn,"!")
|
||||||
advtrains.interlocking.route.cancel_route_from(ts.route.origin)
|
advtrains.interlocking.route.cancel_route_from(ts.route.origin)
|
||||||
atwarn("Route was cancelled.")
|
atwarn("Route was cancelled.")
|
||||||
end
|
else
|
||||||
-- train entered route regularily. Reset route and signal
|
-- train entered route regularily. Reset route and signal
|
||||||
tcbs.route_committed = nil
|
tcbs.route_committed = nil
|
||||||
tcbs.route_comitted = nil -- TODO compatibility cleanup
|
tcbs.route_comitted = nil -- TODO compatibility cleanup
|
||||||
|
@ -100,6 +100,7 @@ local function setsection(tid, train, ts_id, ts, sigd)
|
||||||
tcbs.routeset = nil
|
tcbs.routeset = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
ts.route = nil
|
ts.route = nil
|
||||||
end
|
end
|
||||||
if tcbs.signal then
|
if tcbs.signal then
|
||||||
|
|
Loading…
Reference in New Issue