mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkBehaviour.GetInvokerForHash simplified
This commit is contained in:
parent
c9f68f4b73
commit
c52e36af57
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user