From fedbf4937224c79d49bb5077b47ebf53c38c9832 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 17 Sep 2020 19:30:03 +0200 Subject: [PATCH 1/5] Noteblock: Fade out fire sound (#527) --- mesecons_noteblock/init.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mesecons_noteblock/init.lua b/mesecons_noteblock/init.lua index b4e7d24..d29ab88 100644 --- a/mesecons_noteblock/init.lua +++ b/mesecons_noteblock/init.lua @@ -81,5 +81,11 @@ mesecon.noteblock_play = function(pos, param2) end end pos.y = pos.y+1 - minetest.sound_play(soundname, { pos = pos }, true) + if soundname == "fire_fire" then + -- Smoothly fade out fire sound + local handle = minetest.sound_play(soundname, {pos = pos, loop = true}) + minetest.after(3.0, minetest.sound_fade, handle, -1.5, 0.0) + else + minetest.sound_play(soundname, {pos = pos}, true) + end end From 3202bf6786d855566b06ce04719c25822dcd7328 Mon Sep 17 00:00:00 2001 From: tuedel Date: Fri, 18 Sep 2020 23:27:47 +0200 Subject: [PATCH 2/5] mesecons_doors: Add MTG steel bar door and trapdoor (#523) --- mesecons_doors/init.lua | 7 +++++++ mesecons_doors/mod.conf | 1 + 2 files changed, 8 insertions(+) diff --git a/mesecons_doors/init.lua b/mesecons_doors/init.lua index cf6faeb..0f7bea7 100644 --- a/mesecons_doors/init.lua +++ b/mesecons_doors/init.lua @@ -73,6 +73,7 @@ meseconify_door("doors:door_wood") meseconify_door("doors:door_steel") meseconify_door("doors:door_glass") meseconify_door("doors:door_obsidian_glass") +meseconify_door("xpanes:door_steel_bar") -- Trapdoor local function trapdoor_switch(pos, node) @@ -110,6 +111,12 @@ if doors and doors.get then minetest.override_item("doors:trapdoor_open", override) minetest.override_item("doors:trapdoor_steel", override) minetest.override_item("doors:trapdoor_steel_open", override) + + if minetest.registered_items["xpanes:trapdoor_steel_bar"] then + minetest.override_item("xpanes:trapdoor_steel_bar", override) + minetest.override_item("xpanes:trapdoor_steel_bar_open", override) + end + else if minetest.registered_nodes["doors:trapdoor"] then minetest.override_item("doors:trapdoor", { diff --git a/mesecons_doors/mod.conf b/mesecons_doors/mod.conf index da12b38..4daab34 100644 --- a/mesecons_doors/mod.conf +++ b/mesecons_doors/mod.conf @@ -1,2 +1,3 @@ name = mesecons_doors depends = mesecons, doors +optional_depends = xpanes From 6921909100050c7d9509a2bcddc0ca178a7e0e37 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Mon, 21 Sep 2020 22:32:25 +0300 Subject: [PATCH 3/5] Restrict Lua controller interrupt IDs (#534) * Deprecate non-string IIDs * Restrict tabular IIDs to proper trees Fixes crash on recursive interrupt ID (#473) --- mesecons/util.lua | 11 ++++++- mesecons_luacontroller/init.lua | 57 +++++++++++++++++++++++++-------- 2 files changed, 54 insertions(+), 14 deletions(-) diff --git a/mesecons/util.lua b/mesecons/util.lua index 7485cac..f1f88d6 100644 --- a/mesecons/util.lua +++ b/mesecons/util.lua @@ -193,14 +193,23 @@ function mesecon.tablecopy(obj) -- deep copy return obj end +-- Returns whether two values are equal. +-- In tables, keys are compared for identity but values are compared recursively. +-- There is no protection from infinite recursion. function mesecon.cmpAny(t1, t2) if type(t1) ~= type(t2) then return false end - if type(t1) ~= "table" and type(t2) ~= "table" then return t1 == t2 end + if type(t1) ~= "table" then return t1 == t2 end + -- Check that for each key of `t1` both tables have the same value for i, e in pairs(t1) do if not mesecon.cmpAny(e, t2[i]) then return false end end + -- Check that all keys of `t2` are also keys of `t1` so were checked in the previous loop + for i, _ in pairs(t2) do + if t1[i] == nil then return false end + end + return true end diff --git a/mesecons_luacontroller/init.lua b/mesecons_luacontroller/init.lua index 1c93e48..1960fc4 100644 --- a/mesecons_luacontroller/init.lua +++ b/mesecons_luacontroller/init.lua @@ -266,6 +266,46 @@ local function remove_functions(x) return x end +local function validate_iid(iid) + if not iid then return true end -- nil is OK + + local limit = mesecon.setting("luacontroller_interruptid_maxlen", 256) + if type(iid) == "string" then + if #iid <= limit then return true end -- string is OK unless too long + return false, "An interrupt ID was too large!" + end + if type(iid) == "number" or type(iid) == "boolean" then return true, "Non-string interrupt IDs are deprecated" end + + local warn + local seen = {} + local function check(t) + if type(t) == "function" then + warn = "Functions cannot be used in interrupt IDs" + return false + end + if type(t) ~= "table" then + return true + end + if seen[t] then + warn = "Non-tree-like tables are forbidden as interrupt IDs" + return false + end + seen[t] = true + for k, v in pairs(t) do + if not check(k) then return false end + if not check(v) then return false end + end + return true + end + if not check(iid) then return false, warn end + + if #minetest.serialize(iid) > limit then + return false, "An interrupt ID was too large!" + end + + return true, "Table interrupt IDs are deprecated and are unreliable; use strings instead" +end + -- The setting affects API so is not intended to be changeable at runtime local get_interrupt if mesecon.setting("luacontroller_lightweight_interrupts", false) then @@ -282,26 +322,18 @@ else -- itbl: Flat table of functions to run after sandbox cleanup, used to prevent various security hazards get_interrupt = function(pos, itbl, send_warning) -- iid = interrupt id - local function interrupt(time, iid) + return function (time, iid) -- NOTE: This runs within string metatable sandbox, so don't *rely* on anything of the form (""):y -- Hence the values get moved out. Should take less time than original, so totally compatible if type(time) ~= "number" then error("Delay must be a number") end table.insert(itbl, function () -- Outside string metatable sandbox, can safely run this now local luac_id = minetest.get_meta(pos):get_int("luac_id") - -- Check if IID is dodgy, so you can't use interrupts to store an infinite amount of data. - -- Note that this is safe from alter-after-free because this code gets run after the sandbox has ended. - -- This runs outside of the timer and *shouldn't* harm perf. unless dodgy data is being sent in the first place - iid = remove_functions(iid) - local msg_ser = minetest.serialize(iid) - if #msg_ser <= mesecon.setting("luacontroller_interruptid_maxlen", 256) then - mesecon.queue:add_action(pos, "lc_interrupt", {luac_id, iid}, time, iid, 1) - else - send_warning("An interrupt ID was too large!") - end + local ok, warn = validate_iid(iid) + if ok then mesecon.queue:add_action(pos, "lc_interrupt", {luac_id, iid}, time, iid, 1) end + if warn then send_warning(warn) end end) end - return interrupt end end @@ -901,4 +933,3 @@ minetest.register_craft({ {'group:mesecon_conductor_craftable', 'group:mesecon_conductor_craftable', ''}, } }) - From d356f901a3c26f2cce28ce0be64d26fff996e110 Mon Sep 17 00:00:00 2001 From: Johannes Lundberg Date: Fri, 9 Oct 2020 13:28:11 -0700 Subject: [PATCH 4/5] Make Lua code area and error label use monospaced font (#541) --- mesecons_luacontroller/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mesecons_luacontroller/init.lua b/mesecons_luacontroller/init.lua index 1960fc4..1c411dd 100644 --- a/mesecons_luacontroller/init.lua +++ b/mesecons_luacontroller/init.lua @@ -664,6 +664,7 @@ local function reset_formspec(meta, code, errmsg) code = minetest.formspec_escape(code or "") errmsg = minetest.formspec_escape(tostring(errmsg or "")) meta:set_string("formspec", "size[12,10]" + .."style_type[label,textarea;font=mono]" .."background[-0.2,-0.25;12.4,10.75;jeija_luac_background.png]" .."label[0.1,8.3;"..errmsg.."]" .."textarea[0.2,0.2;12.2,9.5;code;;"..code.."]" From 0d86f2c45eee3382e59652fce678d9c39a677d77 Mon Sep 17 00:00:00 2001 From: auouymous <5005204+auouymous@users.noreply.github.com> Date: Thu, 12 Nov 2020 11:26:02 -0700 Subject: [PATCH 5/5] Prevent unauthorized players from changing the noteblock sound. (#547) --- mesecons_noteblock/init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mesecons_noteblock/init.lua b/mesecons_noteblock/init.lua index d29ab88..577cee0 100644 --- a/mesecons_noteblock/init.lua +++ b/mesecons_noteblock/init.lua @@ -3,7 +3,11 @@ minetest.register_node("mesecons_noteblock:noteblock", { tiles = {"mesecons_noteblock.png"}, is_ground_content = false, groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2}, - on_punch = function(pos, node) -- change sound when punched + on_punch = function(pos, node, puncher) -- change sound when punched + if minetest.is_protected(pos, puncher and puncher:get_player_name()) then + return + end + node.param2 = (node.param2+1)%12 mesecon.noteblock_play(pos, node.param2) minetest.set_node(pos, node)