-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: networkvariable collections can be modified without write permis…
…sions and more (#3081) * fix Provide additional copy of last known current NetworkVariable.Value to be able to compare against the current local value in order to detect if a client without write permissions has modified a collection. * test Updated collections validation tests to spot check the restore known current state when client without write permissions modifies a collection. * update added changelog entry * fix Changing order of operations within CheckDirtyState for clients without write permissions * test Add some spot checks to one of the dictionary tests * fix Fixing issue where upon a client gaining ownership of a NetworkObject that has one or more owner write permission NetworkVariables using a collection type with keyed indices (like a dictionary) can resend already synchronized entries when making a change to the collection causing non-owner clients to throw a key already exists exception. * update Adding changelog entrry * update Adjusted when the NetworkVariable update for ownership change is invoked to account for updates to owner write NetworkVariables within the OnGainedOwnership callback. When changing ownership: - Marking any owner read permissions NetworkVariables as dirty when sending to the new owner (both within NetworkSpawnManager for server-side update and within the NetworkVariableDeltaMessage). - Sending any pending updates to all clients prior to sending the change in ownership message to assure pending updates are synchronized as the owner. When initially synchronizing a client, if a NetworkVariable has a pending state update then send serialize the previously known value(s) to the synchronizing client so when the pending updates are sent they don't duplicate values. * test Adjusting two deferred message tests to not account for a NetworkVariable delta state update message when changing ownership and there are no pending updates. * update updating changelog entries * style * fix This includes additional fixes for NetworkVariable collections that ended up requiring a different approach to how a server forwards NetworkVariable deltas. Now, NetworkVariableDeltaMessage forwards NetworkVariable field deltas immediately after a server has finished processing the deltas (i.e. the keeping a NetworkVariable dirty concept is not used from this point forward). I went ahead and kept the compatibility of this functionality. NetworkVariableDeltaMessage has had its Version incremented as we now send the NetworkDelivery type in order to be able to handle this (it seemed less risky to include this than to try and bubble up this property to all message types). This also separates the duplication of the "original internal value" and the "previous value" until after processing all deltas. If the server has to foward, it forwards first then invokes the PostDeltaRead method that performs the duplication. This includes some minor adjustments to NetworkList in order to adjust to this new order of operations while also preserving the legacy approach. This also includes some adjustments to NetworkBehaviourUpdater where it can force a send (flush) any pending dirty fields when changing ownership. This includes some minor modifications to NetworkObject.PostNetworkVariableWrite. * test Just some updates to two integration tests. These are all primarily for debugging purposes. * update Adding last change log entry for this PR. * style Updated a changelog entry to make it clearer. * fix DAHost fixes: Fixed issue where it was possible to ignore forwarding a change in ownership message to the destination owner if the original owner changed ownership. Fixed issue where it was possible to re-send a change in ownership message back to the original owner if the original owner sent the message. * test Adding and additional test that validates several of the fixes in this PR. * test fix Removing the DAHost testfixture that wasn't supposed to be added. Fixing an issue with the NetworkObjectOwnershipTests when running in DAHost mode. It was passing because the DAHost was sending the ChangeOwnershipMessage back to the owner that changed ownership to another client (without the fix for that in this PR it would send the message to the authority/owner which is why the test was passing). * Update com.unity.netcode.gameobjects/Runtime/Messaging/Messages/NetworkVariableDeltaMessage.cs Co-authored-by: Dominick <dominick@schroer.ca> * style Updating all instances of k_ServerDeltaForwadingAndNetworkDelivery and replacing with k_ServerDeltaForwardingAndNetworkDelivery --------- Co-authored-by: Dominick <dominick@schroer.ca>
- Loading branch information
1 parent
6b459a1
commit 632bf35
Showing
14 changed files
with
1,608 additions
and
185 deletions.
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
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
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
Oops, something went wrong.