From 14da059ce7c9bc0998aacc0d7dc371f2cc038553 Mon Sep 17 00:00:00 2001 From: kabou Date: Tue, 29 Mar 2022 12:06:00 +0200 Subject: [PATCH 1/2] Add extra check and warning on missing player data. * For some unexplained reason, `mcl_burning.storage[player]` can sometimes be `nil`, causing a crash in `on_leaveplayer()`. This commit adds a check for that. If a `nil` is encountered, a sane value is substituted and a warning is set to the log. --- mods/ENTITIES/mcl_burning/init.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mods/ENTITIES/mcl_burning/init.lua b/mods/ENTITIES/mcl_burning/init.lua index 8133a1fe3..b1b2e29f0 100644 --- a/mods/ENTITIES/mcl_burning/init.lua +++ b/mods/ENTITIES/mcl_burning/init.lua @@ -67,6 +67,13 @@ end) local function on_leaveplayer(player) local storage = mcl_burning.storage[player] + if not storage then + -- For some unexplained reasons, mcl_burning.storage can be `nil` here. + -- Logging this exception to assist in finding the cause of this. + minetest.log("warning", "on_leaveplayer: missing mcl_burning.storage " + .. "for player " .. player.name) + storage = {} + end storage.fire_hud_id = nil player:get_meta():set_string("mcl_burning:data", minetest.serialize(storage)) mcl_burning.storage[player] = nil From 1b99b73894fb5cdbabd38eb84d67e4427df4fcdd Mon Sep 17 00:00:00 2001 From: kabou Date: Wed, 30 Mar 2022 01:31:38 +0200 Subject: [PATCH 2/2] Fix wrong player name accessor. * Duh.. --- mods/ENTITIES/mcl_burning/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_burning/init.lua b/mods/ENTITIES/mcl_burning/init.lua index b1b2e29f0..039d295b7 100644 --- a/mods/ENTITIES/mcl_burning/init.lua +++ b/mods/ENTITIES/mcl_burning/init.lua @@ -71,7 +71,7 @@ local function on_leaveplayer(player) -- For some unexplained reasons, mcl_burning.storage can be `nil` here. -- Logging this exception to assist in finding the cause of this. minetest.log("warning", "on_leaveplayer: missing mcl_burning.storage " - .. "for player " .. player.name) + .. "for player " .. player:get_player_name()) storage = {} end storage.fire_hud_id = nil