@@ -617,8 +617,6 @@ private void CreateNetworkVariableTypeInitializers(AssemblyDefinition assembly,
617617 private const string k_RpcAttribute_Delivery = nameof ( RpcAttribute . Delivery ) ;
618618 private const string k_RpcAttribute_InvokePermission = nameof ( RpcAttribute . InvokePermission ) ;
619619
620- private const string k_ServerRpcAttribute_RequireOwnership = "RequireOwnership" ;
621-
622620 private const string k_RpcParams_Server = nameof ( __RpcParams . Server ) ;
623621 private const string k_RpcParams_Client = nameof ( __RpcParams . Client ) ;
624622 private const string k_RpcParams_Ext = nameof ( __RpcParams . Ext ) ;
@@ -1499,10 +1497,6 @@ private void ProcessNetworkBehaviour(TypeDefinition typeDefinition, string[] ass
14991497 {
15001498 switch ( attrField . Name )
15011499 {
1502- case k_ServerRpcAttribute_RequireOwnership :
1503- var requireOwnership = attrField . Argument . Type == rpcHandler . Module . TypeSystem . Boolean && ( bool ) attrField . Argument . Value ;
1504- invokePermission = requireOwnership ? RpcInvokePermission . Owner : RpcInvokePermission . Everyone ;
1505- break ;
15061500 case k_RpcAttribute_InvokePermission :
15071501 invokePermission = ( RpcInvokePermission ) attrField . Argument . Value ;
15081502 break ;
@@ -1689,28 +1683,6 @@ private CustomAttribute CheckAndGetRpcAttribute(MethodDefinition methodDefinitio
16891683 return null ;
16901684 }
16911685
1692- bool hasInvokePermission = false , hasRequireOwnership = false ;
1693-
1694- foreach ( var argument in rpcAttribute . Fields )
1695- {
1696- switch ( argument . Name )
1697- {
1698- case k_ServerRpcAttribute_RequireOwnership :
1699- hasRequireOwnership = true ;
1700- break ;
1701- case k_RpcAttribute_InvokePermission :
1702- hasInvokePermission = true ;
1703- break ;
1704- }
1705- }
1706-
1707- if ( hasInvokePermission && hasRequireOwnership )
1708- {
1709- m_Diagnostics . AddError ( $ "{ methodDefinition . Name } cannot declare both RequireOwnership and InvokePermission!") ;
1710- return null ;
1711- }
1712-
1713-
17141686 // Checks for IsSerializable are moved to later as the check is now done by dynamically seeing if any valid
17151687 // serializer OR extension method exists for it.
17161688 return rpcAttribute ;
@@ -2177,7 +2149,6 @@ private void InjectWriteAndCallBlocks(MethodDefinition methodDefinition, CustomA
21772149 var isServerRpc = rpcAttribute . AttributeType . FullName == CodeGenHelpers . ServerRpcAttribute_FullName ;
21782150 var isClientRpc = rpcAttribute . AttributeType . FullName == CodeGenHelpers . ClientRpcAttribute_FullName ;
21792151 var isGenericRpc = rpcAttribute . AttributeType . FullName == CodeGenHelpers . RpcAttribute_FullName ;
2180- var requireOwnership = true; // default value MUST be == `ServerRpcAttribute.RequireOwnership`
21812152 var rpcDelivery = RpcDelivery . Reliable ; // default value MUST be == `RpcAttribute.Delivery`
21822153 var defaultTarget = SendTo. Everyone;
21832154 var allowTargetOverride = false;
@@ -2193,9 +2164,6 @@ private void InjectWriteAndCallBlocks(MethodDefinition methodDefinition, CustomA
21932164 case k_RpcAttribute_Delivery:
21942165 rpcDelivery = ( RpcDelivery) attrField . Argument . Value ;
21952166 break ;
2196- case k_ServerRpcAttribute_RequireOwnership :
2197- requireOwnership = attrField . Argument . Type == typeSystem . Boolean && ( bool ) attrField . Argument . Value ;
2198- break ;
21992167 case nameof ( RpcAttribute . AllowTargetOverride ) :
22002168 allowTargetOverride = attrField . Argument . Type = = typeSystem . Boolean && ( bool ) attrField . Argument . Value ;
22012169 break ;
@@ -2317,42 +2285,6 @@ private void InjectWriteAndCallBlocks(MethodDefinition methodDefinition, CustomA
23172285 {
23182286 // ServerRpc
23192287
2320- if ( requireOwnership )
2321- {
2322- var roReturnInstr = processor. Create ( OpCodes . Ret ) ;
2323- var roLastInstr = processor. Create ( OpCodes . Nop ) ;
2324-
2325- // if (this.OwnerClientId != networkManager.LocalClientId) { ... } return;
2326- instructions. Add ( processor . Create ( OpCodes . Ldarg_0 ) ) ;
2327- instructions. Add ( processor . Create ( OpCodes . Call , m_NetworkBehaviour_getOwnerClientId_MethodRef ) ) ;
2328- instructions. Add ( processor . Create ( OpCodes . Ldloc , netManLocIdx ) ) ;
2329- instructions. Add ( processor . Create ( OpCodes . Callvirt , m_NetworkManager_getLocalClientId_MethodRef ) ) ;
2330- instructions. Add ( processor . Create ( OpCodes . Ceq ) ) ;
2331- instructions. Add ( processor . Create ( OpCodes . Ldc_I4 , 0 ) ) ;
2332- instructions. Add ( processor . Create ( OpCodes . Ceq ) ) ;
2333- instructions. Add ( processor . Create ( OpCodes . Brfalse , roLastInstr ) ) ;
2334-
2335- var logNextInstr = processor. Create ( OpCodes . Nop ) ;
2336-
2337- // if (LogLevel.Normal > networkManager.LogLevel)
2338- instructions. Add ( processor . Create ( OpCodes . Ldloc , netManLocIdx ) ) ;
2339- instructions. Add ( processor . Create ( OpCodes . Ldfld , m_NetworkManager_LogLevel_FieldRef ) ) ;
2340- instructions. Add ( processor . Create ( OpCodes . Ldc_I4 , ( int ) LogLevel . Normal ) ) ;
2341- instructions. Add ( processor . Create ( OpCodes . Cgt ) ) ;
2342- instructions. Add ( processor . Create ( OpCodes . Ldc_I4 , 0 ) ) ;
2343- instructions. Add ( processor . Create ( OpCodes . Ceq ) ) ;
2344- instructions. Add ( processor . Create ( OpCodes . Brfalse , logNextInstr ) ) ;
2345-
2346- // Debug.LogError(...);
2347- instructions. Add ( processor . Create ( OpCodes . Ldstr , "Only the owner can invoke a ServerRpc that requires ownership!" ) ) ;
2348- instructions. Add ( processor . Create ( OpCodes . Call , m_Debug_LogError_MethodRef ) ) ;
2349-
2350- instructions. Add ( logNextInstr ) ;
2351-
2352- instructions. Add ( roReturnInstr ) ;
2353- instructions. Add ( roLastInstr ) ;
2354- }
2355-
23562288 // var bufferWriter = __beginSendServerRpc(rpcMethodId, serverRpcParams, rpcDelivery);
23572289 instructions. Add ( processor . Create ( OpCodes . Ldarg_0 ) ) ;
23582290
@@ -2960,14 +2892,10 @@ private MethodDefinition GenerateStaticHandler(MethodDefinition methodDefinition
29602892 var processor = rpcHandler. Body. GetILProcessor( ) ;
29612893
29622894 var isServerRpc = rpcAttribute. AttributeType. FullName == CodeGenHelpers. ServerRpcAttribute_FullName;
2963- var requireOwnership = true; // default value MUST be == `ServerRpcAttribute.RequireOwnership`
29642895 foreach ( var attrField in rpcAttribute. Fields)
29652896 {
29662897 switch ( attrField. Name)
29672898 {
2968- case k_ServerRpcAttribute_RequireOwnership:
2969- requireOwnership = attrField. Argument. Type == typeSystem. Boolean && ( bool ) attrField. Argument. Value;
2970- break ;
29712899 }
29722900 }
29732901
@@ -2996,44 +2924,6 @@ private MethodDefinition GenerateStaticHandler(MethodDefinition methodDefinition
29962924 processor. Append( lastInstr) ;
29972925 }
29982926
2999- if ( isServerRpc && requireOwnership)
3000- {
3001- var roReturnInstr = processor. Create( OpCodes. Ret) ;
3002- var roLastInstr = processor. Create( OpCodes. Nop) ;
3003-
3004- // if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId) { ... } return;
3005- processor. Emit( OpCodes. Ldarg_2) ;
3006- processor. Emit( OpCodes. Ldfld, m_RpcParams_Server_FieldRef) ;
3007- processor. Emit( OpCodes. Ldfld, m_ServerRpcParams_Receive_FieldRef) ;
3008- processor. Emit( OpCodes. Ldfld, m_ServerRpcParams_Receive_SenderClientId_FieldRef) ;
3009- processor. Emit( OpCodes. Ldarg_0) ;
3010- processor. Emit( OpCodes. Call, m_NetworkBehaviour_getOwnerClientId_MethodRef) ;
3011- processor. Emit( OpCodes. Ceq) ;
3012- processor. Emit( OpCodes. Ldc_I4, 0 ) ;
3013- processor. Emit( OpCodes. Ceq) ;
3014- processor. Emit( OpCodes. Brfalse, roLastInstr) ;
3015-
3016- var logNextInstr = processor. Create( OpCodes. Nop) ;
3017-
3018- // if (LogLevel.Normal > networkManager.LogLevel)
3019- processor. Emit( OpCodes. Ldloc, netManLocIdx) ;
3020- processor. Emit( OpCodes. Ldfld, m_NetworkManager_LogLevel_FieldRef) ;
3021- processor. Emit( OpCodes. Ldc_I4, ( int ) LogLevel. Normal) ;
3022- processor. Emit( OpCodes. Cgt) ;
3023- processor. Emit( OpCodes. Ldc_I4, 0 ) ;
3024- processor. Emit( OpCodes. Ceq) ;
3025- processor. Emit( OpCodes. Brfalse, logNextInstr) ;
3026-
3027- // Debug.LogError(...);
3028- processor. Emit( OpCodes. Ldstr, "Only the owner can invoke a ServerRpc that requires ownership! ") ;
3029- processor. Emit( OpCodes. Call, m_Debug_LogError_MethodRef) ;
3030-
3031- processor. Append( logNextInstr) ;
3032-
3033- processor. Append( roReturnInstr) ;
3034- processor. Append( roLastInstr) ;
3035- }
3036-
30372927 // read method parameters from stream
30382928 int paramCount = methodDefinition. Parameters. Count;
30392929 int [ ] paramLocalMap = new int [ paramCount] ;
0 commit comments