Fix incorrect Caller after nested Rpc calls.
#123
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.
Fix incorrect
Callerafter nestedRpccalls.Issue: Facepunch/sbox-issues#7755
Changes
Callerin the outerRpcso that any internal calls useConnection.LocalCalleronce the nestedRpchas finishedCallingtoIsRemoteCallfor clarityPreCallas it is no longer neededNotes
There are 2 bugs in the current code.
Rpcthat is nested within another one, it will permanently change theCallereven once you exit back to the originalRpcscope.Callingboolthat should betruewhen theRpcwas invoked remotely is alwaysfalsewhen accessed within anRpc.I found the name
Callingto be quite confusing so I renamed it toIsRemoteCallwhich I think is clearer. I can change it back if you disagree. (Maybe I still need to keepCallingand mark it as obsolete for people who are currently using it? I doubt anyone will be using it since it's broken)I'm not sure if this is the best way to solve this but it's the only way I could come up with after thinking about it for a while. If you have any better ideas let me know and I can try and rework it.
How It Works
InvokeInstanceRpc/IncomingStaticRpcMsgsetsPendingRpcCaller__rpc_Wrapper/OnCallRpcconsumes pending caller and createsWithCallerscopenullpending caller, correctly useConnection.LocalCalleragainDemo Project: rpc_caller_fix.zip
This is small project I made for testing the changes. To use it, just hit play, connect with a client and then look at the server logs.
The code is setup like this so that the broadcast is called in the middle of the Rpc:
Current Behavior:
After Fix: