mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-23 07:43:01 +00:00
weaschem: validate node ids in parse_data_table
This commit is contained in:
parent
3b7e91b3b7
commit
bd012813b3
1 changed files with 11 additions and 3 deletions
|
@ -147,8 +147,7 @@ function weaschem.parse_id_map(source, is_delta)
|
||||||
return true, "SUCCESS", result
|
return true, "SUCCESS", result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function weaschem.parse_data_table(source, is_delta)
|
||||||
function weaschem.parse_data_table(source)
|
|
||||||
local data_table = {}
|
local data_table = {}
|
||||||
local values = split(source, ",", true)
|
local values = split(source, ",", true)
|
||||||
local i = 0
|
local i = 0
|
||||||
|
@ -163,6 +162,15 @@ function weaschem.parse_data_table(source)
|
||||||
if type(multi_node_id) ~= "number" then
|
if type(multi_node_id) ~= "number" then
|
||||||
return false, "DATA_TABLE_INVALID_NODE_ID", "Encountered node id value in data table at position '"..tostring(i).."'."
|
return false, "DATA_TABLE_INVALID_NODE_ID", "Encountered node id value in data table at position '"..tostring(i).."'."
|
||||||
end
|
end
|
||||||
|
if is_delta then
|
||||||
|
if multi_node_id < -2 then
|
||||||
|
return false, "DATA_TABLE_INVALID_NODE_ID", "Error: When type=delta, then node ids must not be less then -2."
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if multi_node_id < -1 then
|
||||||
|
return false, "DATA_TABLE_INVALID_NODE_ID", "Error: When type=delta, then node ids must not be less then -1."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
for _ = 1,multi_count do
|
for _ = 1,multi_count do
|
||||||
data_table[i] = multi_node_id
|
data_table[i] = multi_node_id
|
||||||
|
@ -170,7 +178,7 @@ function weaschem.parse_data_table(source)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local node_id = tonumber(next_val)
|
local node_id = tonumber(next_val)
|
||||||
if type(multi_count) ~= "number" then
|
if type(node_id) ~= "number" then
|
||||||
return false, "DATA_TABLE_INVALID_NODE_ID",
|
return false, "DATA_TABLE_INVALID_NODE_ID",
|
||||||
"Encountered node id value in data table at position '" .. tostring(i) .. "'."
|
"Encountered node id value in data table at position '" .. tostring(i) .. "'."
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue