aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParamat <paramat@users.noreply.github.com>2018-05-16 20:49:46 +0100
committerGitHub <noreply@github.com>2018-05-16 20:49:46 +0100
commit45e48295d203b653041404a75c6e2744b78ced45 (patch)
treeaaf7ee4d2726a9379489d2cc6ecc059af2a8f8c2
parent04f79623a7276a5a09390ac910795ab6c1889dee (diff)
downloadminetest-45e48295d203b653041404a75c6e2744b78ced45.tar.gz
minetest-45e48295d203b653041404a75c6e2744b78ced45.tar.bz2
minetest-45e48295d203b653041404a75c6e2744b78ced45.zip
Pointed_thing_to_face_pos: Avoid crash when player is inside a node (#7342)
Avoid crash in some situations when player is inside a node, causing 'above' to equal 'under'. In this situation return 'under' which is the node position very close to the face position that would normally be returned.
-rw-r--r--builtin/common/misc_helpers.lua6
1 files changed, 6 insertions, 0 deletions
diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua
index 43a6dda48..23b00eafe 100644
--- a/builtin/common/misc_helpers.lua
+++ b/builtin/common/misc_helpers.lua
@@ -685,6 +685,12 @@ end
-- Returns the exact coordinate of a pointed surface
--------------------------------------------------------------------------------
function core.pointed_thing_to_face_pos(placer, pointed_thing)
+ -- Avoid crash in some situations when player is inside a node, causing
+ -- 'above' to equal 'under'.
+ if vector.equals(pointed_thing.above, pointed_thing.under) then
+ return pointed_thing.under
+ end
+
local eye_height = placer:get_properties().eye_height
local eye_offset_first = placer:get_eye_offset()
local node_pos = pointed_thing.under