aboutsummaryrefslogtreecommitdiff
path: root/advtrains
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
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')
-rw-r--r--advtrains/trainlogic.lua6
1 files changed, 6 insertions, 0 deletions
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index 965fcbd..fb87fca 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -222,6 +222,12 @@ local callbacks_remove, run_callbacks_remove = mkcallback("remove")
-- - 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.
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
if train.no_step then return nil end