Otherwise it will stop working entirely soon when the
serialization inside Minetest is reworked.
This allows it to work at least in the cases where the original
bug (LuaJIT register limit) doesn't apply.
return LATEST_SERIALIZATION_HEADER .. result, count\r
end\r
\r
return LATEST_SERIALIZATION_HEADER .. result, count\r
end\r
\r
--- Contains code based on [table.save/table.load](http://lua-users.org/wiki/SaveTableToFile)\r
--- by ChillCode, available under the MIT license.\r
local function deserialize_workaround(content)\r
local nodes\r
if not minetest.global_exists("jit") then\r
nodes = minetest.deserialize(content, true)\r
local function deserialize_workaround(content)\r
local nodes\r
if not minetest.global_exists("jit") then\r
nodes = minetest.deserialize(content, true)\r
+ elseif not content:match("^%s*return%s*{") then\r
+ -- The data doesn't look like we expect it to so we can't apply the workaround.\r
+ -- hope for the best\r
+ minetest.log("warning", "WorldEdit: deserializing data but can't apply LuaJIT workaround")\r
+ nodes = minetest.deserialize(content, true)\r
else\r
-- XXX: This is a filthy hack that works surprisingly well\r
-- in LuaJIT, `minetest.deserialize` will fail due to the register limit\r
else\r
-- XXX: This is a filthy hack that works surprisingly well\r
-- in LuaJIT, `minetest.deserialize` will fail due to the register limit\r
local startpos, startpos1 = 1, 1\r
local endpos\r
while true do -- go through each individual node entry (except the last)\r
local startpos, startpos1 = 1, 1\r
local endpos\r
while true do -- go through each individual node entry (except the last)\r
- startpos, endpos = escaped:find("},%s*{", startpos)\r
+ startpos, endpos = escaped:find("}%s*,%s*{", startpos)\r
if not startpos then\r
break\r
end\r
if not startpos then\r
break\r
end\r