forked from VoxeLibre/VoxeLibre
Merge pull request 'MISC/mcl_selftests: Do not crash if minetest.find_nodes_in_area() lies' (#214) from fix-selftest-crash into master
Reviewed-on: Mineclonia/Mineclonia#214 Reviewed-by: cora <cora@noreply.git.minetest.land>
This commit is contained in:
commit
93a0879b40
|
@ -75,14 +75,22 @@ local test_minetest_find_nodes_in_area_can_count = function(dtime)
|
||||||
local nodes_expected = math.pow( 1 + (2 * radius), 3 )
|
local nodes_expected = math.pow( 1 + (2 * radius), 3 )
|
||||||
local nodes_counted = nnum[nodename]
|
local nodes_counted = nnum[nodename]
|
||||||
local nodes_difference = nodes_expected - nodes_counted
|
local nodes_difference = nodes_expected - nodes_counted
|
||||||
-- Yes, the following line is supposed to crash the game in
|
-- Originally, there was an assertion here that made the game
|
||||||
-- the case that Minetest forgot how to count the number of
|
-- crash at startup if Minetest forgot how to count. This was
|
||||||
-- nodes in a three dimensional volume it just filled. This
|
-- originally intended to avoid buggy engine releases, but it
|
||||||
-- function contains an excellent explanation on what not to
|
-- mostly made people upset and hindered debugging. Also, the
|
||||||
-- do further up. I strongly suggest to pester Minetest core
|
-- assertion contained no error message hinting at the reason
|
||||||
-- devs about this issue and not the author of the function,
|
-- for the crash, making it exceptionally user-unfriendly. It
|
||||||
-- should this test ever fail.
|
-- follows that a game or mod should only assert on behaviour
|
||||||
assert ( 0 == nodes_difference )
|
-- of the Lua code, not the underlying implementation, unless
|
||||||
|
-- engine bugs are bad enough to permanently corrupt a world.
|
||||||
|
if ( 0 ~= nodes_difference ) then
|
||||||
|
minetest.debug(
|
||||||
|
"minetest.find_nodes_in_area() failed to find " ..
|
||||||
|
nodes_difference .. " nodes that were placed. " ..
|
||||||
|
"Downgrading to Minetest 5.4.1 might fix this."
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.after( 0, test_minetest_find_nodes_in_area_can_count )
|
minetest.after( 0, test_minetest_find_nodes_in_area_can_count )
|
||||||
|
|
Loading…
Reference in New Issue