From 84b040766f6c21f9bf28a84fb079ebf337716c84 Mon Sep 17 00:00:00 2001 From: sardelka9515 Date: Sat, 27 Aug 2022 14:23:28 +0800 Subject: [PATCH] Simplify GetBytesFromObject --- RageCoop.Client/Main.cs | 2 +- RageCoop.Client/Properties/AssemblyInfo.cs | 4 +- RageCoop.Core/CoreUtils.cs | 58 +++++++++++----------- RageCoop.Server/Properties/AssemblyInfo.cs | 4 +- 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/RageCoop.Client/Main.cs b/RageCoop.Client/Main.cs index d5a341b..93994a3 100644 --- a/RageCoop.Client/Main.cs +++ b/RageCoop.Client/Main.cs @@ -46,7 +46,7 @@ namespace RageCoop.Client /// Don't use it! /// public Main() - {Game.Player.Character.Task.LeaveVehicle() + { Worker = new Worker("RageCoop.Client.Main.Worker", Logger); try { diff --git a/RageCoop.Client/Properties/AssemblyInfo.cs b/RageCoop.Client/Properties/AssemblyInfo.cs index bf30eff..f98ba17 100644 --- a/RageCoop.Client/Properties/AssemblyInfo.cs +++ b/RageCoop.Client/Properties/AssemblyInfo.cs @@ -16,7 +16,7 @@ using System.Resources; // Version informationr( -[assembly: AssemblyVersion("1.5.3.146")] -[assembly: AssemblyFileVersion("1.5.3.146")] +[assembly: AssemblyVersion("1.5.3.147")] +[assembly: AssemblyFileVersion("1.5.3.147")] [assembly: NeutralResourcesLanguageAttribute( "en-US" )] diff --git a/RageCoop.Core/CoreUtils.cs b/RageCoop.Core/CoreUtils.cs index 26ac8cf..65261d1 100644 --- a/RageCoop.Core/CoreUtils.cs +++ b/RageCoop.Core/CoreUtils.cs @@ -38,34 +38,36 @@ namespace RageCoop.Core { switch (obj) { - case byte _: - return (0x01, new byte[] { (byte)obj }); - case short _: - return (0x02, BitConverter.GetBytes((short)obj)); - case ushort _: - return (0x03, BitConverter.GetBytes((ushort)obj)); - case int _: - return (0x04, BitConverter.GetBytes((int)obj)); - case uint _: - return (0x05, BitConverter.GetBytes((uint)obj)); - case long _: - return (0x06, BitConverter.GetBytes((long)obj)); - case ulong _: - return (0x07, BitConverter.GetBytes((ulong)obj)); - case float _: - return (0x08, BitConverter.GetBytes((float)obj)); - case bool _: - return (0x09, BitConverter.GetBytes((bool)obj)); - case string _: - return (0x10, ((string)obj).GetBytesWithLength()); - case Vector3 _: - return (0x11,((Vector3)obj).GetBytes()); - case Quaternion _: - return (0x12, ((Quaternion)obj).GetBytes()); - case GTA.Model _: - return (0x13, BitConverter.GetBytes((GTA.Model)obj)); - case Vector2 _: - return (0x14, ((Vector2)obj).GetBytes()); + case byte value: + return (0x01, new byte[] { value }); + case short value: + return (0x02, BitConverter.GetBytes(value)); + case ushort value: + return (0x03, BitConverter.GetBytes(value)); + case int value: + return (0x04, BitConverter.GetBytes(value)); + case uint value: + return (0x05, BitConverter.GetBytes(value)); + case long value: + return (0x06, BitConverter.GetBytes(value)); + case ulong value: + return (0x07, BitConverter.GetBytes(value)); + case float value: + return (0x08, BitConverter.GetBytes(value)); + case bool value: + return (0x09, BitConverter.GetBytes(value)); + case string value: + return (0x10, value.GetBytesWithLength()); + case Vector3 value: + return (0x11, value.GetBytes()); + case Quaternion value: + return (0x12, value.GetBytes()); + case GTA.Model value: + return (0x13, BitConverter.GetBytes(value)); + case Vector2 value: + return (0x14, value.GetBytes()); + case byte[] value: + return (0x15, value); case Tuple _: var tup = (Tuple)obj; return (tup.Item1, tup.Item2); diff --git a/RageCoop.Server/Properties/AssemblyInfo.cs b/RageCoop.Server/Properties/AssemblyInfo.cs index 3a18850..024670b 100644 --- a/RageCoop.Server/Properties/AssemblyInfo.cs +++ b/RageCoop.Server/Properties/AssemblyInfo.cs @@ -15,7 +15,7 @@ using System.Resources; [assembly: AssemblyCulture("")] // Version information -[assembly: AssemblyVersion("1.5.3.126")] -[assembly: AssemblyFileVersion("1.5.3.126")] +[assembly: AssemblyVersion("1.5.3.128")] +[assembly: AssemblyFileVersion("1.5.3.128")] [assembly: NeutralResourcesLanguageAttribute( "en-US" )]