-
Notifications
You must be signed in to change notification settings - Fork 450
fix: ClientRpcs ignores NetworkObject's observer list [MTT-2878] #1836
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
fix: ClientRpcs ignores NetworkObject's observer list [MTT-2878] #1836
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor changes, overall looks neat!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the changes discussed here and in Slack. 👌🏻
@@ -158,7 +158,7 @@ internal void __endSendClientRpc(ref FastBufferWriter bufferWriter, uint rpcMeth | |||
// We check to see if we need to shortcut for the case where we are the host/server and we can send a clientRPC | |||
// to ourself. Sadly we have to figure that out from the list of clientIds :( | |||
bool shouldSendToHost = false; | |||
|
|||
var logLevel = NetworkManager.LogLevel; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though I'm a big fan of temp variables for clarity, I'm not sure this actually does so here.
shouldSendToHost = true; | ||
continue; | ||
} | ||
observerClientIds[observerCount++] = observerEnumerator.Current; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than go to the trouble of allocating and building up the client ids, why not simply here in the while loop do:
NetworkManager.SendMessage(ref clientRpcMessage, networkDelivery, observerEnumerator.Current)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After our internal discussion, I changed my approach to avoid the temporary memory allocation.
This fixes the issue where NetworkBehaviour.__endSendClientRpc ignored the associated NetworkObject's Observers list and would send to all connected clients (including non-observers which would not have that NetworkObject instance).
Changelog
Testing and Documentation