FirstGearGames / FishNet

FishNet: Unity Networking Evolved.
Other
1.39k stars 149 forks source link

Methods with multiple RPC attributes are counting as only 1 RPC. #669

Closed FirstGearGames closed 6 months ago

FirstGearGames commented 6 months ago

FishNet 4.3.0.

Methods with multiple RPC attributes on a single method and using inheritance will result an a runtime error. 'Rpc Type' key # has already been added for YourClass on GameObject

Resolution is to find Method internal uint GetRpcCount(TypeDefinition typeDef) within RpcProcessor and replace it's entirety with this.

        internal uint GetRpcCount(TypeDefinition typeDef)
        {
            uint count = 0;
            foreach (MethodDefinition methodDef in typeDef.Methods)
            {
                foreach (CustomAttribute customAttribute in methodDef.CustomAttributes)
                {
                    RpcType rpcType = base.GetClass<AttributeHelper>().GetRpcAttributeType(customAttribute);
                    if (rpcType != RpcType.None)
                        count++;
                        break;
                }
            }

            return count;
        }

Resolved in 4.3.1