From 7363de93baca0c6c08d212ba9c38af3f9c272354 Mon Sep 17 00:00:00 2001 From: vis2k Date: Thu, 8 Oct 2020 10:42:32 +0200 Subject: [PATCH] MessagePacker: remove reundant GetId version. GetId is enough. --- Assets/Mirror/Runtime/MessagePacker.cs | 9 ++------- Assets/Mirror/Runtime/NetworkConnection.cs | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Assets/Mirror/Runtime/MessagePacker.cs b/Assets/Mirror/Runtime/MessagePacker.cs index f6690b286..b43d76be1 100644 --- a/Assets/Mirror/Runtime/MessagePacker.cs +++ b/Assets/Mirror/Runtime/MessagePacker.cs @@ -18,16 +18,11 @@ public static class MessagePacker { public static int GetId() where T : struct, NetworkMessage - { - return GetId(typeof(T)); - } - - public static int GetId(Type type) { // paul: 16 bits is enough to avoid collisions // - keeps the message size small because it gets varinted // - in case of collisions, Mirror will display an error - return type.FullName.GetStableHashCode() & 0xFFFF; + return typeof(T).FullName.GetStableHashCode() & 0xFFFF; } // pack message before sending @@ -40,7 +35,7 @@ public static void Pack(T message, NetworkWriter writer) // this works because value types cannot be derived // if it is a reference type (for example NetworkMessage), // ask the message for the real type - int msgType = GetId(typeof(T)); + int msgType = GetId(); writer.WriteUInt16((ushort)msgType); // serialize message into writer diff --git a/Assets/Mirror/Runtime/NetworkConnection.cs b/Assets/Mirror/Runtime/NetworkConnection.cs index 33fc9b868..76b1e9e11 100644 --- a/Assets/Mirror/Runtime/NetworkConnection.cs +++ b/Assets/Mirror/Runtime/NetworkConnection.cs @@ -190,7 +190,7 @@ public bool InvokeHandler(T msg) // this works because value types cannot be derived // if it is a reference type (for example IMessageBase), // ask the message for the real type - int msgType = MessagePacker.GetId(typeof(T)); + int msgType = MessagePacker.GetId(); MessagePacker.Pack(msg, writer); ArraySegment segment = writer.ToArraySegment();