Skip to content
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

Merged
merged 1 commit into from May 16, 2018
Merged

Pointed_thing_to_face_pos: Fix crash when inside a node #7342

merged 1 commit into from May 16, 2018

Conversation

paramat
Copy link
Contributor

@paramat paramat commented May 15, 2018

#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 return pointed_thing.under which is the integer position vector of the node itself.

@paramat
Copy link
Contributor Author

paramat commented May 15, 2018

Clang tidy seems broken @nerzhul here and in other recent commits:

-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
IRRLICHT_INCLUDE_DIR (ADVANCED)
   used as include directory in directory /home/travis/build/minetest/minetest/src
   used as include directory in directory /home/travis/build/minetest/minetest/src
   used as include directory in directory /home/travis/build/minetest/minetest/src
   used as include directory in directory /home/travis/build/minetest/minetest/src
   used as include directory in directory /home/travis/build/minetest/minetest/src
   used as include directory in directory /home/travis/build/minetest/minetest/src
   used as include directory in directory /home/travis/build/minetest/minetest/src
   used as include directory in directory /home/travis/build/minetest/minetest/src
   used as include directory in directory /home/travis/build/minetest/minetest/src
   used as include directory in directory /home/travis/build/minetest/minetest/src
   used as include directory in directory /home/travis/build/minetest/minetest/src
   used as include directory in directory /home/travis/build/minetest/minetest/src
IRRLICHT_LIBRARY (ADVANCED)
    linked by target "minetest" in directory /home/travis/build/minetest/minetest/src
-- Configuring incomplete, errors occurred!
See also "/home/travis/build/minetest/minetest/cmakebuild/CMakeFiles/CMakeOutput.log".
make: *** No rule to make target `GenerateVersion'.  Stop.
Performing clang-tidy checks...
Error while trying to load a compilation database:
Could not auto-detect compilation database from directory "cmakebuild"
No compilation database found in /home/travis/build/minetest/minetest/cmakebuild or any parent directory
json-compilation-database: Error while opening JSON database: No such file or directory
Running without flags.
Enabled checks:
    modernize-avoid-bind
    modernize-use-emplace
    performance-faster-string-find
    performance-for-range-copy
    performance-implicit-cast-in-loop
    performance-inefficient-string-concatenation
    performance-inefficient-vector-operation
    performance-type-promotion-in-math-fn
    performance-unnecessary-copy-initialization
    performance-unnecessary-value-param
Traceback (most recent call last):
  File "./util/travis/run-clang-tidy.py", line 271, in <module>
    main()
  File "./util/travis/run-clang-tidy.py", line 209, in main
    database = json.load(open(os.path.join(build_path, db_path)))
IOError: [Errno 2] No such file or directory: 'cmakebuild/compile_commands.json'
Clang tidy returned 1
The command "./util/travis/clangtidy.sh" exited with 1.
Done. Your build exited with 1.

@@ -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,
Copy link
Member

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, will update.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.
@paramat
Copy link
Contributor Author

paramat commented May 16, 2018

Updated comment to be less specific.

Copy link
Member

@SmallJoker SmallJoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@paramat paramat merged commit 45e4829 into minetest:master May 16, 2018
@paramat paramat deleted the fineposcrash branch May 19, 2018 22:43
osjc pushed a commit to osjc/minetest that referenced this pull request Jan 23, 2019
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix 🐛 PRs that fix a bug @ Builtin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants