Pointed thing to face pos: Fix crash if opening door with slab or stair
authorMarkuBu <markus.burrer@gmail.com>
Thu, 13 Apr 2017 11:58:34 +0000 (13:58 +0200)
committerparamat <mat.gregory@virginmedia.com>
Wed, 19 Apr 2017 01:01:42 +0000 (02:01 +0100)
Avoids crash caused when 'pointed thing -under' and '-above' are not
face-neighbours, for example in the case of pointing to the top half
of a door.

builtin/common/misc_helpers.lua

index 1c7ff3958b437e3b9c54d6aafed880132ab129d3..fc284c84305b8b36523be10969f96f30de2a546b 100644 (file)
@@ -706,13 +706,14 @@ function core.pointed_thing_to_face_pos(placer, pointed_thing)
        local oc = {}
 
        for c, v in pairs(pos_off) do
-               if v == 0 then
+               if nc or v == 0 then
                        oc[#oc + 1] = c
                else
                        offset = v
                        nc = c
                end
        end
+
        local fine_pos = {[nc] = node_pos[nc] + offset}
        camera_pos.y = camera_pos.y + 1.625 + eye_offset_first.y / 10
        local f = (node_pos[nc] + offset - camera_pos[nc]) / look_dir[nc]
@@ -722,4 +723,3 @@ function core.pointed_thing_to_face_pos(placer, pointed_thing)
        end
        return fine_pos
 end
-