1
0
Fork 0

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:
iliekprogrammar 2021-11-13 10:46:16 +08:00
parent 490e40d042
commit 96c4fb60d8
No known key found for this signature in database
GPG Key ID: 8E7B20514DBCFBFA
1 changed files with 10 additions and 10 deletions

View File

@ -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 = {}
else
storage = minetest.deserialize(burn_data)
end end
mcl_burning.storage[player] = meta:contains("mcl_burning:data") and minetest.deserialize(meta:get_string("mcl_burning:data")) or {}
mcl_burning.storage[player] = storage
mcl_burning.channels[player] = minetest.mod_channel_join("mcl_burning:" .. player:get_player_name()) mcl_burning.channels[player] = minetest.mod_channel_join("mcl_burning:" .. player:get_player_name())
end
minetest.register_on_joinplayer(function(player)
mcl_burning.init_player(player)
end) end)
minetest.register_on_leaveplayer(function(player) minetest.register_on_leaveplayer(function(player)