Closed auouymous closed 3 years ago
Thanks for the PR. Per-player ownership could be confusing if it is not visualized - i.e. not contained in "infotext"
. Hence I would prefer to keep things simple by checking only is_protected
without any specific ownership.
Calling is_protected without an owner would prevent the constructor from working inside protections, even when placed by the owner of the protection. The pipeworks node breaker appears to also set an owner when placed and its lack of displayed ownership isn't a problem. But I could display the owner in infotext if you want.
Oh sorry, I somehow assumed this was for an additional node ownership (dig/place). It's fine like this.
Thank you for modifying the get_player_name() line with empty quotes that I copy and pasted, it pointed out a bypass. You can use a constructor to place a constructor that will have an empty owner and bypass protection. You can't put a constructor directly inside the constructor, but the constructor will break a constructor and put it in its inventory. New commit always gives the constructor an invalid owner and a failure in after_place_node uses an invalid owner.
Check if the player who placed constructor can access protected positions before placing or removing nodes. A mk3 constructor can remove up to 4 nodes into a protection, including chests that contain items. This only fixes the protection bypass, but the constructor should probably call can_dig() before removing nodes to avoid losing items inside inventories.
Existing constructors won't have an owner but will continue to work. Only newly placed constructors will perform the protection check.