From 1965e846b6c61958063ea13e2ac88ae18b701d09 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 22 Jan 2019 00:06:59 +0100 Subject: [PATCH] Debugging code to trace down path_invalidate within callbacks error --- advtrains/path.lua | 1 + advtrains/trainlogic.lua | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/advtrains/path.lua b/advtrains/path.lua index a0bcd04..92ad8c1 100644 --- a/advtrains/path.lua +++ b/advtrains/path.lua @@ -117,6 +117,7 @@ function advtrains.path_invalidate(train) train.path_req_b=0 train.dirty = true + advtrains.dbg_last_pathclear = "LAST PATH_INVALIDATE: "..debug.traceback() end -- Prints a path using the passed print function diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua index 585b571..a3785df 100644 --- a/advtrains/trainlogic.lua +++ b/advtrains/trainlogic.lua @@ -480,7 +480,11 @@ function advtrains.train_step_c(id, train, dtime) run_callbacks_update(id, train) -- Return if something(TM) damaged the path - if train.no_step or train.wait_for_path or not train.path then return end + if not train.path then + atwarn(id,"@train_step_c missing path") + atwarn(advtrains.dbg_last_pathclear) + return + end advtrains.path_clear_unused(train) @@ -612,6 +616,11 @@ advtrains.te_register_on_new_path(function(id, train) end) advtrains.te_register_on_update(function(id, train) + if not train.path then + atwarn(id,"@register_on_update missing path") + atwarn(advtrains.dbg_last_pathclear) + return + end local new_index = atround(train.index) local new_end_index = atround(train.end_index) local old_index = train.tnc.old_index