New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pointed_thing_to_face_pos: Fix crash when inside a node #7342
Conversation
Clang tidy seems broken @nerzhul here and in other recent commits:
|
builtin/common/misc_helpers.lua
Outdated
@@ -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 when head is inside a non-walkable and buildable_to node, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessary a non-walkable and buildable_to node. It can be any node if the player placed into themselves (minetest.conf setting).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, will update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In testing, it doesn't crash when inside a normal cube node, using 'build where stand'. However will make comment less specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
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.
Updated comment to be less specific. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…inetest#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.
#6643 Avoid crash when head is inside a non-walkable and buildable_to node,
causing 'above' to equal 'under'.
In this situation return 'under' which is a vector very close to what
would be returned if not inside the node.
//////////////////
For #6643
Tested.
To reproduce crash in MTG:
Enable free move, fly down a little, and place a stair or slab while player head is inside long grass, dry shrub, junglegrass etc.
With PR, the result is suitable and intuitive: the stair or slab is placed where the plantlike node is.
The issue suggested returning
vector.new()
(a zero vector). Although that has the same suitable result in the 'stairs' mod it may be unsuitable for other mods. Normally a float position vector is returned that is the point on the node's face, so i chose to returnpointed_thing.under
which is the integer position vector of the node itself.