Sokomine / replacer

tool that replaces nodes by clicking on them (Mod for Minetest)
8 stars 21 forks source link

check for string length not against nil #15

Open SwissalpS opened 4 years ago

SwissalpS commented 4 years ago

instead of:

if sdata ... do

if 0 < #sdata to avoid crashing the server when users inspect naturally spawned mobs. https://github.com/Sokomine/replacer/blob/7bfcb7360747ddea6c739ae8e991d07099002262/inspect.lua#L77

SwissalpS commented 2 years ago

on a related note, a little further up luaob should be checked against '' == luaob.owner to avoid inspection tool from being used as weapon against untamed mobs. see; lines 157-160 https://github.com/SwissalpS/replacer/blob/8f7a4bef1e7e9ab2c24da2817cefcd08ce524d7a/inspect.lua#L160

-- bug work around to prevent using inspection tool as a weapon
local function is_endangered(luaob)
    if not luaob._cmi_is_mob then return false end
    if not registered_entities[luaob.name] then return false end

    return '' == luaob.owner
end -- is_endangered

Related: https://github.com/Sokomine/replacer/issues/9 and https://github.com/Sokomine/replacer/pull/10 Edit: issue on [mobs_redo]: https://notabug.org/TenPlus1/mobs_redo/issues/109