BuckarooBanzay / digibuilder

0 stars 2 forks source link

digibuilder allows getnode/setnode on places it shouldn't #20

Closed TheEt1234 closed 6 months ago

TheEt1234 commented 6 months ago
nan=0/0

if event.type=="program" then
digiline_send("digibuilder",{
command="setnode",
pos={
  x=0,y=0,z=nan
  },
name="default:cobble",
param2=0

})
end

print(event)

actually builds the node (if the target position isn't protected or occupied)

what's going on here

digibuilder's https://github.com/BuckarooBanzay/digibuilder/blob/master/digiline_validate_pos.lua does not check for NaN

x<NaN = false x>NaN = false x==NaN = false (so passes the max radius checks)

and minetest somehow interprets NaN as 0

so when pos={x=0,y=0,z=nan} it will build at x=digibuilder's x,y= digibuilder's y, z=0

fix

simply check for nan

BuckarooBanzay commented 6 months ago

thanks for reporting that, the position-check is now a bit stricter and should not allow any NaN's in it :)

TheEt1234 commented 6 months ago

@BuckarooBanzay i don't think that fixes the bug, since type(0/0)=="number"

A simple way to detect NaN would be x ~= x

OgelGames commented 6 months ago

minetest.is_nan() exists too :)

BuckarooBanzay commented 6 months ago

this should now be properly fixed with https://github.com/BuckarooBanzay/digibuilder/commit/faa4e5b7b265400b9e4571420d3f55a5ff7f3bf2 and https://github.com/BuckarooBanzay/digibuilder/commit/84ca01da026bcedfa7ac7790c794caa6a742229e

minetest.is_nan() exists too :)

thanks, totally forgot we have that :+1:

OgelGames commented 6 months ago

https://github.com/minetest-mods/mesecons/pull/667 https://github.com/mt-mods/pipeworks/commit/8828183befafdf1bf3a26e3b6303cc824da36b81 https://github.com/mt-mods/mooncontroller/commit/a72aa33c489d43d8992377a71c3358a491824467