NGO 2.9.0 - ServerRpc deprecated requireOwnership, but InvokePermission.Everyone doesn't work properly

After updating my project from Unity 6.2 to 6.3 and NGO from 2.1.0 to 2.9.0 I noticed that in the ServerRpc attribute, the RequireOwnership property has been deprecated! After changing the attribute to use the recommended InvokePermission, I was getting errors in my game like these:

Only the owner can invoke a ServerRpc that requires ownership!

I found the reason for this is that the NetworkBehaviourILPP script still has two places where the InvokePermission is not looked at, and still uses requireOwnership, resulting in it defaulting to “true”!

  1. InjectWriteAndCallBlock()
    At line ~2182 it reads requireOwnership from the attribute, but doesn’t look at InvokePermission at all.

  2. GenerateStaticHandler()
    At line ~2965 it reads requireOwnership from the attribute, but doesn’t look at InvokePermission at all.

After adding the following code snippets, the ServerRpcs are working as expected again!

case k_RpcAttribute_InvokePermission:
                        RpcInvokePermission invokePermission = (RpcInvokePermission)attrField.Argument.Value;
                        requireOwnership = invokePermission != RpcInvokePermission.Everyone;
                        break;
  case k_RpcAttribute_InvokePermission:
                        RpcInvokePermission invokePermission = (RpcInvokePermission)attrField.Argument.Value;
                        requireOwnership = invokePermission != RpcInvokePermission.Everyone;
                        break;

From this report it sounds like you’re still using the ServerRpc attribute. To get the same behaviour as [ServerRpc(requireOwnership=false)] the supported way is to use [Rpc(SendTo.Server)]. It does look like there is an issue there however, we should be throwing a compilation error when trying to use ServerRpc(InvokePermission = RpcInvokePermission.Everyone)].

The goal is to eventually deprecate the ServerRpc and ClientRpc attributes. Removing requireOwnership was the first step to do that. The new Rpc(SendTo) pattern should be faster, require fewer memory allocations, and is easier for us to maintain. It is also designed to be easier to read and reason about.