@@ -1441,6 +1441,7 @@ private void ProcessNetworkBehaviour(TypeDefinition typeDefinition, string[] ass
14411441 }
14421442
14431443 var invokePermission = RpcInvokePermission . Anyone ;
1444+
14441445 foreach ( var attrField in rpcAttribute . Fields )
14451446 {
14461447 switch ( attrField . Name )
@@ -1537,6 +1538,7 @@ private void ProcessNetworkBehaviour(TypeDefinition typeDefinition, string[] ass
15371538 private CustomAttribute CheckAndGetRpcAttribute ( MethodDefinition methodDefinition )
15381539 {
15391540 CustomAttribute rpcAttribute = null ;
1541+
15401542 foreach ( var customAttribute in methodDefinition . CustomAttributes )
15411543 {
15421544 var customAttributeType_FullName = customAttribute . AttributeType . FullName ;
@@ -1620,6 +1622,30 @@ private CustomAttribute CheckAndGetRpcAttribute(MethodDefinition methodDefinitio
16201622
16211623 return null ;
16221624 }
1625+
1626+ bool hasRequireOwnership = false , hasInvokePermission = false ;
1627+
1628+ foreach ( var argument in rpcAttribute . Fields )
1629+ {
1630+ switch ( argument . Name )
1631+ {
1632+ case k_ServerRpcAttribute_RequireOwnership :
1633+ hasRequireOwnership = true ;
1634+ break ;
1635+ case k_RpcAttribute_InvokePermission :
1636+ hasInvokePermission = true ;
1637+ break ;
1638+ default :
1639+ break ;
1640+ }
1641+ }
1642+
1643+ if ( hasRequireOwnership && hasInvokePermission )
1644+ {
1645+ m_Diagnostics . AddError ( "Rpc attribute cannot declare both RequireOwnership and InvokePermission!" ) ;
1646+ return null ;
1647+ }
1648+
16231649 // Checks for IsSerializable are moved to later as the check is now done by dynamically seeing if any valid
16241650 // serializer OR extension method exists for it.
16251651 return rpcAttribute ;
@@ -2366,6 +2392,7 @@ private void InjectWriteAndCallBlocks(MethodDefinition methodDefinition, CustomA
23662392 m_Diagnostics. AddError ( $ "{ nameof ( RpcAttribute ) } contains field { field } which is not present in { nameof ( RpcAttribute . RpcAttributeParams ) } .") ;
23672393 }
23682394 }
2395+
23692396 instructions. Add ( processor . Create ( OpCodes . Ldloc , rpcAttributeParamsIdx ) ) ;
23702397
23712398 // defaultTarget
0 commit comments