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,29 +269,20 @@ internal static bool GetInvokerForHashSyncEvent(int cmdHash, out CmdDelegate inv
|
|||||||
static bool GetInvokerForHash(int cmdHash, UNetInvokeType invokeType, out CmdDelegate invokeFunction)
|
static bool GetInvokerForHash(int cmdHash, UNetInvokeType invokeType, out CmdDelegate invokeFunction)
|
||||||
{
|
{
|
||||||
Invoker invoker;
|
Invoker invoker;
|
||||||
if (!s_CmdHandlerDelegates.TryGetValue(cmdHash, out invoker))
|
if (s_CmdHandlerDelegates.TryGetValue(cmdHash, out invoker) &&
|
||||||
|
invoker != null &&
|
||||||
|
invoker.invokeType == invokeType)
|
||||||
{
|
{
|
||||||
if (LogFilter.Debug) { Debug.Log("GetInvokerForHash hash:" + cmdHash + " not found"); }
|
invokeFunction = invoker.invokeFunction;
|
||||||
invokeFunction = null;
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invoker == null)
|
// debug message if not found, or null, or mismatched type
|
||||||
{
|
// (no need to throw an error, an attacker might just be trying to
|
||||||
if (LogFilter.Debug) { Debug.Log("GetInvokerForHash hash:" + cmdHash + " invoker null"); }
|
// call an cmd with an rpc's hash)
|
||||||
invokeFunction = null;
|
if (LogFilter.Debug) { Debug.Log("GetInvokerForHash hash:" + cmdHash + " not found"); }
|
||||||
return false;
|
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)
|
internal bool InvokeCommandDelegate(int cmdHash, NetworkReader reader)
|
||||||
|
Loading…
Reference in New Issue
Block a user