Make legacy table copy entries

This commit is contained in:
ShadowNinja 2014-07-12 19:18:31 -04:00
parent 57c18fce95
commit 913e1fe6b3

@ -111,31 +111,22 @@ HasOwner = areas.hasOwner
-- This is entirely untested and may break in strange and new ways. -- This is entirely untested and may break in strange and new ways.
if areas.legacy_table then if areas.legacy_table then
owner_defs = {} owner_defs = setmetatable({}, {
setmetatable(owner_defs, {
__index = function(table, key) __index = function(table, key)
local a = rawget(areas.areas, key) local a = rawget(areas.areas, key)
if a then if not a then return a end
a.x1 = a.pos1.x local b = {}
a.y1 = a.pos1.y for k, v in pairs(a) do b[k] = v end
a.z1 = a.pos1.z b.x1, b.y1, b.z1 = b.pos1.x, b.pos1.y, b.pos1.z
a.x2 = a.pos2.x b.x2, b.y1, b.z2 = b.pos2.x, b.pos2.y, b.pos2.z
a.y2 = a.pos2.y b.pos1, b.pos2 = nil, nil
a.z2 = a.pos2.z b.id = key
a.pos1, a.pos2 = nil, nil return b
a.id = key
end
return a
end, end,
__newindex = function(table, key, value) __newindex = function(table, key, value)
local a = value local a = value
a.pos1, a.pos2 = {}, {} a.pos1, a.pos2 = {x=a.x1, y=a.y1, z=a.z1},
a.pos1.x = a.x1 {x=a.x2, y=a.y2, z=a.z2}
a.pos1.y = a.y1
a.pos1.z = a.z1
a.pos2.x = a.x2
a.pos2.y = a.y2
a.pos2.z = a.z2
a.x1, a.y1, a.z1, a.x2, a.y2, a.z2 = a.x1, a.y1, a.z1, a.x2, a.y2, a.z2 =
nil, nil, nil, nil, nil, nil nil, nil, nil, nil, nil, nil
a.name = a.name or "unnamed" a.name = a.name or "unnamed"