From 5b7a06fe0faba5f037a0b2e602284674fb0b3fb1 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Wed, 15 Feb 2017 19:45:43 +0100 Subject: fix #34 - end_index not set when step_a returned in phase 2 --- advtrains/advtrains/trainlogic.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'advtrains') diff --git a/advtrains/advtrains/trainlogic.lua b/advtrains/advtrains/trainlogic.lua index 0b28129..f0295d1 100644 --- a/advtrains/advtrains/trainlogic.lua +++ b/advtrains/advtrains/trainlogic.lua @@ -165,7 +165,7 @@ function advtrains.train_step_a(id, train, dtime) if node_ok==nil then --block not loaded, do nothing - atprint("last_pos not available") + atprint("last_pos", advtrains.round_vector_floor_y(train.last_pos), "not loaded and not in ndb, waiting") return nil elseif node_ok==false then atprint("no track here, (fail) removing train.") @@ -184,7 +184,7 @@ function advtrains.train_step_a(id, train, dtime) if prevnode_ok==nil then --block not loaded, do nothing - atprint("prev not available") + atprint("last_pos_prev", advtrains.round_vector_floor_y(train.last_pos_prev), "not loaded and not in ndb, waiting") return nil elseif prevnode_ok==false then atprint("no track at prev, (fail) removing train.") @@ -483,6 +483,12 @@ end function advtrains.train_step_b(id, train, dtime) + --hacky fix: if train_step_a returned in phase 2, end_index may not be set. + --just return + if not train.end_index then + return + end + --- 8. check for collisions with other trains and damage players --- local train_moves=(train.velocity~=0) -- cgit v1.2.3