mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-21 23:03:46 +01:00
Make code more robust against corrupt database data
This commit is contained in:
parent
1ded993e4e
commit
c9a013a458
@ -23,7 +23,9 @@ local function deserialize(s)
|
||||
local tbl = {}
|
||||
for line in s:gmatch("[^;]+") do
|
||||
local num, spos = unpack(string.split(line, "="))
|
||||
tbl[num] = {pos = minetest.string_to_pos(spos)}
|
||||
if num ~= nil and num ~= "" and spos ~= nil and spos ~= "" then
|
||||
tbl[num] = {pos = minetest.string_to_pos(spos)}
|
||||
end
|
||||
end
|
||||
return tbl
|
||||
end
|
||||
@ -31,7 +33,9 @@ end
|
||||
local function serialize(data)
|
||||
local tbl = {}
|
||||
for k,v in pairs(data) do
|
||||
tbl[#tbl+1] = k.."="..minetest.pos_to_string(v.pos)
|
||||
if k ~= nil and k ~= "" and v ~= nil and v.pos ~= nil then
|
||||
tbl[#tbl+1] = k.."="..minetest.pos_to_string(v.pos)
|
||||
end
|
||||
end
|
||||
return table.concat(tbl, ";")
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user