Repository navigation
feat(statebag): add private keys that only replicate to the owner - #4391
Open
BigSmoKe07 wants to merge 3 commits into
Open
BigSmoKe07 wants to merge 3 commits into
BigSmoKe07 wants to merge 3 commits into
Conversation
Signed-off-by: Guru Saran <gurusarank@icloud.com>
Contributor
|
I think this is nice to have, but not really necessary - events can already do everything here. Also, why are you still iterating over all peers (O(n)) when the whole point of this PR is to replicate private keys to only one peer (the owner)? Could just send it directly to the owner, the info should be available |
Signed-off-by: Guru Saran <gurusarank@icloud.com>
Signed-off-by: Guru Saran <gurusarank@icloud.com>
Author
|
Events work, but each resource then rebuilds what state bags already do. Use cases from the forum thread:
Loop removed: private keys go straight to the owner. Also fixed: a reused owner ID no longer gets them. |
Contributor
|
Should be banned for spam at this point |
|
@ook3D he is road to 2 pages full of PRs atp |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal of this PR
Let the server keep a state bag key private to the owner of the state bag.
Today every replicated key goes to every player the state bag replicates to, so per-player values such as a balance or a permission level can be read by any client that has that player in scope. The only way around it is to keep such data out of state bags and sync it with events.
How is this PR achieving the goal
StateBag::SetKeyPrivate(key, isPrivate)marks a key that is only sent to the owning peer.SendKeyValueToAllTargetsandSendAll, so owner writes and peers entering scope later are covered.SetOwningPeersends private keys to the new owner and nil to the previous one.SET_STATE_BAG_KEY_PRIVATE, with docs and a test case.Nothing changes on the wire and keys stay public unless a script marks them, so existing resources and clients behave as before.
This PR applies to the following area(s)
FiveM, RedM, Server, Natives
Successfully tested on
Game builds: b3889
Platforms: Windows
Component check:
State Bag private keystest case passes under ASan; a concurrent stress run is clean under TSan.Checklist
Fixes issues
Related: https://forum.cfx.re/t/5002514