From 2d2cd9605b91ec2f8ec2320714d7a263db50d009 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Wed, 6 Feb 2019 23:22:48 +0100 Subject: No crash when train does not exist on check_collision() --- advtrains/occupation.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/advtrains/occupation.lua b/advtrains/occupation.lua index 6e14459..66a5a75 100644 --- a/advtrains/occupation.lua +++ b/advtrains/occupation.lua @@ -172,8 +172,9 @@ function o.check_collision(pos, train_id) if ti~=train_id then local idx = t[i+1] local train = advtrains.trains[ti] + --atdebug("checking train",t[i],"index",idx,"<>",train.index,train.end_index) - if idx >= train.end_index and idx <= train.index then + if train and idx >= train.end_index and idx <= train.index then --atdebug("collides.") return true end -- cgit v1.2.3