forked from mtcontrib/pipeworks
teleport_tube.lua: fix 32-bit clamping issues on some systems for %d in string.format
Some servers running ubuntu in particular were reporting issues with teleport tubes not working. On investigation, all tube entries were colliding as string.format("%d", ...) was returning either -2^31 or 2^31-1 depending on system bit width, causing hash entries to be overwritten. This is possibly related to the use of C sprintf within lua. Fix this by using %g instead to interpret as double without int conversion, with a large enough number of digits such that all possible 2^48 values from minetest.hash_node_position() can be correctly serialised.
This commit is contained in:
parent
a2e183c6f3
commit
57fc8c67f8
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user