summaryrefslogtreecommitdiff
path: root/pipeworks/teleport_tube.lua
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2018-02-13 14:05:34 -0500
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2018-02-13 14:05:34 -0500
commit335d9a3eddcb590c3ca5de9cba9b152e5e560af1 (patch)
tree1b95d73b945fbc9924438c28a35d7f1019fa255f /pipeworks/teleport_tube.lua
parent1d0f113f4c5afcf8479973f2e01786fb9a1fbbb7 (diff)
downloaddreambuilder_modpack-335d9a3eddcb590c3ca5de9cba9b152e5e560af1.tar
dreambuilder_modpack-335d9a3eddcb590c3ca5de9cba9b152e5e560af1.tar.gz
dreambuilder_modpack-335d9a3eddcb590c3ca5de9cba9b152e5e560af1.tar.bz2
dreambuilder_modpack-335d9a3eddcb590c3ca5de9cba9b152e5e560af1.tar.xz
dreambuilder_modpack-335d9a3eddcb590c3ca5de9cba9b152e5e560af1.zip
removed boost_cart and carbone_mobs -- too many crashes
updated blox, homedecor, plantlifed, cottages, farming_redo, framedglass, gloopblocks, mesecons, moreblocks, moretrees, pipeworks, player_textures, replacer, signs_lib, stained_glass, technic, travelnet, unified_inventory, unifieddyes, and worldedit.
Diffstat (limited to 'pipeworks/teleport_tube.lua')
-rw-r--r--pipeworks/teleport_tube.lua20
1 files changed, 19 insertions, 1 deletions
diff --git a/pipeworks/teleport_tube.lua b/pipeworks/teleport_tube.lua
index bb364db..d707717 100644
--- a/pipeworks/teleport_tube.lua
+++ b/pipeworks/teleport_tube.lua
@@ -4,7 +4,7 @@ local tp_tube_db = nil -- nil forces a read
local tp_tube_db_version = 2.0
local function hash(pos)
- return string.format("%d", minetest.hash_node_position(pos))
+ return string.format("%.30g", minetest.hash_node_position(pos))
end
local function save_tube_db()
@@ -50,6 +50,11 @@ local function read_tube_db()
return tp_tube_db
end
+-- debug formatter for coordinates used below
+local fmt = function(pos)
+ return pos.x..", "..pos.y..", "..pos.z
+end
+
-- updates or adds a tube
local function set_tube(pos, channel, can_receive)
local tubes = tp_tube_db or read_tube_db()
@@ -63,6 +68,19 @@ local function set_tube(pos, channel, can_receive)
end
-- we haven't found any tp tube to update, so lets add it
+ -- but sanity check that the hash has not already been inserted.
+ -- if so, complain very loudly and refuse the update so the player knows something is amiss.
+ -- to catch regressions of https://github.com/minetest-mods/pipeworks/issues/166
+ local existing = tp_tube_db[hash]
+ if existing ~= nil then
+ local e = "error"
+ minetest.log(e, "pipeworks teleport tube update refused due to position hash collision")
+ minetest.log(e, "collided hash: "..hash)
+ minetest.log(e, "tried-to-place tube: "..fmt(pos))
+ minetest.log(e, "existing tube: "..fmt(existing))
+ return
+ end
+
tp_tube_db[hash] = {x=pos.x,y=pos.y,z=pos.z,channel=channel,cr=can_receive}
save_tube_db()
end