Do not trust node.param2.

The table lookup will fail if node.param2 is outside [0-3] which
is easily possible since there are several ways to modify param2
values of nodes. Force truncating param2 to always be 0-3 before
using it in a table lookup.
This commit is contained in:
Auke Kok 2016-06-11 17:09:07 -07:00
parent 32f331e7c4
commit f76668969e

View File

@ -71,7 +71,7 @@ pipeworks.spigot_check = function(pos, node)
local belowname = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name local belowname = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name
if belowname and (belowname == "air" or belowname == "default:water_flowing" or belowname == "default:water_source") then if belowname and (belowname == "air" or belowname == "default:water_flowing" or belowname == "default:water_source") then
local spigotname = minetest.get_node(pos).name local spigotname = minetest.get_node(pos).name
local fdir=node.param2 local fdir=node.param2 % 4
local check = { local check = {
{x=pos.x,y=pos.y,z=pos.z+1}, {x=pos.x,y=pos.y,z=pos.z+1},
{x=pos.x+1,y=pos.y,z=pos.z}, {x=pos.x+1,y=pos.y,z=pos.z},