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

Add require_protection and node_ownership_legacy settings #59

Closed
wants to merge 1 commit into from

Conversation

SmallJoker
Copy link
Member

@SmallJoker SmallJoker commented Mar 25, 2022

require_protection: Disallows interactions outside of owned areas
node_ownership_legacy: Skip 9+ year old compatibility code by default

areas.config.legacy_table was never used, hence removed/replaced.

Fixes #58
Fixes #54

Feedback is welcome.

require_protection: Disallows interactions outside of owned areas
node_ownership_legacy: Skip 9+ year old compatibility code by default
@S-S-X
Copy link

S-S-X commented Mar 27, 2022

require_protection: Any way to make this extensible? Basically to easily support any protection mod instead of separate implementation for every protection mod?

It should be possible by adding last override for minetest.is_protected and make 2 calls from there: actual player name and empty string.

  • if both return false then there's probably no protection.
  • if first returns false and second returns true then it is protected area where player has access.
  • if both returns true then it is area protected by another player.

Not sure if that would work well enough and what corner cases there would be (for example open areas) but would be nice to have generic solution that could work with any protection mod and to require minimum changes to actual protection mods.

@SmallJoker
Copy link
Member Author

SmallJoker commented Mar 27, 2022

@S-S-X Your idea is good, but how can any protection mod know whether the position is protected and accessible for the player or whether it's unprotected?
Some protection mods also have options to allow access to everyone. The area would be "protected" but impossible to distinguish from open maps.

@S-S-X
Copy link

S-S-X commented Mar 27, 2022

but how can any protection mod know whether the position is protected and accessible for the player or whether it's unprotected?

Protection mods usually do know this for their own protections, suggestion with dual call was exactly to make call that likely returns true for every protection to check for any protection from any protection mod and then another call to check for actual protection against player.
Access for everyone (open areas) and such however probably makes this way too complicated approach.

Some protection mods also have options to allow access to everyone. The area would be "protected" but impossible to distinguish from open maps.

Yeah, that's exactly one of those corner cases I've mentioned... and probably dual calls to is_protected wont work well enough as it would break many open/public areas.

One way I could think of that might possibly work would be to return both "is_protected" and protection state from minetest.is_protected (should be fully backwards compatible and not needed at all for mods that do not do "allow all" ever):

function minetest.is_protected(...)
    -- access granted but position is protected
    return false, true
end

That would require some changes to protection mods but would be minimal just adding second return value.
Mods that do not implement both return values (second is nil) can be handled with default until said protection mod adds support (it would be problem only with ones that add "public" protections).
Grab and forward return values from chain with mods that do not return protection status can be done with __index meta method (metatables can be extended so multiple can be kind of stacked).

@SmallJoker
Copy link
Member Author

No future in this PR.

@SmallJoker SmallJoker closed this May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option to disable all player interaction outside of their claimed area? minetest.place_node broken
2 participants