forked from VoxeLibre/VoxeLibre
Fix crash on startup during immediate runtime by mcl_burning
The crash occurs if mcl_burning:data is deserialized to nil. The cause of mcl_burning being set to "return nil" is unknown. Therefore, when it occurs, it will be logged as warning.
This commit is contained in:
parent
490e40d042
commit
96c4fb60d8
|
@ -44,18 +44,18 @@ minetest.register_on_respawnplayer(function(player)
|
||||||
mcl_burning.extinguish(player)
|
mcl_burning.extinguish(player)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
function mcl_burning.init_player(player)
|
||||||
local storage
|
local meta = player:get_meta()
|
||||||
|
-- NOTE: mcl_burning:data may be "return nil" (which deserialize into nil) for reasons unknown.
|
||||||
local burn_data = player:get_meta():get_string("mcl_burning:data")
|
if meta:get_string("mcl_burning:data"):find("return nil", 1, true) then
|
||||||
if burn_data == "" then
|
minetest.log("warning", "[mcl_burning] 'mcl_burning:data' player meta field is invalid! Please report this bug")
|
||||||
storage = {}
|
end
|
||||||
else
|
mcl_burning.storage[player] = meta:contains("mcl_burning:data") and minetest.deserialize(meta:get_string("mcl_burning:data")) or {}
|
||||||
storage = minetest.deserialize(burn_data)
|
mcl_burning.channels[player] = minetest.mod_channel_join("mcl_burning:" .. player:get_player_name())
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_burning.storage[player] = storage
|
minetest.register_on_joinplayer(function(player)
|
||||||
mcl_burning.channels[player] = minetest.mod_channel_join("mcl_burning:" .. player:get_player_name())
|
mcl_burning.init_player(player)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
|
Loading…
Reference in New Issue