fixed vec2/vec3 crashing on attempted copy construction from something that had a type field which wasn't a callable type() method (eg objects from tiled)

This commit is contained in:
Max Cahill 2021-07-16 19:23:59 +10:00
parent 6ef19cfde0
commit a339854651
2 changed files with 2 additions and 2 deletions

View File

@ -21,7 +21,7 @@ function vec2:new(x, y)
if type(x) == "number" or type(x) == "nil" then
self:sset(x or 0, y)
elseif type(x) == "table" then
if x.type and x:type() == "vec2" then
if type(x.type) == "function" and x:type() == "vec2" then
self:vset(x)
elseif x[1] then
self:sset(x[1], x[2])

View File

@ -23,7 +23,7 @@ function vec3:new(x, y, z)
if type(x) == "number" or type(x) == "nil" then
self:sset(x or 0, y, z)
elseif type(x) == "table" then
if x.type and x:type() == "vec3" then
if type(x.type) == "function" and x:type() == "vec3" then
self:vset(x)
elseif x[1] then
self:sset(x[1], x[2], x[3])