Do not print "couldn't determine section" warning when all traverser ends were end-of-track
This commit is contained in:
parent
93726db4e3
commit
1ff809b883
|
@ -434,16 +434,17 @@ end
|
||||||
-- Utilize the traverser to find the track section at the specified position
|
-- Utilize the traverser to find the track section at the specified position
|
||||||
-- Returns:
|
-- Returns:
|
||||||
-- ts_id, origin - the first found ts and the sigd of the found tcb
|
-- 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
|
-- nil - there were no TCBs in TRAVERSER_MAX range of the position
|
||||||
-- false - the first found TCB stated End-Of-Interlocking
|
-- false - the first found TCB stated End-Of-Interlocking, or track ends were reached
|
||||||
function ildb.get_ts_at_pos(pos)
|
function ildb.get_ts_at_pos(pos)
|
||||||
local node_ok, conns, rhe = advtrains.get_rail_info_at(pos, advtrains.all_tracktypes)
|
local node_ok, conns, rhe = advtrains.get_rail_info_at(pos, advtrains.all_tracktypes)
|
||||||
if not node_ok then
|
if not node_ok then
|
||||||
error("get_ts_at_pos but node is NOK: "..minetest.pos_to_string(pos))
|
error("get_ts_at_pos but node is NOK: "..minetest.pos_to_string(pos))
|
||||||
end
|
end
|
||||||
|
local limit_hit = false
|
||||||
local found_tcbs = {}
|
local found_tcbs = {}
|
||||||
for connid, conn in ipairs(conns) do -- Note: a breadth-first-search would be better for performance
|
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
|
if #found_tcbs >= 1 then
|
||||||
local tcbs = ildb.get_tcbs(found_tcbs[1])
|
local tcbs = ildb.get_tcbs(found_tcbs[1])
|
||||||
local ts
|
local ts
|
||||||
|
@ -454,7 +455,13 @@ function ildb.get_ts_at_pos(pos)
|
||||||
end
|
end
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue