forked from VoxeLibre/VoxeLibre
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.
This commit is contained in:
parent
04f0ea260d
commit
14da059ce7
|
@ -67,6 +67,13 @@ end)
|
||||||
|
|
||||||
local function on_leaveplayer(player)
|
local function on_leaveplayer(player)
|
||||||
local storage = mcl_burning.storage[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
|
storage.fire_hud_id = nil
|
||||||
player:get_meta():set_string("mcl_burning:data", minetest.serialize(storage))
|
player:get_meta():set_string("mcl_burning:data", minetest.serialize(storage))
|
||||||
mcl_burning.storage[player] = nil
|
mcl_burning.storage[player] = nil
|
||||||
|
|
Loading…
Reference in New Issue