NetworkBehaviour.GetInvokerForHash simplified

This commit is contained in:
vis2k 2018-12-30 17:42:36 +01:00
parent c9f68f4b73
commit c52e36af57

View File

@ -269,31 +269,22 @@ internal static bool GetInvokerForHashSyncEvent(int cmdHash, out CmdDelegate inv
static bool GetInvokerForHash(int cmdHash, UNetInvokeType invokeType, out CmdDelegate invokeFunction)
{
Invoker invoker;
if (!s_CmdHandlerDelegates.TryGetValue(cmdHash, out invoker))
if (s_CmdHandlerDelegates.TryGetValue(cmdHash, out invoker) &&
invoker != null &&
invoker.invokeType == invokeType)
{
invokeFunction = invoker.invokeFunction;
return true;
}
// debug message if not found, or null, or mismatched type
// (no need to throw an error, an attacker might just be trying to
// call an cmd with an rpc's hash)
if (LogFilter.Debug) { Debug.Log("GetInvokerForHash hash:" + cmdHash + " not found"); }
invokeFunction = null;
return false;
}
if (invoker == null)
{
if (LogFilter.Debug) { Debug.Log("GetInvokerForHash hash:" + cmdHash + " invoker null"); }
invokeFunction = null;
return false;
}
if (invoker.invokeType != invokeType)
{
Debug.LogError("GetInvokerForHash hash:" + cmdHash + " mismatched invokeType");
invokeFunction = null;
return false;
}
invokeFunction = invoker.invokeFunction;
return true;
}
internal bool InvokeCommandDelegate(int cmdHash, NetworkReader reader)
{
Invoker invoker;