2
3
Fork
You've already forked protector
2

Support multiple factions #13

Closed
opened 2025年08月16日 13:25:37 +02:00 by tuxmain · 6 comments

On my server, some players may want to use multiple factions, for example one for sharing a town with friends, others for leasing areas to other players. The advantage of factions here is that the owner is not forced to manually update all the protectors to add or remove someone. The nonempty faction intersection algorithm is not appropriate for this use.

I implemented a faction list that behaves the same way as the member list: enter a list of factions, of which members are allowed to access the area.

My fork: git.txmn.tk/tuxmain/luanti-protector@39d43f643a

It is a breaking change (the checkbox is gone).

If you're interested in merging upstream, I can make my commit cleaner.

Also I had to fix the returns in playerfactions (reverted changes from this commit because functions that were seemingly supposed to returns lists or nil returned booleans (unless there is some Lua dark magic in there I don't understand).

On my server, some players may want to use multiple factions, for example one for sharing a town with friends, others for leasing areas to other players. The advantage of factions here is that the owner is not forced to manually update all the protectors to add or remove someone. The nonempty faction intersection algorithm is not appropriate for this use. I implemented a faction list that behaves the same way as the member list: enter a list of factions, of which members are allowed to access the area. My fork: https://git.txmn.tk/tuxmain/luanti-protector/commit/39d43f643ab347de31dab4a5593f78180e9d82ad It is a breaking change (the checkbox is gone). If you're interested in merging upstream, I can make my commit cleaner. Also I had to fix the returns in `playerfactions` (reverted changes from [this commit](https://github.com/mt-mods/playerfactions/commit/c629b298f9d7888ad390360eccf3f065138807ce#diff-0fc5c43f6f1d7605fd7d16c088ba6b83f096eee8e2049517407bbaa27aa3a4f7) because functions that were seemingly supposed to returns lists or nil returned booleans (unless there is some Lua dark magic in there I don't understand).

The new feature looks good, although it would break backwards compatibility for current faction enabled tick boxes within a protector elsewhere, so we need a fix for this before adding.

The new feature looks good, although it would break backwards compatibility for current faction enabled tick boxes within a protector elsewhere, so we need a fix for this before adding.
Author
Copy link

It may be a migration function that, if the checkbox is checked in the storage, removes this value and adds all the owner's factions.

It still breaks behavior (the owner joining factions no longer "updates" the protectors) but it's enough if the owner has only one faction.

Or a wildcard * faction may allow any of the owner's factions. (the migration function would add this wildcard faction) Then nothing is broken.

It may be a migration function that, if the checkbox is checked in the storage, removes this value and adds all the owner's factions. It still breaks behavior (the owner joining factions no longer "updates" the protectors) but it's enough if the owner has only one faction. Or a wildcard `*` faction may allow any of the owner's factions. (the migration function would add this wildcard faction) Then nothing is broken.
Author
Copy link

I added the joker * and the automatic migration (in is_member).

I removed the test that prevents adding an already present name, because it was using is_member, but this function does not behave as a simple "is in list" check.

git.txmn.tk/tuxmain/luanti-protector@751ab8953b

I added the joker `*` and the automatic migration (in `is_member`). I removed the test that prevents adding an already present name, because it was using `is_member`, but this function does not behave as a simple "is in list" check. https://git.txmn.tk/tuxmain/luanti-protector/commit/751ab8953b8a6a7797285c5ba3e03f754091fa16

I've added multiple faction support with some changes, can you test to make sure it works as it should and I'll update ContentDB.

I've added multiple faction support with some changes, can you test to make sure it works as it should and I'll update ContentDB.
Author
Copy link

It works.
Thanks!

I also updated the french and spanish locales (and fixed all the french locales, there were some errors).

It works. Thanks! I also updated the french and spanish locales (and fixed all the french locales, there were some errors).

Good to hear, will update ContentDB.

Good to hear, will update ContentDB.
Sign in to join this conversation.
No Branch/Tag specified
master
No results found.
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
tenplus1/protector#13
Reference in a new issue
tenplus1/protector
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?