Check length of serialized item stacks

This commit is contained in:
stujones11 2017-07-10 17:01:47 +01:00
parent e99b25ac75
commit 5901137c1e
2 changed files with 6 additions and 7 deletions

View File

@ -336,7 +336,12 @@ meshnode.create = function(pos, parent)
if meta_tab.inventory then
for _, list in pairs(meta_tab.inventory) do
for i, stack in ipairs(list) do
list[i] = ItemStack(stack):to_string()
local str = ItemStack(stack):to_string()
if str:len() > 0xffff then
minetest.log("error", "String too long for serialization!")
str = ""
end
list[i] = str
end
end
end

View File

@ -275,12 +275,6 @@ minetest.register_entity("meshnode:ctrl", {
end
end,
get_staticdata = function(self)
for k, v in pairs(self.nodes) do
if type(v) == "string" and v:len() > 0xffff then
minetest.log("error", "String too long for serialization!")
self.nodes[k] = ""
end
end
local data = {self.mesh_id, self.activated, self.nodes}
return minetest.serialize(data)
end,