From b0dc0ecc9cbe9aa4bc35a146a82ca37626a54cc2 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 21 Dec 2020 13:13:01 +0100 Subject: [PATCH] Fix possible nil crashes in mcl_jukebox --- mods/ITEMS/mcl_jukebox/init.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_jukebox/init.lua b/mods/ITEMS/mcl_jukebox/init.lua index 9a101e33fa..db9f25312a 100644 --- a/mods/ITEMS/mcl_jukebox/init.lua +++ b/mods/ITEMS/mcl_jukebox/init.lua @@ -81,7 +81,7 @@ local function now_playing(player, track_id) if not player or not player:is_player() or not active_huds[playername] or not hud_sequence_numbers[playername] or seq ~= hud_sequence_numbers[playername] then return end - if id == active_huds[playername] then + if id ~= nil and id == active_huds[playername] then player:hud_remove(active_huds[playername]) active_huds[playername] = nil end @@ -162,8 +162,10 @@ minetest.register_node("mcl_jukebox:jukebox", { inv:set_stack("main", 1, "") if active_tracks[cname] ~= nil then minetest.sound_stop(active_tracks[cname]) - clicker:hud_remove(active_huds[cname]) active_tracks[cname] = nil + end + if active_huds[cname] ~= nil then + clicker:hud_remove(active_huds[cname]) active_huds[cname] = nil end else @@ -219,8 +221,10 @@ minetest.register_node("mcl_jukebox:jukebox", { dropped_item:set_yaw(math.pi/2) if active_tracks[name] ~= nil then minetest.sound_stop(active_tracks[name]) - digger:hud_remove(active_huds[name]) active_tracks[name] = nil + end + if active_huds[name] ~= nil then + digger:hud_remove(active_huds[name]) active_huds[name] = nil end end