stujones11 / minetest-3d_armor

Visible player armor & wielded items for minetest
Other
56 stars 98 forks source link

Armor drop outside map limits #115

Closed evrooije closed 7 years ago

evrooije commented 7 years ago

Very rare and minor edge/ boundary issue that would only happen when someone noclips and free moves outside the map limits (e.g. a hacked client/ admin at world border) or an admin that teleports to 31000 (because too lazy to look up the exact map boundaries, like me -_-), while wearing armor. Then when the player dies and the armor is dropped (on my server that happens when not wearing a space suit at very high elevation), add_item crashes the game because it being outside the map limit (api.lua).

armor.drop_armor = function(pos, stack)
    local obj = minetest.add_item(pos, stack)
    if obj then
        obj:setvelocity({x=math.random(-1, 1), y=5, z=math.random(-1, 1)})
    end
end

So a sanity check of pos around the drop code and skipping it when outside the world would make it a little more robust :) And I for one will change my code to clear inventories (including the armor one) when outside the boundaries before killing the player ;)

stujones11 commented 7 years ago

add_item crashes the game because it being outside the map limit (api.lua)

I consider this an engine a bug, it certainly should not cause a crash. Was there not some work done on this recently? I would be happy to add a sanity check on the pos though I think a check for CONTENT_IGNORE before dropping might suffice.

I am not sure if it the responsibility of this mod to provide 'anti-cheat' functionality but I would encourage server owners to add their own little tweaks that the cheaters are not aware of.

evrooije commented 7 years ago

Engine should indeed deal with this better, I have added quite a few boundary checks now already e.g. arrows from mod throwing all of a sudden appearing outside of the map limit crashing the game, the player at infinity bug, have seen entities floating in space outside the border on HOMETOWN, etc. When I have time I'll have a look at the engine repo as well to see if this has been raised before/ addressed now and if not create an issue there as well...

stujones11 commented 7 years ago

I was thinking about this https://github.com/minetest/minetest/pull/5889 however, this does not appear to check when adding entities outside the terrain limits.

stujones11 commented 7 years ago

43c9984d574f997da9fa0eea4ae14fca090abc40 should hopefully at least help prevent this.