From 1ff809b8837ec1a4d06672e9b4bc12b1230575b7 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Mon, 29 Oct 2018 21:28:03 +0100 Subject: Do not print "couldn't determine section" warning when all traverser ends were end-of-track --- advtrains_interlocking/database.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'advtrains_interlocking/database.lua') diff --git a/advtrains_interlocking/database.lua b/advtrains_interlocking/database.lua index 299f6cc..12853c0 100644 --- a/advtrains_interlocking/database.lua +++ b/advtrains_interlocking/database.lua @@ -434,16 +434,17 @@ end -- Utilize the traverser to find the track section at the specified position -- Returns: -- ts_id, origin - the first found ts and the sigd of the found tcb --- nil - there were no TCBs in TRAVERSER_MAX range of the position, or track ends were reached --- false - the first found TCB stated End-Of-Interlocking +-- nil - there were no TCBs in TRAVERSER_MAX range of the position +-- false - the first found TCB stated End-Of-Interlocking, or track ends were reached function ildb.get_ts_at_pos(pos) local node_ok, conns, rhe = advtrains.get_rail_info_at(pos, advtrains.all_tracktypes) if not node_ok then error("get_ts_at_pos but node is NOK: "..minetest.pos_to_string(pos)) end + local limit_hit = false local found_tcbs = {} for connid, conn in ipairs(conns) do -- Note: a breadth-first-search would be better for performance - traverser(found_tcbs, pos, conns, connid, 0, 1) + limit_hit = limit_hit or traverser(found_tcbs, pos, conns, connid, 0, 1) if #found_tcbs >= 1 then local tcbs = ildb.get_tcbs(found_tcbs[1]) local ts @@ -454,7 +455,13 @@ function ildb.get_ts_at_pos(pos) end end end - return nil + if limit_hit then + -- there was at least one limit hit + return nil + else + -- all traverser ends were track ends + return false + end end -- cgit v1.2.3