mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
MessagePacker: remove reundant GetId version. GetId<T> is enough.
This commit is contained in:
parent
c709682344
commit
7363de93ba
@ -18,16 +18,11 @@ public static class MessagePacker
|
||||
{
|
||||
public static int GetId<T>()
|
||||
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>(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<T>();
|
||||
writer.WriteUInt16((ushort)msgType);
|
||||
|
||||
// serialize message into writer
|
||||
|
@ -190,7 +190,7 @@ public bool InvokeHandler<T>(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<T>();
|
||||
|
||||
MessagePacker.Pack(msg, writer);
|
||||
ArraySegment<byte> segment = writer.ToArraySegment();
|
||||
|
Loading…
Reference in New Issue
Block a user