1
0
Fork 0

Fix Wuzzy/MineClone2#996 Coordinate exploit in signs and chests, sent by @cora

This commit is contained in:
kay27 2021-01-22 21:42:37 +04:00
parent 2e898b3113
commit c9294a4d8a
2 changed files with 19 additions and 19 deletions

View File

@ -360,6 +360,15 @@ minetest.register_node("mcl_chests:"..basename, {
end, end,
}) })
local function close_forms(canonical_basename, pos)
local players = minetest.get_connected_players()
for p=1, #players do
if vector.distance(players[p]:get_pos(), pos) <= 30 then
minetest.close_formspec(players[p]:get_player_name(), "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z)
end
end
end
minetest.register_node(small_name, { minetest.register_node(small_name, {
description = desc, description = desc,
_tt_help = tt_help, _tt_help = tt_help,
@ -483,10 +492,7 @@ minetest.register_node(small_name, {
end, end,
on_destruct = function(pos) on_destruct = function(pos)
local players = minetest.get_connected_players() close_forms(canonical_basename, pos)
for p=1, #players do
minetest.close_formspec(players[p]:get_player_name(), "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z)
end
end, end,
mesecons = mesecons, mesecons = mesecons,
on_rotate = simple_rotate, on_rotate = simple_rotate,
@ -527,19 +533,15 @@ minetest.register_node(left_name, {
return return
end end
local players = minetest.get_connected_players() close_forms(canonical_basename, pos)
for p=1, #players do
minetest.close_formspec(players[p]:get_player_name(), "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z)
end
local param2 = n.param2 local param2 = n.param2
local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "left") local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "left")
if not p or minetest.get_node(p).name ~= "mcl_chests:"..basename.."_right" then if not p or minetest.get_node(p).name ~= "mcl_chests:"..basename.."_right" then
return return
end end
for pl=1, #players do close_forms(canonical_basename, p)
minetest.close_formspec(players[pl]:get_player_name(), "mcl_chests:"..canonical_basename.."_"..p.x.."_"..p.y.."_"..p.z)
end
minetest.swap_node(p, { name = small_name, param2 = param2 }) minetest.swap_node(p, { name = small_name, param2 = param2 })
create_entity(p, small_name, small_textures, param2, false, "default_chest", "mcl_chests_chest") create_entity(p, small_name, small_textures, param2, false, "default_chest", "mcl_chests_chest")
end, end,
@ -678,19 +680,15 @@ minetest.register_node("mcl_chests:"..basename.."_right", {
return return
end end
local players = minetest.get_connected_players() close_forms(canonical_basename, pos)
for p=1, #players do
minetest.close_formspec(players[p]:get_player_name(), "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z)
end
local param2 = n.param2 local param2 = n.param2
local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "right") local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "right")
if not p or minetest.get_node(p).name ~= "mcl_chests:"..basename.."_left" then if not p or minetest.get_node(p).name ~= "mcl_chests:"..basename.."_left" then
return return
end end
for pl=1, #players do close_forms(canonical_basename, p)
minetest.close_formspec(players[pl]:get_player_name(), "mcl_chests:"..canonical_basename.."_"..p.x.."_"..p.y.."_"..p.z)
end
minetest.swap_node(p, { name = small_name, param2 = param2 }) minetest.swap_node(p, { name = small_name, param2 = param2 })
create_entity(p, small_name, small_textures, param2, false, "default_chest", "mcl_chests_chest") create_entity(p, small_name, small_textures, param2, false, "default_chest", "mcl_chests_chest")
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)

View File

@ -197,9 +197,11 @@ local destruct_sign = function(pos)
end end
local players = minetest.get_connected_players() local players = minetest.get_connected_players()
for p=1, #players do for p=1, #players do
if vector.distance(players[p]:get_pos(), pos) <= 30 then
minetest.close_formspec(players[p]:get_player_name(), "mcl_signs:set_text_"..pos.x.."_"..pos.y.."_"..pos.z) minetest.close_formspec(players[p]:get_player_name(), "mcl_signs:set_text_"..pos.x.."_"..pos.y.."_"..pos.z)
end end
end end
end
local update_sign = function(pos, fields, sender, force_remove) local update_sign = function(pos, fields, sender, force_remove)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)