diff --git a/Assets/Mirror/Components/Discovery/NetworkDiscoveryBase.cs b/Assets/Mirror/Components/Discovery/NetworkDiscoveryBase.cs index d5a160011..36e0e4d41 100644 --- a/Assets/Mirror/Components/Discovery/NetworkDiscoveryBase.cs +++ b/Assets/Mirror/Components/Discovery/NetworkDiscoveryBase.cs @@ -162,7 +162,7 @@ async Task ReceiveRequestAsync(UdpClient udpClient) using (PooledNetworkReader networkReader = NetworkReaderPool.GetReader(udpReceiveResult.Buffer)) { - long handshake = networkReader.ReadInt64(); + long handshake = networkReader.ReadLong(); if (handshake != secretHandshake) { // message is not for us @@ -339,7 +339,7 @@ async Task ReceiveGameBroadcastAsync(UdpClient udpClient) using (PooledNetworkReader networkReader = NetworkReaderPool.GetReader(udpReceiveResult.Buffer)) { - if (networkReader.ReadInt64() != secretHandshake) + if (networkReader.ReadLong() != secretHandshake) return; Response response = networkReader.Read(); diff --git a/Assets/Mirror/Components/NetworkAnimator.cs b/Assets/Mirror/Components/NetworkAnimator.cs index cea62515e..a1d3be5a5 100644 --- a/Assets/Mirror/Components/NetworkAnimator.cs +++ b/Assets/Mirror/Components/NetworkAnimator.cs @@ -342,7 +342,7 @@ void ReadParameters(NetworkReader reader) bool animatorEnabled = animator.enabled; // need to read values from NetworkReader even if animator is disabled - ulong dirtyBits = reader.ReadUInt64(); + ulong dirtyBits = reader.ReadULong(); for (int i = 0; i < parameters.Length; i++) { if ((dirtyBits & (1ul << i)) == 0) @@ -351,19 +351,19 @@ void ReadParameters(NetworkReader reader) AnimatorControllerParameter par = parameters[i]; if (par.type == AnimatorControllerParameterType.Int) { - int newIntValue = reader.ReadInt32(); + int newIntValue = reader.ReadInt(); if (animatorEnabled) animator.SetInteger(par.nameHash, newIntValue); } else if (par.type == AnimatorControllerParameterType.Float) { - float newFloatValue = reader.ReadSingle(); + float newFloatValue = reader.ReadFloat(); if (animatorEnabled) animator.SetFloat(par.nameHash, newFloatValue); } else if (par.type == AnimatorControllerParameterType.Bool) { - bool newBoolValue = reader.ReadBoolean(); + bool newBoolValue = reader.ReadBool(); if (animatorEnabled) animator.SetBool(par.nameHash, newBoolValue); } @@ -415,9 +415,9 @@ public override void OnDeserialize(NetworkReader reader, bool initialState) { for (int i = 0; i < animator.layerCount; i++) { - int stateHash = reader.ReadInt32(); - float normalizedTime = reader.ReadSingle(); - animator.SetLayerWeight(i, reader.ReadSingle()); + int stateHash = reader.ReadInt(); + float normalizedTime = reader.ReadFloat(); + animator.SetLayerWeight(i, reader.ReadFloat()); animator.Play(stateHash, i, normalizedTime); } diff --git a/Assets/Mirror/Components/NetworkTransformBase.cs b/Assets/Mirror/Components/NetworkTransformBase.cs index e14fedfea..f390111d7 100644 --- a/Assets/Mirror/Components/NetworkTransformBase.cs +++ b/Assets/Mirror/Components/NetworkTransformBase.cs @@ -140,7 +140,7 @@ void DeserializeFromReader(NetworkReader reader) // (rotation is optionally compressed) localPosition = reader.ReadVector3(), localRotation = compressRotation - ? Compression.DecompressQuaternion(reader.ReadUInt32()) + ? Compression.DecompressQuaternion(reader.ReadUInt()) : reader.ReadQuaternion(), // use current target scale, so we can check boolean and reader later, to see if the data is actually sent. localScale = targetComponent.localScale, diff --git a/Assets/Mirror/Editor/Weaver/Readers.cs b/Assets/Mirror/Editor/Weaver/Readers.cs index f5c21e337..dcb5cd219 100644 --- a/Assets/Mirror/Editor/Weaver/Readers.cs +++ b/Assets/Mirror/Editor/Weaver/Readers.cs @@ -19,7 +19,10 @@ internal static void Register(TypeReference dataType, MethodReference methodRefe { if (readFuncs.ContainsKey(dataType)) { - Weaver.Warning($"Registering a Read method for {dataType.FullName} when one already exists", methodReference); + // TODO enable this again later. + // Reader has some obsolete functions that were renamed. + // Don't want weaver warnings for all of them. + //Weaver.Warning($"Registering a Read method for {dataType.FullName} when one already exists", methodReference); } // we need to import type when we Initialize Readers so import here in case it is used anywhere else diff --git a/Assets/Mirror/Runtime/MessagePacking.cs b/Assets/Mirror/Runtime/MessagePacking.cs index e74a2e3ce..66fb63e47 100644 --- a/Assets/Mirror/Runtime/MessagePacking.cs +++ b/Assets/Mirror/Runtime/MessagePacking.cs @@ -49,7 +49,7 @@ public static bool Unpack(NetworkReader messageReader, out ushort msgType) // read message type (varint) try { - msgType = messageReader.ReadUInt16(); + msgType = messageReader.ReadUShort(); return true; } catch (System.IO.EndOfStreamException) diff --git a/Assets/Mirror/Runtime/NetworkBehaviour.cs b/Assets/Mirror/Runtime/NetworkBehaviour.cs index 77e418c19..84a71df40 100644 --- a/Assets/Mirror/Runtime/NetworkBehaviour.cs +++ b/Assets/Mirror/Runtime/NetworkBehaviour.cs @@ -665,7 +665,7 @@ internal void DeSerializeObjectsAll(NetworkReader reader) internal void DeSerializeObjectsDelta(NetworkReader reader) { - ulong dirty = reader.ReadUInt64(); + ulong dirty = reader.ReadULong(); for (int i = 0; i < syncObjects.Count; i++) { SyncObject syncObject = syncObjects[i]; diff --git a/Assets/Mirror/Runtime/NetworkIdentity.cs b/Assets/Mirror/Runtime/NetworkIdentity.cs index 6e0b98d18..aa08d09e3 100644 --- a/Assets/Mirror/Runtime/NetworkIdentity.cs +++ b/Assets/Mirror/Runtime/NetworkIdentity.cs @@ -903,7 +903,7 @@ internal void OnSerializeAllSafely(bool initialState, NetworkWriter ownerWriter, void OnDeserializeSafely(NetworkBehaviour comp, NetworkReader reader, bool initialState) { // read header as 4 bytes and calculate this chunk's start+end - int contentSize = reader.ReadInt32(); + int contentSize = reader.ReadInt(); int chunkStart = reader.Position; int chunkEnd = reader.Position + contentSize; diff --git a/Assets/Mirror/Runtime/NetworkReader.cs b/Assets/Mirror/Runtime/NetworkReader.cs index d77717f80..061704072 100644 --- a/Assets/Mirror/Runtime/NetworkReader.cs +++ b/Assets/Mirror/Runtime/NetworkReader.cs @@ -111,18 +111,38 @@ public static class NetworkReaderExtensions public static byte ReadByte(this NetworkReader reader) => reader.ReadByte(); public static sbyte ReadSByte(this NetworkReader reader) => (sbyte)reader.ReadByte(); - public static char ReadChar(this NetworkReader reader) => (char)reader.ReadUInt16(); - public static bool ReadBoolean(this NetworkReader reader) => reader.ReadByte() != 0; - public static short ReadInt16(this NetworkReader reader) => (short)reader.ReadUInt16(); - public static ushort ReadUInt16(this NetworkReader reader) + public static char ReadChar(this NetworkReader reader) => (char)reader.ReadUShort(); + + // Deprecated 2021-05-18 + [Obsolete("We've cleaned up the API. Use ReadBool instead.")] + public static bool ReadBoolean(this NetworkReader reader) => reader.ReadBool(); + public static bool ReadBool(this NetworkReader reader) => reader.ReadByte() != 0; + + // Deprecated 2021-05-18 + [Obsolete("We've cleaned up the API. Use ReadShort instead.")] + public static short ReadInt16(this NetworkReader reader) => reader.ReadShort(); + public static short ReadShort(this NetworkReader reader) => (short)reader.ReadUShort(); + + // Deprecated 2021-05-18 + [Obsolete("We've cleaned up the API. Use ReadUShort instead.")] + public static ushort ReadUInt16(this NetworkReader reader) => reader.ReadUShort(); + public static ushort ReadUShort(this NetworkReader reader) { ushort value = 0; value |= reader.ReadByte(); value |= (ushort)(reader.ReadByte() << 8); return value; } - public static int ReadInt32(this NetworkReader reader) => (int)reader.ReadUInt32(); - public static uint ReadUInt32(this NetworkReader reader) + + // Deprecated 2021-05-18 + [Obsolete("We've cleaned up the API. Use ReadInt instead.")] + public static int ReadInt32(this NetworkReader reader) => reader.ReadInt(); + public static int ReadInt(this NetworkReader reader) => (int)reader.ReadUInt(); + + // Deprecated 2021-05-18 + [Obsolete("We've cleaned up the API. Use ReadUInt instead.")] + public static uint ReadUInt32(this NetworkReader reader) => reader.ReadUInt(); + public static uint ReadUInt(this NetworkReader reader) { uint value = 0; value |= reader.ReadByte(); @@ -131,8 +151,16 @@ public static uint ReadUInt32(this NetworkReader reader) value |= (uint)(reader.ReadByte() << 24); return value; } - public static long ReadInt64(this NetworkReader reader) => (long)reader.ReadUInt64(); - public static ulong ReadUInt64(this NetworkReader reader) + + // Deprecated 2021-05-18 + [Obsolete("We've cleaned up the API. Use ReadLong instead.")] + public static long ReadInt64(this NetworkReader reader) => reader.ReadLong(); + public static long ReadLong(this NetworkReader reader) => (long)reader.ReadULong(); + + // Deprecated 2021-05-18 + [Obsolete("We've cleaned up the API. Use ReadULong instead.")] + public static ulong ReadUInt64(this NetworkReader reader) => reader.ReadULong(); + public static ulong ReadULong(this NetworkReader reader) { ulong value = 0; value |= reader.ReadByte(); @@ -145,23 +173,28 @@ public static ulong ReadUInt64(this NetworkReader reader) value |= ((ulong)reader.ReadByte()) << 56; return value; } - public static float ReadSingle(this NetworkReader reader) + + // Deprecated 2021-05-18 + [Obsolete("We've cleaned up the API. Use ReadSingle instead.")] + public static float ReadSingle(this NetworkReader reader) => reader.ReadFloat(); + public static float ReadFloat(this NetworkReader reader) { UIntFloat converter = new UIntFloat(); - converter.intValue = reader.ReadUInt32(); + converter.intValue = reader.ReadUInt(); return converter.floatValue; } + public static double ReadDouble(this NetworkReader reader) { UIntDouble converter = new UIntDouble(); - converter.longValue = reader.ReadUInt64(); + converter.longValue = reader.ReadULong(); return converter.doubleValue; } public static decimal ReadDecimal(this NetworkReader reader) { UIntDecimal converter = new UIntDecimal(); - converter.longValue1 = reader.ReadUInt64(); - converter.longValue2 = reader.ReadUInt64(); + converter.longValue1 = reader.ReadULong(); + converter.longValue2 = reader.ReadULong(); return converter.decimalValue; } @@ -169,7 +202,7 @@ public static decimal ReadDecimal(this NetworkReader reader) public static string ReadString(this NetworkReader reader) { // read number of bytes - ushort size = reader.ReadUInt16(); + ushort size = reader.ReadUShort(); // null support, see NetworkWriter if (size == 0) @@ -194,7 +227,7 @@ public static byte[] ReadBytesAndSize(this NetworkReader reader) { // count = 0 means the array was null // otherwise count -1 is the length of the array - uint count = reader.ReadUInt32(); + uint count = reader.ReadUInt(); // Use checked() to force it to throw OverflowException if data is invalid return count == 0 ? null : reader.ReadBytes(checked((int)(count - 1u))); } @@ -204,42 +237,42 @@ public static ArraySegment ReadBytesAndSizeSegment(this NetworkReader read { // count = 0 means the array was null // otherwise count - 1 is the length of the array - uint count = reader.ReadUInt32(); + uint count = reader.ReadUInt(); // Use checked() to force it to throw OverflowException if data is invalid return count == 0 ? default : reader.ReadBytesSegment(checked((int)(count - 1u))); } - public static Vector2 ReadVector2(this NetworkReader reader) => new Vector2(reader.ReadSingle(), reader.ReadSingle()); - public static Vector3 ReadVector3(this NetworkReader reader) => new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); - public static Vector4 ReadVector4(this NetworkReader reader) => new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); - public static Vector2Int ReadVector2Int(this NetworkReader reader) => new Vector2Int(reader.ReadInt32(), reader.ReadInt32()); - public static Vector3Int ReadVector3Int(this NetworkReader reader) => new Vector3Int(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); - public static Color ReadColor(this NetworkReader reader) => new Color(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); + public static Vector2 ReadVector2(this NetworkReader reader) => new Vector2(reader.ReadFloat(), reader.ReadFloat()); + public static Vector3 ReadVector3(this NetworkReader reader) => new Vector3(reader.ReadFloat(), reader.ReadFloat(), reader.ReadFloat()); + public static Vector4 ReadVector4(this NetworkReader reader) => new Vector4(reader.ReadFloat(), reader.ReadFloat(), reader.ReadFloat(), reader.ReadFloat()); + public static Vector2Int ReadVector2Int(this NetworkReader reader) => new Vector2Int(reader.ReadInt(), reader.ReadInt()); + public static Vector3Int ReadVector3Int(this NetworkReader reader) => new Vector3Int(reader.ReadInt(), reader.ReadInt(), reader.ReadInt()); + public static Color ReadColor(this NetworkReader reader) => new Color(reader.ReadFloat(), reader.ReadFloat(), reader.ReadFloat(), reader.ReadFloat()); public static Color32 ReadColor32(this NetworkReader reader) => new Color32(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), reader.ReadByte()); - public static Quaternion ReadQuaternion(this NetworkReader reader) => new Quaternion(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); - public static Rect ReadRect(this NetworkReader reader) => new Rect(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); - public static Plane ReadPlane(this NetworkReader reader) => new Plane(reader.ReadVector3(), reader.ReadSingle()); + public static Quaternion ReadQuaternion(this NetworkReader reader) => new Quaternion(reader.ReadFloat(), reader.ReadFloat(), reader.ReadFloat(), reader.ReadFloat()); + public static Rect ReadRect(this NetworkReader reader) => new Rect(reader.ReadFloat(), reader.ReadFloat(), reader.ReadFloat(), reader.ReadFloat()); + public static Plane ReadPlane(this NetworkReader reader) => new Plane(reader.ReadVector3(), reader.ReadFloat()); public static Ray ReadRay(this NetworkReader reader) => new Ray(reader.ReadVector3(), reader.ReadVector3()); public static Matrix4x4 ReadMatrix4x4(this NetworkReader reader) { return new Matrix4x4 { - m00 = reader.ReadSingle(), - m01 = reader.ReadSingle(), - m02 = reader.ReadSingle(), - m03 = reader.ReadSingle(), - m10 = reader.ReadSingle(), - m11 = reader.ReadSingle(), - m12 = reader.ReadSingle(), - m13 = reader.ReadSingle(), - m20 = reader.ReadSingle(), - m21 = reader.ReadSingle(), - m22 = reader.ReadSingle(), - m23 = reader.ReadSingle(), - m30 = reader.ReadSingle(), - m31 = reader.ReadSingle(), - m32 = reader.ReadSingle(), - m33 = reader.ReadSingle() + m00 = reader.ReadFloat(), + m01 = reader.ReadFloat(), + m02 = reader.ReadFloat(), + m03 = reader.ReadFloat(), + m10 = reader.ReadFloat(), + m11 = reader.ReadFloat(), + m12 = reader.ReadFloat(), + m13 = reader.ReadFloat(), + m20 = reader.ReadFloat(), + m21 = reader.ReadFloat(), + m22 = reader.ReadFloat(), + m23 = reader.ReadFloat(), + m30 = reader.ReadFloat(), + m31 = reader.ReadFloat(), + m32 = reader.ReadFloat(), + m33 = reader.ReadFloat() }; } public static byte[] ReadBytes(this NetworkReader reader, int count) @@ -266,7 +299,7 @@ public static GameObject ReadGameObject(this NetworkReader reader) public static NetworkIdentity ReadNetworkIdentity(this NetworkReader reader) { - uint netId = reader.ReadUInt32(); + uint netId = reader.ReadUInt(); if (netId == 0) return null; @@ -284,7 +317,7 @@ public static NetworkIdentity ReadNetworkIdentity(this NetworkReader reader) public static NetworkBehaviour ReadNetworkBehaviour(this NetworkReader reader) { - uint netId = reader.ReadUInt32(); + uint netId = reader.ReadUInt(); if (netId == 0) return null; @@ -310,7 +343,7 @@ public static T ReadNetworkBehaviour(this NetworkReader reader) where T : Net public static NetworkBehaviour.NetworkBehaviourSyncVar ReadNetworkBehaviourSyncVar(this NetworkReader reader) { - uint netId = reader.ReadUInt32(); + uint netId = reader.ReadUInt(); byte componentIndex = default; // if netId is not 0, then index is also sent to read before returning @@ -324,7 +357,7 @@ public static NetworkBehaviour.NetworkBehaviourSyncVar ReadNetworkBehaviourSyncV public static List ReadList(this NetworkReader reader) { - int length = reader.ReadInt32(); + int length = reader.ReadInt(); if (length < 0) return null; List result = new List(length); @@ -337,7 +370,7 @@ public static List ReadList(this NetworkReader reader) public static T[] ReadArray(this NetworkReader reader) { - int length = reader.ReadInt32(); + int length = reader.ReadInt(); // we write -1 for null if (length < 0) diff --git a/Assets/Mirror/Runtime/SyncDictionary.cs b/Assets/Mirror/Runtime/SyncDictionary.cs index 14ff268ec..f3a0b5abd 100644 --- a/Assets/Mirror/Runtime/SyncDictionary.cs +++ b/Assets/Mirror/Runtime/SyncDictionary.cs @@ -130,7 +130,7 @@ public void OnDeserializeAll(NetworkReader reader) IsReadOnly = true; // if init, write the full list content - int count = (int)reader.ReadUInt32(); + int count = (int)reader.ReadUInt(); objects.Clear(); changes.Clear(); @@ -145,7 +145,7 @@ public void OnDeserializeAll(NetworkReader reader) // We will need to skip all these changes // the next time the list is synchronized // because they have already been applied - changesAhead = (int)reader.ReadUInt32(); + changesAhead = (int)reader.ReadUInt(); } public void OnDeserializeDelta(NetworkReader reader) @@ -153,7 +153,7 @@ public void OnDeserializeDelta(NetworkReader reader) // This list can now only be modified by synchronization IsReadOnly = true; - int changesCount = (int)reader.ReadUInt32(); + int changesCount = (int)reader.ReadUInt(); for (int i = 0; i < changesCount; i++) { diff --git a/Assets/Mirror/Runtime/SyncList.cs b/Assets/Mirror/Runtime/SyncList.cs index 4c6f679a6..deba7ebb4 100644 --- a/Assets/Mirror/Runtime/SyncList.cs +++ b/Assets/Mirror/Runtime/SyncList.cs @@ -161,7 +161,7 @@ public void OnDeserializeAll(NetworkReader reader) IsReadOnly = true; // if init, write the full list content - int count = (int)reader.ReadUInt32(); + int count = (int)reader.ReadUInt(); objects.Clear(); changes.Clear(); @@ -175,7 +175,7 @@ public void OnDeserializeAll(NetworkReader reader) // We will need to skip all these changes // the next time the list is synchronized // because they have already been applied - changesAhead = (int)reader.ReadUInt32(); + changesAhead = (int)reader.ReadUInt(); } public void OnDeserializeDelta(NetworkReader reader) @@ -183,7 +183,7 @@ public void OnDeserializeDelta(NetworkReader reader) // This list can now only be modified by synchronization IsReadOnly = true; - int changesCount = (int)reader.ReadUInt32(); + int changesCount = (int)reader.ReadUInt(); for (int i = 0; i < changesCount; i++) { @@ -215,7 +215,7 @@ public void OnDeserializeDelta(NetworkReader reader) break; case Operation.OP_INSERT: - index = (int)reader.ReadUInt32(); + index = (int)reader.ReadUInt(); newItem = reader.Read(); if (apply) { @@ -224,7 +224,7 @@ public void OnDeserializeDelta(NetworkReader reader) break; case Operation.OP_REMOVEAT: - index = (int)reader.ReadUInt32(); + index = (int)reader.ReadUInt(); if (apply) { oldItem = objects[index]; @@ -233,7 +233,7 @@ public void OnDeserializeDelta(NetworkReader reader) break; case Operation.OP_SET: - index = (int)reader.ReadUInt32(); + index = (int)reader.ReadUInt(); newItem = reader.Read(); if (apply) { diff --git a/Assets/Mirror/Runtime/SyncSet.cs b/Assets/Mirror/Runtime/SyncSet.cs index 0c98d065d..29dc2ed4c 100644 --- a/Assets/Mirror/Runtime/SyncSet.cs +++ b/Assets/Mirror/Runtime/SyncSet.cs @@ -122,7 +122,7 @@ public void OnDeserializeAll(NetworkReader reader) IsReadOnly = true; // if init, write the full list content - int count = (int)reader.ReadUInt32(); + int count = (int)reader.ReadUInt(); objects.Clear(); changes.Clear(); @@ -136,7 +136,7 @@ public void OnDeserializeAll(NetworkReader reader) // We will need to skip all these changes // the next time the list is synchronized // because they have already been applied - changesAhead = (int)reader.ReadUInt32(); + changesAhead = (int)reader.ReadUInt(); } public void OnDeserializeDelta(NetworkReader reader) @@ -144,7 +144,7 @@ public void OnDeserializeDelta(NetworkReader reader) // This list can now only be modified by synchronization IsReadOnly = true; - int changesCount = (int)reader.ReadUInt32(); + int changesCount = (int)reader.ReadUInt(); for (int i = 0; i < changesCount; i++) { diff --git a/Assets/Mirror/Tests/Editor/ClientSceneTests_OnSpawn.cs b/Assets/Mirror/Tests/Editor/ClientSceneTests_OnSpawn.cs index 5cb85da0d..01130589c 100644 --- a/Assets/Mirror/Tests/Editor/ClientSceneTests_OnSpawn.cs +++ b/Assets/Mirror/Tests/Editor/ClientSceneTests_OnSpawn.cs @@ -29,7 +29,7 @@ public override void OnDeserialize(NetworkReader reader, bool initialState) { base.OnDeserialize(reader, initialState); - value = reader.ReadInt32(); + value = reader.ReadInt(); direction = reader.ReadVector3(); OnDeserializeCalled?.Invoke(); diff --git a/Assets/Mirror/Tests/Editor/CustomRWTest.cs b/Assets/Mirror/Tests/Editor/CustomRWTest.cs index 972b2d3e0..971ec578f 100644 --- a/Assets/Mirror/Tests/Editor/CustomRWTest.cs +++ b/Assets/Mirror/Tests/Editor/CustomRWTest.cs @@ -25,7 +25,7 @@ public static void WriteQuest(this NetworkWriter writer, MockQuest quest) } public static MockQuest WriteQuest(this NetworkReader reader) { - return new MockQuest(reader.ReadInt32()); + return new MockQuest(reader.ReadInt()); } } diff --git a/Assets/Mirror/Tests/Editor/EnumReadWriteTests.cs b/Assets/Mirror/Tests/Editor/EnumReadWriteTests.cs index 1b75b2ee5..a37e18245 100644 --- a/Assets/Mirror/Tests/Editor/EnumReadWriteTests.cs +++ b/Assets/Mirror/Tests/Editor/EnumReadWriteTests.cs @@ -18,7 +18,7 @@ public static void WriteMyCustomEnum(this NetworkWriter networkWriter, EnumReadW } public static EnumReadWriteTests.MyCustomEnum ReadMyCustomEnum(this NetworkReader networkReader) { - return (EnumReadWriteTests.MyCustomEnum)networkReader.ReadInt32(); + return (EnumReadWriteTests.MyCustomEnum)networkReader.ReadInt(); } } public class EnumReadWriteTests diff --git a/Assets/Mirror/Tests/Editor/MessagePackingTest.cs b/Assets/Mirror/Tests/Editor/MessagePackingTest.cs index d555b242e..e1b27c9fc 100644 --- a/Assets/Mirror/Tests/Editor/MessagePackingTest.cs +++ b/Assets/Mirror/Tests/Editor/MessagePackingTest.cs @@ -26,7 +26,7 @@ public static T UnpackFromByteArray(byte[] data) { int msgType = MessagePacking.GetId(); - int id = networkReader.ReadUInt16(); + int id = networkReader.ReadUShort(); if (id != msgType) throw new FormatException("Invalid message, could not unpack " + typeof(T).FullName); diff --git a/Assets/Mirror/Tests/Editor/NetworkBehaviourSerializeTest.cs b/Assets/Mirror/Tests/Editor/NetworkBehaviourSerializeTest.cs index 8f651f338..019c3cbac 100644 --- a/Assets/Mirror/Tests/Editor/NetworkBehaviourSerializeTest.cs +++ b/Assets/Mirror/Tests/Editor/NetworkBehaviourSerializeTest.cs @@ -83,7 +83,7 @@ public override bool OnSerialize(NetworkWriter writer, bool initialState) } public override void OnDeserialize(NetworkReader reader, bool initialState) { - customSerializeField = reader.ReadSingle(); + customSerializeField = reader.ReadFloat(); base.OnDeserialize(reader, initialState); } } @@ -99,7 +99,7 @@ public override bool OnSerialize(NetworkWriter writer, bool initialState) } public override void OnDeserialize(NetworkReader reader, bool initialState) { - customSerializeField = reader.ReadSingle(); + customSerializeField = reader.ReadFloat(); base.OnDeserialize(reader, initialState); } } @@ -120,7 +120,7 @@ public override bool OnSerialize(NetworkWriter writer, bool initialState) } public override void OnDeserialize(NetworkReader reader, bool initialState) { - customSerializeField = reader.ReadSingle(); + customSerializeField = reader.ReadFloat(); base.OnDeserialize(reader, initialState); } } diff --git a/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs b/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs index bdd843327..571f9ff1f 100644 --- a/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs +++ b/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs @@ -131,7 +131,7 @@ public override bool OnSerialize(NetworkWriter writer, bool initialState) } public override void OnDeserialize(NetworkReader reader, bool initialState) { - value = reader.ReadInt32(); + value = reader.ReadInt(); } } @@ -173,7 +173,7 @@ public override bool OnSerialize(NetworkWriter writer, bool initialState) } public override void OnDeserialize(NetworkReader reader, bool initialState) { - value = reader.ReadInt32(); + value = reader.ReadInt(); } } diff --git a/Assets/Mirror/Tests/Editor/NetworkMessageTests.cs b/Assets/Mirror/Tests/Editor/NetworkMessageTests.cs index 7da0f1177..50e6cea19 100644 --- a/Assets/Mirror/Tests/Editor/NetworkMessageTests.cs +++ b/Assets/Mirror/Tests/Editor/NetworkMessageTests.cs @@ -17,7 +17,7 @@ public TestMessage(int i, string s, double d) public void Deserialize(NetworkReader reader) { - IntValue = reader.ReadInt32(); + IntValue = reader.ReadInt(); StringValue = reader.ReadString(); DoubleValue = reader.ReadDouble(); } diff --git a/Assets/Mirror/Tests/Editor/NetworkServerTest.cs b/Assets/Mirror/Tests/Editor/NetworkServerTest.cs index 4d55af389..30128737d 100644 --- a/Assets/Mirror/Tests/Editor/NetworkServerTest.cs +++ b/Assets/Mirror/Tests/Editor/NetworkServerTest.cs @@ -23,7 +23,7 @@ public TestMessage1(int i, string s, double d) public void Deserialize(NetworkReader reader) { - IntValue = reader.ReadInt32(); + IntValue = reader.ReadInt(); StringValue = reader.ReadString(); DoubleValue = reader.ReadDouble(); } diff --git a/Assets/Mirror/Tests/Editor/NetworkTransformTest.cs b/Assets/Mirror/Tests/Editor/NetworkTransformTest.cs index 00752fdc3..158bf0b96 100644 --- a/Assets/Mirror/Tests/Editor/NetworkTransformTest.cs +++ b/Assets/Mirror/Tests/Editor/NetworkTransformTest.cs @@ -17,7 +17,7 @@ public void SerializeIntoWriterTest() NetworkTransformBase.SerializeIntoWriter(writer, position, rotation, scale, true, true); NetworkReader reader = new NetworkReader(writer.ToArray()); Assert.That(reader.ReadVector3(), Is.EqualTo(position)); - Assert.That(reader.ReadUInt32(), Is.EqualTo(Compression.CompressQuaternion(rotation))); + Assert.That(reader.ReadUInt(), Is.EqualTo(Compression.CompressQuaternion(rotation))); Assert.That(reader.ReadVector3(), Is.EqualTo(scale)); } } diff --git a/Assets/Mirror/Tests/Editor/NetworkWriterCollectionTest.cs b/Assets/Mirror/Tests/Editor/NetworkWriterCollectionTest.cs index 86393154a..93d6ce211 100644 --- a/Assets/Mirror/Tests/Editor/NetworkWriterCollectionTest.cs +++ b/Assets/Mirror/Tests/Editor/NetworkWriterCollectionTest.cs @@ -20,7 +20,7 @@ public void HasReadFunctionForInt() { Assert.That(Reader.read, Is.Not.Null, "int read function was not found"); - Func action = NetworkReaderExtensions.ReadInt32; + Func action = NetworkReaderExtensions.ReadInt; Assert.That(Reader.read, Is.EqualTo(action), "int read function was incorrect value"); } diff --git a/Assets/Mirror/Tests/Editor/NetworkWriterTest.cs b/Assets/Mirror/Tests/Editor/NetworkWriterTest.cs index 8ab734650..379d11db5 100644 --- a/Assets/Mirror/Tests/Editor/NetworkWriterTest.cs +++ b/Assets/Mirror/Tests/Editor/NetworkWriterTest.cs @@ -157,15 +157,15 @@ void EnsureThrows(Action read, byte[] data = null) EnsureThrows(r => r.ReadByte()); EnsureThrows(r => r.ReadSByte()); EnsureThrows(r => r.ReadChar()); - EnsureThrows(r => r.ReadBoolean()); - EnsureThrows(r => r.ReadInt16()); - EnsureThrows(r => r.ReadUInt16()); - EnsureThrows(r => r.ReadInt32()); - EnsureThrows(r => r.ReadUInt32()); - EnsureThrows(r => r.ReadInt64()); - EnsureThrows(r => r.ReadUInt64()); + EnsureThrows(r => r.ReadBool()); + EnsureThrows(r => r.ReadShort()); + EnsureThrows(r => r.ReadUShort()); + EnsureThrows(r => r.ReadInt()); + EnsureThrows(r => r.ReadUInt()); + EnsureThrows(r => r.ReadLong()); + EnsureThrows(r => r.ReadULong()); EnsureThrows(r => r.ReadDecimal()); - EnsureThrows(r => r.ReadSingle()); + EnsureThrows(r => r.ReadFloat()); EnsureThrows(r => r.ReadDouble()); EnsureThrows(r => r.ReadString()); EnsureThrows(r => r.ReadBytes(1)); @@ -618,7 +618,7 @@ public void TestFloats() NetworkWriter writer = new NetworkWriter(); writer.WriteFloat(weird); NetworkReader reader = new NetworkReader(writer.ToArray()); - float readFloat = reader.ReadSingle(); + float readFloat = reader.ReadFloat(); Assert.That(readFloat, Is.EqualTo(weird)); } } @@ -877,14 +877,14 @@ public void TestWritingAndReading() Assert.That(reader.ReadChar(), Is.EqualTo(1)); Assert.That(reader.ReadByte(), Is.EqualTo(2)); Assert.That(reader.ReadSByte(), Is.EqualTo(3)); - Assert.That(reader.ReadBoolean(), Is.True); - Assert.That(reader.ReadInt16(), Is.EqualTo(4)); - Assert.That(reader.ReadUInt16(), Is.EqualTo(5)); - Assert.That(reader.ReadInt32(), Is.EqualTo(6)); - Assert.That(reader.ReadUInt32(), Is.EqualTo(7)); - Assert.That(reader.ReadInt64(), Is.EqualTo(8)); - Assert.That(reader.ReadUInt64(), Is.EqualTo(9)); - Assert.That(reader.ReadSingle(), Is.EqualTo(10)); + Assert.That(reader.ReadBool(), Is.True); + Assert.That(reader.ReadShort(), Is.EqualTo(4)); + Assert.That(reader.ReadUShort(), Is.EqualTo(5)); + Assert.That(reader.ReadInt(), Is.EqualTo(6)); + Assert.That(reader.ReadUInt(), Is.EqualTo(7)); + Assert.That(reader.ReadLong(), Is.EqualTo(8)); + Assert.That(reader.ReadULong(), Is.EqualTo(9)); + Assert.That(reader.ReadFloat(), Is.EqualTo(10)); Assert.That(reader.ReadDouble(), Is.EqualTo(11)); Assert.That(reader.ReadDecimal(), Is.EqualTo(12)); // writing null string should write null in Mirror ("" in original HLAPI) diff --git a/Assets/Mirror/Tests/Editor/SyncListTest.cs b/Assets/Mirror/Tests/Editor/SyncListTest.cs index f1b995d94..d51fdffab 100644 --- a/Assets/Mirror/Tests/Editor/SyncListTest.cs +++ b/Assets/Mirror/Tests/Editor/SyncListTest.cs @@ -399,7 +399,7 @@ public static uint GetChangeCount(this SyncObject syncObject) using (PooledNetworkReader reader = NetworkReaderPool.GetReader(writer.ToArraySegment())) { - return reader.ReadUInt32(); + return reader.ReadUInt(); } } } diff --git a/Assets/Mirror/Tests/Editor/Weaver/ExtraAssembly/SomeDataWithWriter.cs b/Assets/Mirror/Tests/Editor/Weaver/ExtraAssembly/SomeDataWithWriter.cs index 31730be73..d229527a8 100644 --- a/Assets/Mirror/Tests/Editor/Weaver/ExtraAssembly/SomeDataWithWriter.cs +++ b/Assets/Mirror/Tests/Editor/Weaver/ExtraAssembly/SomeDataWithWriter.cs @@ -13,7 +13,7 @@ public static void WriteSomeData(this NetworkWriter writer, SomeDataWithWriter i } public static SomeDataWithWriter ReadSomeData(this NetworkReader reader) { - return new SomeDataWithWriter { usefulNumber = reader.ReadInt32() }; + return new SomeDataWithWriter { usefulNumber = reader.ReadInt() }; } } }