Use minetest.hash_node_position for searches.

Previously, Digilines used concatenations of X/Y/Z coordinates into
strings as keys to check for repeatedly visiting the same node during a
graph search. Replace them with integer keys generated by
`minetest.hash_node_position`, which should be more efficient.
This commit is contained in:
Christopher Head
2017-02-19 15:15:00 -08:00
committed by Auke Kok
parent 25ea72270d
commit 84133a10df
2 changed files with 2 additions and 2 deletions

View File

@ -105,7 +105,7 @@ function digiline:transmit(pos, channel, msg, checked)
for _, rule in ipairs(rules) do
local nextPos = digiline:addPosRule(curPos, rule)
if digiline:rules_link(curPos, nextPos) then
local checkedID = tostring(nextPos.x) .. "_" .. tostring(nextPos.y) .. "_" .. tostring(nextPos.z)
local checkedID = minetest.hash_node_position(nextPos)
if not checked[checkedID] then
checked[checkedID] = true
queue_enqueue(queue, nextPos)