Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Intersects_protection(): Move from Minetest Game to builtin (#6952)
A useful function that applies 'core.is_protected()' to a 3D lattice of points evenly spaced throughout a defined volume, with a parameter for the maximum spacing of points.
- Loading branch information
Showing
2 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
01bc817
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.
Wouldn't it have been better to name this
minetest.is_area_protected
and encourage protection mods to overwrite it with a more efficient implementation (if possible)?01bc817
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.
Both versions sound good. It's a function that will do its job just fine with any area-based protection system without requiring any modifcation. All builtin/core functions can be overwritten anyway if that's desired.
01bc817
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.
Explicitly mentioning that you are supposed to overwrite this function if possible would still be nice.
01bc817
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.
I agree with @sfan5
I also makes the function name a verb, which is better code style
01bc817
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.
'is area protected' is misleading and less descriptive, it's actually 'does defined volume intersect any protected volume'.
The function name is a verb and makes sense:
(pos) is protected? true/false
(volume) intersects protection? true/false
It's not 'supposed' to be overriden as it is functional code, but it can be overriden if desired or if more efficient to do so in a protection mod.
'is protected' is supposed to be overriden because it is an empty function.
So, it's ok to add a comment:
"This function can be overriden in a protection mod if desired or if more efficient"
I can do this.
All else i disagree with.