aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking/database.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-10-29 21:28:03 +0100
committerorwell96 <orwell@bleipb.de>2018-10-29 21:28:03 +0100
commit1ff809b8837ec1a4d06672e9b4bc12b1230575b7 (patch)
tree0ee055c8d8cd52fde4ec91e760423fd6c8ca58b4 /advtrains_interlocking/database.lua
parent93726db4e3c36878981b5eb934b3599a50bc6619 (diff)
downloadadvtrains-1ff809b8837ec1a4d06672e9b4bc12b1230575b7.tar.gz
advtrains-1ff809b8837ec1a4d06672e9b4bc12b1230575b7.tar.bz2
advtrains-1ff809b8837ec1a4d06672e9b4bc12b1230575b7.zip
Do not print "couldn't determine section" warning when all traverser ends were end-of-track
Diffstat (limited to 'advtrains_interlocking/database.lua')
-rw-r--r--advtrains_interlocking/database.lua15
1 files changed, 11 insertions, 4 deletions
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