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
* backported upstream commit 1f949b4c112b0a7b86de164a05dfdc66b1a3179c
This commit is contained in:
mckaygerhard 2024-04-07 23:17:42 -04:00
parent 18ef8da8ed
commit 52d847e3c4

View File

@ -371,6 +371,12 @@ end)
local check_can_dig = function(pos, digger) 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(); local p = digger:getpos();
if p.y<0 then p.y=p.y+2 else p.y=p.y+1 end -- head position 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)); 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 if dist>6 then -- here 5
dist = math.floor(dist*100)/100; dist = math.floor(dist*100)/100;
local pname = digger:get_player_name(); 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 for name,_ in pairs(cheat.debuglist) do -- show to all watchers
minetest.chat_send_player(name,logtext) minetest.chat_send_player(name,logtext)
minetest.log("warning", "[governing] "..logtext) minetest.log("warning", "[governing] "..logtext)