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

View File

@ -24,6 +24,15 @@ interact_priv.give_to_admin = false
local overlay = mcl_enchanting.overlay
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", {
description = S("Shield"),
_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 damager = reason.direct
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()
if entity and (type == "arrow" or type == "generic") then
damager = entity._shooter

View File

@ -73,7 +73,7 @@ minetest.register_globalstep(function(dtime)
end)
-- 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
mcl_playerinfo[name] = {
node_head = "",