NetworkIdentity.HandleRemoteCall uses NetworkBehaviour.InvokeHandlerDelegate; Removed unnecessary GetInvokerFunctionForHash afterwards.

This commit is contained in:
vis2k 2018-12-30 20:06:33 +01:00
parent fa893c0ff1
commit 8854eba284
2 changed files with 5 additions and 23 deletions

View File

@ -246,18 +246,6 @@ static bool GetInvokerForHash(int cmdHash, UNetInvokeType invokeType, out Invoke
return false; return false;
} }
internal static bool GetInvokerFunctionForHash(int cmdHash, UNetInvokeType invokeType, out CmdDelegate invokeFunction)
{
Invoker invoker;
if (GetInvokerForHash(cmdHash, invokeType, out invoker))
{
invokeFunction = invoker.invokeFunction;
return true;
}
invokeFunction = null;
return false;
}
// InvokeCmd/Rpc/SyncEventDelegate can all use the same function here // InvokeCmd/Rpc/SyncEventDelegate can all use the same function here
internal bool InvokeHandlerDelegate(int cmdHash, UNetInvokeType invokeType, NetworkReader reader) internal bool InvokeHandlerDelegate(int cmdHash, UNetInvokeType invokeType, NetworkReader reader)
{ {

View File

@ -568,21 +568,15 @@ internal void HandleRemoteCall(int componentIndex, int functionHash, UNetInvokeT
return; return;
} }
// find the matching invoke function and NetworkBehaviour class
NetworkBehaviour.CmdDelegate invokeFunction;
if (!NetworkBehaviour.GetInvokerFunctionForHash(functionHash, invokeType, out invokeFunction))
{
// We don't get a valid lookup of the command name when it doesn't exist...
string functionName = NetworkBehaviour.GetCmdHashHandlerName(functionHash);
Debug.LogError("Found no receiver for incoming [" + functionName + "] on " + gameObject + ", the server and client should have the same NetworkBehaviour instances [netId=" + netId + "].");
return;
}
// find the right component to invoke the function on // find the right component to invoke the function on
if (0 <= componentIndex && componentIndex < m_NetworkBehaviours.Length) if (0 <= componentIndex && componentIndex < m_NetworkBehaviours.Length)
{ {
NetworkBehaviour invokeComponent = m_NetworkBehaviours[componentIndex]; NetworkBehaviour invokeComponent = m_NetworkBehaviours[componentIndex];
invokeFunction(invokeComponent, reader); if (!invokeComponent.InvokeHandlerDelegate(functionHash, invokeType, reader))
{
string functionName = NetworkBehaviour.GetCmdHashHandlerName(functionHash);
Debug.LogError("Found no receiver for incoming [" + functionName + "] on " + gameObject + ", the server and client should have the same NetworkBehaviour instances [netId=" + netId + "].");
}
} }
else else
{ {