Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Assets/Mirror/Core/NetworkBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ protected void InitSyncObject(SyncObject syncObject)
}

// pass full function name to avoid ClassA.Func <-> ClassB.Func collisions
protected void SendCommandInternal(string functionFullName, int functionHashCode, NetworkWriter writer, int channelId, bool requiresAuthority = true)
protected void SendCommandInternal(string functionFullName, ushort functionHashCode, NetworkWriter writer, int channelId, bool requiresAuthority = true)
{
// this was in Weaver before
// NOTE: we could remove this later to allow calling Cmds on Server
Expand Down Expand Up @@ -418,7 +418,7 @@ protected void SendCommandInternal(string functionFullName, int functionHashCode
netId = netId,
componentIndex = ComponentIndex,
// type+func so Inventory.RpcUse != Equipment.RpcUse
functionHash = (ushort)functionHashCode,
functionHash = functionHashCode,
// segment to avoid reader allocations
payload = writer.ToArraySegment()
};
Expand All @@ -434,7 +434,7 @@ protected void SendCommandInternal(string functionFullName, int functionHashCode
}

// pass full function name to avoid ClassA.Func <-> ClassB.Func collisions
protected void SendRPCInternal(string functionFullName, int functionHashCode, NetworkWriter writer, int channelId, bool includeOwner)
protected void SendRPCInternal(string functionFullName, ushort functionHashCode, NetworkWriter writer, int channelId, bool includeOwner)
{
// this was in Weaver before
if (!NetworkServer.active)
Expand All @@ -456,7 +456,7 @@ protected void SendRPCInternal(string functionFullName, int functionHashCode, Ne
netId = netId,
componentIndex = ComponentIndex,
// type+func so Inventory.RpcUse != Equipment.RpcUse
functionHash = (ushort)functionHashCode,
functionHash = functionHashCode,
// segment to avoid reader allocations
payload = writer.ToArraySegment()
};
Expand Down Expand Up @@ -488,7 +488,7 @@ protected void SendRPCInternal(string functionFullName, int functionHashCode, Ne
}

// pass full function name to avoid ClassA.Func <-> ClassB.Func collisions
protected void SendTargetRPCInternal(NetworkConnection conn, string functionFullName, int functionHashCode, NetworkWriter writer, int channelId)
protected void SendTargetRPCInternal(NetworkConnection conn, string functionFullName, ushort functionHashCode, NetworkWriter writer, int channelId)
{
if (!NetworkServer.active)
{
Expand Down Expand Up @@ -527,7 +527,7 @@ protected void SendTargetRPCInternal(NetworkConnection conn, string functionFull
netId = netId,
componentIndex = ComponentIndex,
// type+func so Inventory.RpcUse != Equipment.RpcUse
functionHash = (ushort)functionHashCode,
functionHash = functionHashCode,
// segment to avoid reader allocations
payload = writer.ToArraySegment()
};
Expand Down
2 changes: 1 addition & 1 deletion Assets/Mirror/Core/RemoteCalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static bool CheckIfDelegateExists(Type componentType, RemoteCallType remoteCallT
internal static ushort RegisterDelegate(Type componentType, string functionFullName, RemoteCallType remoteCallType, RemoteCallDelegate func, bool cmdRequiresAuthority = true)
{
// type+func so Inventory.RpcUse != Equipment.RpcUse
ushort hash = (ushort)(functionFullName.GetStableHashCode() & 0xFFFF);
ushort hash = functionFullName.GetStableHashCode16();

if (CheckIfDelegateExists(componentType, remoteCallType, func, hash))
return hash;
Expand Down
2 changes: 1 addition & 1 deletion Assets/Mirror/Editor/Weaver/Processors/CommandProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static MethodDefinition ProcessCommandCall(WeaverTypes weaverTypes, Write
// otherwise each GetStableHash call requires O(N) complexity.
// noticeable for long function names:
// https://github.com/MirrorNetworking/Mirror/issues/3375
worker.Emit(OpCodes.Ldc_I4, md.FullName.GetStableHashCode());
worker.Emit(OpCodes.Ldc_I4, md.FullName.GetStableHashCode16());
// writer
worker.Emit(OpCodes.Ldloc_0);
worker.Emit(OpCodes.Ldc_I4, channel);
Expand Down
2 changes: 1 addition & 1 deletion Assets/Mirror/Editor/Weaver/Processors/RpcProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static MethodDefinition ProcessRpcCall(WeaverTypes weaverTypes, Writers w
// otherwise each GetStableHash call requires O(N) complexity.
// noticeable for long function names:
// https://github.com/MirrorNetworking/Mirror/issues/3375
worker.Emit(OpCodes.Ldc_I4, md.FullName.GetStableHashCode());
worker.Emit(OpCodes.Ldc_I4, md.FullName.GetStableHashCode16());
// writer
worker.Emit(OpCodes.Ldloc_0);
worker.Emit(OpCodes.Ldc_I4, channel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public static MethodDefinition ProcessTargetRpcCall(WeaverTypes weaverTypes, Wri
// otherwise each GetStableHash call requires O(N) complexity.
// noticeable for long function names:
// https://github.com/MirrorNetworking/Mirror/issues/3375
worker.Emit(OpCodes.Ldc_I4, md.FullName.GetStableHashCode());
worker.Emit(OpCodes.Ldc_I4, md.FullName.GetStableHashCode16());
// writer
worker.Emit(OpCodes.Ldloc_0);
worker.Emit(OpCodes.Ldc_I4, targetRpcAttr.GetField("channel", 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void GetDelegate()
false);

// get handler
ushort cmdHash = (ushort)nameof(NetworkBehaviourDelegateComponent.Delegate).GetStableHashCode();
ushort cmdHash = nameof(NetworkBehaviourDelegateComponent.Delegate).GetStableHashCode16();
RemoteCallDelegate func = RemoteProcedureCalls.GetDelegate(cmdHash);
RemoteCallDelegate expected = NetworkBehaviourDelegateComponent.Delegate;
Assert.That(func, Is.EqualTo(expected));
Expand Down
Loading