fix anticheat for huge amoutn if nodes "digged" on explotions

* if a huge amount of nodes are removed from or near a player or mob
  due the player was not direct actor a nil will be received
master
mckaygerhard 2024-04-07 23:07:15 -04:00
parent 5aba5f1f5b
commit 1f949b4c11
1 changed files with 8 additions and 2 deletions

View File

@ -370,7 +370,13 @@ end)
-- long range dig check
local check_can_dig = function(pos, digger)
local cpos = minetest.pos_to_string(pos) or "missing pos seems nul returned"
local logtext = os.date("%H:%M.%S") .. "#anticheat: long range dig made by some entity, could be a player or huge tnt explotion at ".. cpos;
if not digger then
minetest.log("warning", "[governing] "..logtext)
return
end
local p = digger:getpos();
if p.y<0 then p.y=p.y+2 else p.y=p.y+1 end -- head position
local dist = math.max(math.abs(p.x-pos.x),math.abs(p.y-pos.y),math.abs(p.z-pos.z));
@ -379,7 +385,7 @@ local check_can_dig = function(pos, digger)
if dist>6 then -- here 5
dist = math.floor(dist*100)/100;
local pname = digger:get_player_name();
local logtext = os.date("%H:%M.%S") .. "#anticheat: long range dig " .. pname ..", distance " .. dist .. ", pos " .. minetest.pos_to_string(pos);
logtext = os.date("%H:%M.%S") .. "#anticheat: long range dig " .. pname ..", distance " .. dist .. ", pos " .. cpos;
for name,_ in pairs(cheat.debuglist) do -- show to all watchers
minetest.chat_send_player(name,logtext)
minetest.log("warning", "[governing] "..logtext)