#198 Fix a crash, step 8

This commit is contained in:
kay27 2022-02-14 02:01:01 +00:00
parent 52e2e2506b
commit 89a016c0e6
3 changed files with 27 additions and 10 deletions

View File

@ -1,5 +1,7 @@
mcl_craftguide = {} mcl_craftguide = {}
local awaiting_connection_player_names = {}
local M = minetest local M = minetest
local player_data = {} local player_data = {}
@ -1075,12 +1077,14 @@ if progressive_mode then
for i = 1, #players do for i = 1, #players do
local player = players[i] local player = players[i]
local name = player:get_player_name() local name = player:get_player_name()
local data = player_data[name] if not awaiting_connection_player_names[name] then
local inv_items = get_inv_items(player) local data = player_data[name]
local diff = table_diff(inv_items, data.inv_items) local inv_items = get_inv_items(player)
local diff = table_diff(inv_items, data.inv_items)
if #diff > 0 then if #diff > 0 then
data.inv_items = table_merge(diff, data.inv_items) data.inv_items = table_merge(diff, data.inv_items)
end
end end
end end
@ -1094,12 +1098,14 @@ if progressive_mode then
mcl_craftguide.add_recipe_filter("Default progressive filter", progressive_filter) mcl_craftguide.add_recipe_filter("Default progressive filter", progressive_filter)
M.register_on_authplayer(function(name, ip, is_success) M.register_on_authplayer(function(name, ip, is_success)
if not is_success then return if not is_success then return end
init_data(name) awaiting_connection_player_names[name] = true
end) end)
M.register_on_joinplayer(function(player) M.register_on_joinplayer(function(player)
local name = player:get_player_name() local name = player:get_player_name()
awaiting_connection_player_names[name] = nil
init_data(name)
local meta = player:get_meta() local meta = player:get_meta()
local data = player_data[name] local data = player_data[name]
@ -1130,7 +1136,9 @@ if progressive_mode then
local players = M.get_connected_players() local players = M.get_connected_players()
for i = 1, #players do for i = 1, #players do
local player = players[i] local player = players[i]
save_meta(player) if not awaiting_connection_player_names[player:get_player_name()] then
save_meta(player)
end
end end
end) end)
else else

View File

@ -24,6 +24,15 @@ interact_priv.give_to_admin = false
local overlay = mcl_enchanting.overlay local overlay = mcl_enchanting.overlay
local hud = "mcl_shield_hud.png" local hud = "mcl_shield_hud.png"
local function is_player_for_real(obj)
if not obj then return end
if not obj:is_player() then return end
local name = obj:get_player_name()
if not name then return end
if possible_hackers[name] then return end
return true
end
minetest.register_tool("mcl_shields:shield", { minetest.register_tool("mcl_shields:shield", {
description = S("Shield"), description = S("Shield"),
_doc_items_longdesc = S("A shield is a tool used for protecting the player against attacks."), _doc_items_longdesc = S("A shield is a tool used for protecting the player against attacks."),
@ -123,7 +132,7 @@ mcl_damage.register_modifier(function(obj, damage, reason)
local type = reason.type local type = reason.type
local damager = reason.direct local damager = reason.direct
local blocking, shieldstack = mcl_shields.is_blocking(obj) local blocking, shieldstack = mcl_shields.is_blocking(obj)
if obj:is_player() and blocking and mcl_shields.types[type] and damager then if is_player_for_real(obj) and blocking and mcl_shields.types[type] and damager then
local entity = damager:get_luaentity() local entity = damager:get_luaentity()
if entity and (type == "arrow" or type == "generic") then if entity and (type == "arrow" or type == "generic") then
damager = entity._shooter damager = entity._shooter

View File

@ -73,7 +73,7 @@ minetest.register_globalstep(function(dtime)
end) end)
-- set to blank on join (for 3rd party mods) -- set to blank on join (for 3rd party mods)
minetest.register_on_authlayer(function(name, ip, is_success) minetest.register_on_authplayer(function(name, ip, is_success)
if not is_success then return end if not is_success then return end
mcl_playerinfo[name] = { mcl_playerinfo[name] = {
node_head = "", node_head = "",