From beeda8cb9becef5811808ddaa0d2525a147076cb Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 5 Aug 2016 22:17:15 +0200 Subject: [PATCH] Don't crash on nil-player in can_dig and check the right players for attachment in chairs. --- handlers/animations.lua | 10 +++------- itemframe.lua | 4 ++-- mailbox.lua | 4 ++-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/handlers/animations.lua b/handlers/animations.lua index ea6c83c..831ec8b 100644 --- a/handlers/animations.lua +++ b/handlers/animations.lua @@ -40,13 +40,9 @@ function xdecor.sit(pos, node, clicker, pointed_thing) end end -function xdecor.sit_dig(pos, player) - local pname = player:get_player_name() - local objs = minetest.get_objects_inside_radius(pos, 0.1) - - for _, p in pairs(objs) do - if not player or not player:is_player() or p:get_player_name() or - default.player_attached[pname] then +function xdecor.sit_dig(pos, digger) + for _, player in pairs(minetest.get_objects_inside_radius(pos, 0.1)) do + if player:is_player() and default.player_attached[player:get_player_name()] then return false end end diff --git a/itemframe.lua b/itemframe.lua index 39d400a..02d83d6 100644 --- a/itemframe.lua +++ b/itemframe.lua @@ -94,10 +94,10 @@ end function itemframe.dig(pos, player) local meta = minetest.get_meta(pos) - local pname = player:get_player_name() + local pname = player and player:get_player_name() local owner = meta:get_string("owner") - return player and pname == owner + return pname == owner end xdecor.register("itemframe", { diff --git a/mailbox.lua b/mailbox.lua index ec1d874..cd9a03c 100644 --- a/mailbox.lua +++ b/mailbox.lua @@ -78,10 +78,10 @@ end function mailbox.dig(pos, player) local meta = minetest.get_meta(pos) local owner = meta:get_string("owner") - local player_name = player:get_player_name() + local player_name = player and player:get_player_name() local inv = meta:get_inventory() - return inv:is_empty("mailbox") and player and player_name == owner + return inv:is_empty("mailbox") and player_name == owner end function mailbox.after_place_node(pos, placer)