aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-12-10 22:57:16 +0100
committerorwell96 <orwell@bleipb.de>2018-12-10 22:57:16 +0100
commitc8788e6ca7cc26f41c819983d0677502786e8985 (patch)
tree4841282baa2d27b72166856fc5edb0db07cdef79 /advtrains_interlocking
parent144e1fc4e01741f8cdd5a579ae84cde85c420d78 (diff)
downloadadvtrains-c8788e6ca7cc26f41c819983d0677502786e8985.tar.gz
advtrains-c8788e6ca7cc26f41c819983d0677502786e8985.tar.bz2
advtrains-c8788e6ca7cc26f41c819983d0677502786e8985.zip
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
Diffstat (limited to 'advtrains_interlocking')
-rw-r--r--advtrains_interlocking/train_sections.lua27
1 files changed, 14 insertions, 13 deletions
diff --git a/advtrains_interlocking/train_sections.lua b/advtrains_interlocking/train_sections.lua
index 762fd5d..bd89c4b 100644
--- a/advtrains_interlocking/train_sections.lua
+++ b/advtrains_interlocking/train_sections.lua
@@ -85,19 +85,20 @@ local function setsection(tid, train, ts_id, ts, sigd)
atwarn("Train",tid,"hit route",ts.route.rsn,"!")
advtrains.interlocking.route.cancel_route_from(ts.route.origin)
atwarn("Route was cancelled.")
- end
- -- train entered route regularily. Reset route and signal
- tcbs.route_committed = nil
- tcbs.route_comitted = nil -- TODO compatibility cleanup
- tcbs.aspect = nil
- tcbs.route_origin = nil
- advtrains.interlocking.update_signal_aspect(tcbs)
- if tcbs.signal and sigd_equal(ts.route.entry, ts.route.origin) then
- if tcbs.route_auto and tcbs.routeset then
- --atdebug("Resetting route (",ts.route.origin,")")
- advtrains.interlocking.route.update_route(ts.route.origin, tcbs)
- else
- tcbs.routeset = nil
+ else
+ -- train entered route regularily. Reset route and signal
+ tcbs.route_committed = nil
+ tcbs.route_comitted = nil -- TODO compatibility cleanup
+ tcbs.aspect = nil
+ tcbs.route_origin = nil
+ advtrains.interlocking.update_signal_aspect(tcbs)
+ if tcbs.signal and sigd_equal(ts.route.entry, ts.route.origin) then
+ if tcbs.route_auto and tcbs.routeset then
+ --atdebug("Resetting route (",ts.route.origin,")")
+ advtrains.interlocking.route.update_route(ts.route.origin, tcbs)
+ else
+ tcbs.routeset = nil
+ end
end
end
ts.route = nil