From f9a0e240f35e7d37b69f1a6a22258889b06f842b Mon Sep 17 00:00:00 2001 From: miner28_3 Date: Sun, 1 Dec 2024 21:46:18 +0100 Subject: [PATCH] Fix Unsigned longs --- .../Runtime/DataListSerializer.cs | 310 +++++++++--------- .../Runtime/NetworkedEventCallerReceiver.cs | 50 ++- .../package.json | 2 +- 3 files changed, 179 insertions(+), 183 deletions(-) diff --git a/Packages/com.miner28.networkedeventcaller/Runtime/DataListSerializer.cs b/Packages/com.miner28.networkedeventcaller/Runtime/DataListSerializer.cs index 9312032..675e45d 100644 --- a/Packages/com.miner28.networkedeventcaller/Runtime/DataListSerializer.cs +++ b/Packages/com.miner28.networkedeventcaller/Runtime/DataListSerializer.cs @@ -42,33 +42,33 @@ public static void AddVariableInt(this DataList list, uint value) { if (value < 0x80) { - list.Add((byte) value); + list.Add((byte)value); } else if (value < 0x4000) { - list.Add((byte) ((value >> Bit8) | _0x80)); - list.Add((byte) (value & 0xFF)); + list.Add((byte)((value >> Bit8) | _0x80)); + list.Add((byte)(value & 0xFF)); } else if (value < 0x200000) { - list.Add((byte) ((value >> Bit16) | _0xC0)); - list.Add((byte) ((value >> Bit8) & 0xFF)); - list.Add((byte) (value & 0xFF)); + list.Add((byte)((value >> Bit16) | _0xC0)); + list.Add((byte)((value >> Bit8) & 0xFF)); + list.Add((byte)(value & 0xFF)); } else if (value < 0x10000000) { - list.Add((byte) ((value >> Bit24) | _0xE0)); - list.Add((byte) ((value >> Bit16) & 0xFF)); - list.Add((byte) ((value >> Bit8) & 0xFF)); - list.Add((byte) (value & 0xFF)); + list.Add((byte)((value >> Bit24) | _0xE0)); + list.Add((byte)((value >> Bit16) & 0xFF)); + list.Add((byte)((value >> Bit8) & 0xFF)); + list.Add((byte)(value & 0xFF)); } else { - list.Add((byte) 0xF0); - list.Add((byte) ((value >> Bit24) & 0xFF)); - list.Add((byte) ((value >> Bit16) & 0xFF)); - list.Add((byte) ((value >> Bit8) & 0xFF)); - list.Add((byte) (value & 0xFF)); + list.Add((byte)0xF0); + list.Add((byte)((value >> Bit24) & 0xFF)); + list.Add((byte)((value >> Bit16) & 0xFF)); + list.Add((byte)((value >> Bit8) & 0xFF)); + list.Add((byte)(value & 0xFF)); } } @@ -76,137 +76,138 @@ public static void AddVariableInt(this DataList list, ushort value) { if (value < 0x80) { - list.Add((byte) value); + list.Add((byte)value); } else if (value < 0x4000) { - list.Add((byte) ((value >> Bit8) | _0x80)); - list.Add((byte) (value & 0xFF)); + list.Add((byte)((value >> Bit8) | _0x80)); + list.Add((byte)(value & 0xFF)); } else { // Handle values greater than or equal to 0x4000 using your existing method - list.Add((byte) ((value >> Bit16) | _0xC0)); - list.Add((byte) ((value >> Bit8) & 0xFF)); - list.Add((byte) (value & 0xFF)); + list.Add((byte)((value >> Bit16) | _0xC0)); + list.Add((byte)((value >> Bit8) & 0xFF)); + list.Add((byte)(value & 0xFF)); } } public static void AddVariableInt(this DataList list, ulong value) { - if (value < 0x80) + if (value < 0x80) // Single byte (7-bit value) { - list.Add((byte) value); + list.Add((byte)value); } - else if (value < 0x4000) + else if (value < 0x4000) // Two bytes (14-bit value) { - list.Add((byte) ((value >> Bit8) | _0x80)); - list.Add((byte) (value & 0xFF)); + list.Add((byte)((value >> 8) | 0x80)); + list.Add((byte)(value & 0xFF)); } - else if (value < 0x200000) + else if (value < 0x200000) // Three bytes (21-bit value) { - list.Add((byte) ((value >> Bit16) | _0xC0)); - list.Add((byte) ((value >> Bit8) & 0xFF)); - list.Add((byte) (value & 0xFF)); + list.Add((byte)((value >> 16) | 0xC0)); + list.Add((byte)((value >> 8) & 0xFF)); + list.Add((byte)(value & 0xFF)); } - else if (value < 0x10000000) + else if (value < 0x10000000) // Four bytes (28-bit value) { - list.Add((byte) ((value >> Bit24) | _0xE0)); - list.Add((byte) ((value >> Bit16) & 0xFF)); - list.Add((byte) ((value >> Bit8) & 0xFF)); - list.Add((byte) (value & 0xFF)); - } - else if (value < 0x800000000) - { - list.Add((byte) 0xF0); - list.Add((byte) ((value >> Bit24) & 0xFF)); - list.Add((byte) ((value >> Bit16) & 0xFF)); - list.Add((byte) ((value >> Bit8) & 0xFF)); - list.Add((byte) (value & 0xFF)); - } - else if (value < 0x40000000000) - { - list.Add((byte) 0xF8); - list.Add((byte) ((value >> Bit32) & 0xFF)); - list.Add((byte) ((value >> Bit24) & 0xFF)); - list.Add((byte) ((value >> Bit16) & 0xFF)); - list.Add((byte) ((value >> Bit8) & 0xFF)); - list.Add((byte) (value & 0xFF)); - } - else if (value < 0x2000000000000) - { - list.Add((byte) 0xFC); - list.Add((byte) ((value >> Bit40) & 0xFF)); - list.Add((byte) ((value >> Bit32) & 0xFF)); - list.Add((byte) ((value >> Bit24) & 0xFF)); - list.Add((byte) ((value >> Bit16) & 0xFF)); - list.Add((byte) ((value >> Bit8) & 0xFF)); - list.Add((byte) (value & 0xFF)); - } - else if (value < 0x100000000000000) - { - list.Add((byte) 0xFE); - list.Add((byte) ((value >> Bit48) & 0xFF)); - list.Add((byte) ((value >> Bit40) & 0xFF)); - list.Add((byte) ((value >> Bit32) & 0xFF)); - list.Add((byte) ((value >> Bit24) & 0xFF)); - list.Add((byte) ((value >> Bit16) & 0xFF)); - list.Add((byte) ((value >> Bit8) & 0xFF)); - list.Add((byte) (value & 0xFF)); - } - else if (value < 0x8000000000000000) - { - list.Add((byte) 0xFF); - list.Add((byte) ((value >> Bit56) & 0xFF)); - list.Add((byte) ((value >> Bit48) & 0xFF)); - list.Add((byte) ((value >> Bit40) & 0xFF)); - list.Add((byte) ((value >> Bit32) & 0xFF)); - list.Add((byte) ((value >> Bit24) & 0xFF)); - list.Add((byte) ((value >> Bit16) & 0xFF)); - list.Add((byte) ((value >> Bit8) & 0xFF)); - list.Add((byte) (value & 0xFF)); + list.Add((byte)((value >> 24) | 0xE0)); + list.Add((byte)((value >> 16) & 0xFF)); + list.Add((byte)((value >> 8) & 0xFF)); + list.Add((byte)(value & 0xFF)); + } + else if (value < 0x800000000) // Five bytes (35-bit value) + { + list.Add((byte)((value >> 32) | 0xF0)); + list.Add((byte)((value >> 24) & 0xFF)); + list.Add((byte)((value >> 16) & 0xFF)); + list.Add((byte)((value >> 8) & 0xFF)); + list.Add((byte)(value & 0xFF)); + } + else if (value < 0x40000000000) // Six bytes (42-bit value) + { + list.Add((byte)((value >> 40) | 0xF8)); + list.Add((byte)((value >> 32) & 0xFF)); + list.Add((byte)((value >> 24) & 0xFF)); + list.Add((byte)((value >> 16) & 0xFF)); + list.Add((byte)((value >> 8) & 0xFF)); + list.Add((byte)(value & 0xFF)); + } + else if (value < 0x2000000000000) // Seven bytes (49-bit value) + { + list.Add((byte)((value >> 48) | 0xFC)); + list.Add((byte)((value >> 40) & 0xFF)); + list.Add((byte)((value >> 32) & 0xFF)); + list.Add((byte)((value >> 24) & 0xFF)); + list.Add((byte)((value >> 16) & 0xFF)); + list.Add((byte)((value >> 8) & 0xFF)); + list.Add((byte)(value & 0xFF)); + } + else if (value < 0x100000000000000) // Eight bytes (56-bit value) + { + list.Add(0xFE); + list.Add((byte)((value >> 48) & 0xFF)); + list.Add((byte)((value >> 40) & 0xFF)); + list.Add((byte)((value >> 32) & 0xFF)); + list.Add((byte)((value >> 24) & 0xFF)); + list.Add((byte)((value >> 16) & 0xFF)); + list.Add((byte)((value >> 8) & 0xFF)); + list.Add((byte)(value & 0xFF)); + } + else // Nine bytes (64-bit value) + { + list.Add(0xFF); + list.Add((byte)((value >> 56) & 0xFF)); + list.Add((byte)((value >> 48) & 0xFF)); + list.Add((byte)((value >> 40) & 0xFF)); + list.Add((byte)((value >> 32) & 0xFF)); + list.Add((byte)((value >> 24) & 0xFF)); + list.Add((byte)((value >> 16) & 0xFF)); + list.Add((byte)((value >> 8) & 0xFF)); + list.Add((byte)(value & 0xFF)); } } + public static void AddVariableInt(this DataList list, int value) { // Apply ZigZag encoding to convert the signed int to an unsigned int - uint uValue = (uint) ((value << 1) ^ (value >> 31)); + uint uValue = (uint)((value << 1) ^ (value >> 31)); while (uValue >= 0x80) { - list.Add((byte) ((uValue & 0x7F) | 0x80)); + list.Add((byte)((uValue & 0x7F) | 0x80)); uValue >>= 7; } - list.Add((byte) uValue); + list.Add((byte)uValue); } public static int AddVariableInt(this DataList list, short value) { - ushort uValue = (ushort) ((value << 1) ^ (value >> 15)); + ushort uValue = (ushort)((value << 1) ^ (value >> 15)); while (uValue >= 0x80) { - list.Add((byte) ((uValue & 0x7F) | 0x80)); + list.Add((byte)((uValue & 0x7F) | 0x80)); uValue >>= 7; } - list.Add((byte) uValue); + list.Add((byte)uValue); return list.Count; } public static int AddVariableInt(this DataList list, long value) { - ulong uValue = (ulong) ((value << 1) ^ (value >> 63)); + ulong uValue = (ulong)((value << 1) ^ (value >> 63)); while (uValue >= 0x80) { - list.Add((byte) ((uValue & 0x7F) | 0x80)); + list.Add((byte)((uValue & 0x7F) | 0x80)); uValue >>= 7; } - list.Add((byte) uValue); + list.Add((byte)uValue); return list.Count; } @@ -263,25 +264,25 @@ public static void AddBytes(this DataList list, float value) } //return WriteUInt32(tmp); - list.Add((byte) ((tmp >> Bit24) & 255u)); - list.Add((byte) ((tmp >> Bit16) & 255u)); - list.Add((byte) ((tmp >> Bit8) & 255u)); - list.Add((byte) (tmp & 255u)); + list.Add((byte)((tmp >> Bit24) & 255u)); + list.Add((byte)((tmp >> Bit16) & 255u)); + list.Add((byte)((tmp >> Bit8) & 255u)); + list.Add((byte)(tmp & 255u)); } public static float ReadFloat(this byte[] array, int startIndex) { - var _uint32Value = ((uint) array[startIndex] << Bit24) | - ((uint) array[startIndex + 1] << Bit16) | - ((uint) array[startIndex + 2] << Bit8) | array[startIndex + 3]; + var _uint32Value = ((uint)array[startIndex] << Bit24) | + ((uint)array[startIndex + 1] << Bit16) | + ((uint)array[startIndex + 2] << Bit8) | array[startIndex + 3]; if (_uint32Value == 0 || _uint32Value == FloatSignBit) { return 0f; } - var _exp = (int) ((_uint32Value & FloatExpMask) >> 23); - var _doubleFracMask = (int) (_uint32Value & FloatFracMask); + var _exp = (int)((_uint32Value & FloatExpMask) >> 23); + var _doubleFracMask = (int)(_uint32Value & FloatFracMask); if (_exp == 0xFF) { if (_doubleFracMask == 0) @@ -311,15 +312,15 @@ public static float ReadFloat(this byte[] array, int startIndex) public static double ReadDouble(this byte[] array, int startIndex) { - ulong value = ((ulong) array[0] << Bit56) | ((ulong) array[1] << Bit48) | - ((ulong) array[2] << Bit40) | ((ulong) array[3] << Bit32) | - ((ulong) array[4] << Bit24) | ((ulong) array[5] << Bit16) | - ((ulong) array[6] << Bit8) | array[7]; + ulong value = ((ulong)array[0] << Bit56) | ((ulong)array[1] << Bit48) | + ((ulong)array[2] << Bit40) | ((ulong)array[3] << Bit32) | + ((ulong)array[4] << Bit24) | ((ulong)array[5] << Bit16) | + ((ulong)array[6] << Bit8) | array[7]; if (value == 0.0 || value == DoubleSignBit) return 0.0; - long exp = (long) ((value & DoubleExpMask) >> 52); - long frac = (long) (value & DoubleFracMask); + long exp = (long)((value & DoubleExpMask) >> 52); + long frac = (long)(value & DoubleFracMask); bool negate = (value & DoubleSignBit) == DoubleSignBit; if (exp == 0x7FF) @@ -332,7 +333,7 @@ public static double ReadDouble(this byte[] array, int startIndex) if (normal) exp -= 1023; else exp = -1022; - double result = (double) frac / 0x10000000000000UL; + double result = (double)frac / 0x10000000000000UL; if (normal) result += 1.0; result *= Math.Pow(2, exp); @@ -361,8 +362,7 @@ public static int ReadVariableInt(this byte[] array, int startIndex, out short r shift += 7; bytesRead++; startIndex++; - } - while ((array[startIndex - 1] & 0x80) != 0); + } while ((array[startIndex - 1] & 0x80) != 0); // Apply ZigZag decoding to get the original signed short value result = (short)((uValue >> 1) ^ -(short)(uValue & 1)); @@ -390,11 +390,10 @@ public static int ReadVariableInt(this byte[] array, int startIndex, out long re shift += 7; bytesRead++; startIndex++; - } - while ((array[startIndex - 1] & 0x80) != 0); + } while ((array[startIndex - 1] & 0x80) != 0); // Apply ZigZag decoding to get the original signed long value - result = (long)((uValue >> 1) ^ (ulong) -(long)(uValue & 1)); + result = (long)((uValue >> 1) ^ (ulong)-(long)(uValue & 1)); return bytesRead; } @@ -418,8 +417,7 @@ public static int ReadVariableInt(this byte[] array, int startIndex, out int res shift += 7; bytesRead++; startIndex++; - } - while ((array[startIndex - 1] & 0x80) != 0); + } while ((array[startIndex - 1] & 0x80) != 0); // Apply ZigZag decoding to get the original signed integer value result = (int)((uValue >> 1) ^ -(int)(uValue & 1)); @@ -439,24 +437,24 @@ public static int ReadVariableInt(this byte[] array, int startIndex, out uint re } else if ((b & _0xC0) == _0x80) { - result = (uint) ((b & _0x3F) << 8 | array[startIndex + 1]); + result = (uint)((b & _0x3F) << 8 | array[startIndex + 1]); return 2; } else if ((b & _0xE0) == _0xC0) { - result = (uint) ((b & _0x1F) << 16 | array[startIndex + 1] << 8 | array[startIndex + 2]); + result = (uint)((b & _0x1F) << 16 | array[startIndex + 1] << 8 | array[startIndex + 2]); return 3; } else if ((b & _0xF0) == _0xE0) { - result = (uint) ((b & _0x0F) << 24 | array[startIndex + 1] << 16 | array[startIndex + 2] << 8 | - array[startIndex + 3]); + result = (uint)((b & _0x0F) << 24 | array[startIndex + 1] << 16 | array[startIndex + 2] << 8 | + array[startIndex + 3]); return 4; } else if (b == 0xF0) { - result = (uint) (array[startIndex + 1] << 24 | array[startIndex + 2] << 16 | - array[startIndex + 3] << 8 | array[startIndex + 4]); + result = (uint)(array[startIndex + 1] << 24 | array[startIndex + 2] << 16 | + array[startIndex + 3] << 8 | array[startIndex + 4]); return 5; } @@ -470,17 +468,17 @@ public static int ReadVariableInt(this byte[] array, int startIndex, out ushort if ((b & _0x80) == 0) { - result = (ushort) b; + result = (ushort)b; return 1; } else if ((b & _0xC0) == _0x80) { - result = (ushort) (((b & _0x3F) << 8) | array[startIndex + 1]); + result = (ushort)(((b & _0x3F) << 8) | array[startIndex + 1]); return 2; } else { - result = (ushort) (((b & _0x1F) << 16) | (array[startIndex + 1] << 8) | array[startIndex + 2]); + result = (ushort)(((b & _0x1F) << 16) | (array[startIndex + 1] << 8) | array[startIndex + 2]); return 3; } } @@ -490,61 +488,63 @@ public static int ReadVariableInt(this byte[] array, int startIndex, out ulong r byte b = array[startIndex]; result = 0; - if ((b & _0x80) == 0) + if ((b & 0x80) == 0) // Single byte (7-bit value) { result = b; return 1; } - else if ((b & _0xC0) == _0x80) + else if ((b & 0xC0) == 0x80) // Two bytes (14-bit value) { - result = (ulong) ((b & _0x3F) << 8 | array[startIndex + 1]); + result = (ulong)((b & 0x3F) << 8 | array[startIndex + 1]); return 2; } - else if ((b & _0xE0) == _0xC0) + else if ((b & 0xE0) == 0xC0) // Three bytes (21-bit value) { - result = (ulong) ((b & _0x1F) << 16 | array[startIndex + 1] << 8 | array[startIndex + 2]); + result = (ulong)((b & 0x1F) << 16 | array[startIndex + 1] << 8 | array[startIndex + 2]); return 3; } - else if ((b & _0xF0) == _0xE0) + else if ((b & 0xF0) == 0xE0) // Four bytes (28-bit value) { - result = (ulong) ((b & _0x0F) << 24 | array[startIndex + 1] << 16 | array[startIndex + 2] << 8 | - array[startIndex + 3]); + result = (ulong)((b & 0x0F) << 24 | array[startIndex + 1] << 16 | array[startIndex + 2] << 8 | + array[startIndex + 3]); return 4; } - else if (b == 0xF0) + else if ((b & 0xF8) == 0xF0) // Five bytes (35-bit value) { - result = (ulong) (array[startIndex + 1] << 24 | array[startIndex + 2] << 16 | - array[startIndex + 3] << 8 | array[startIndex + 4]); + result = (ulong)(b & 0x07) << 32 | (ulong)array[startIndex + 1] << 24 | + (ulong)array[startIndex + 2] << 16 | (ulong)array[startIndex + 3] << 8 | + array[startIndex + 4]; return 5; } - else if (b == 0xF8) + else if ((b & 0xFC) == 0xF8) // Six bytes (42-bit value) { - result = (ulong) (array[startIndex + 1]) << 32 | ((ulong) array[startIndex + 2]) << 24 | - ((ulong) array[startIndex + 3]) << 16 | ((ulong) array[startIndex + 4]) << 8 | - ((ulong) array[startIndex + 5]); + result = (ulong)(b & 0x03) << 40 | (ulong)array[startIndex + 1] << 32 | + (ulong)array[startIndex + 2] << 24 | (ulong)array[startIndex + 3] << 16 | + (ulong)array[startIndex + 4] << 8 | array[startIndex + 5]; return 6; } - else if (b == 0xFC) + else if ((b & 0xFE) == 0xFC) // Seven bytes (49-bit value) { - result = (ulong) (array[startIndex + 1]) << 40 | ((ulong) array[startIndex + 2]) << 32 | - ((ulong) array[startIndex + 3]) << 24 | ((ulong) array[startIndex + 4]) << 16 | - ((ulong) array[startIndex + 5]) << 8 | ((ulong) array[startIndex + 6]); + result = ((ulong)(b & 0x01) << 48 | (ulong)array[startIndex + 1] << 40 | + (ulong)array[startIndex + 2] << 32 | (ulong)array[startIndex + 3] << 24 | + (ulong)array[startIndex + 4] << 16 | (ulong)array[startIndex + 5] << 8 | + array[startIndex + 6]); return 7; } - else if (b == 0xFE) + else if (b == 0xFE) // Eight bytes (56-bit value) { - result = (ulong) (array[startIndex + 1]) << 48 | ((ulong) array[startIndex + 2]) << 40 | - ((ulong) array[startIndex + 3]) << 32 | ((ulong) array[startIndex + 4]) << 24 | - ((ulong) array[startIndex + 5]) << 16 | ((ulong) array[startIndex + 6]) << 8 | - ((ulong) array[startIndex + 7]); + result = (ulong)array[startIndex + 1] << 48 | (ulong)array[startIndex + 2] << 40 | + (ulong)array[startIndex + 3] << 32 | (ulong)array[startIndex + 4] << 24 | + (ulong)array[startIndex + 5] << 16 | (ulong)array[startIndex + 6] << 8 | + array[startIndex + 7]; return 8; } - else if (b == 0xFF) + else if (b == 0xFF) // Nine bytes (64-bit value) { - result = (ulong) (array[startIndex + 1]) << 56 | ((ulong) array[startIndex + 2]) << 48 | - ((ulong) array[startIndex + 3]) << 40 | ((ulong) array[startIndex + 4]) << 32 | - ((ulong) array[startIndex + 5]) << 24 | ((ulong) array[startIndex + 6]) << 16 | - ((ulong) array[startIndex + 7]) << 8 | ((ulong) array[startIndex + 8]); + result = (ulong)array[startIndex + 1] << 56 | (ulong)array[startIndex + 2] << 48 | + (ulong)array[startIndex + 3] << 40 | (ulong)array[startIndex + 4] << 32 | + (ulong)array[startIndex + 5] << 24 | (ulong)array[startIndex + 6] << 16 | + (ulong)array[startIndex + 7] << 8 | array[startIndex + 8]; return 9; } diff --git a/Packages/com.miner28.networkedeventcaller/Runtime/NetworkedEventCallerReceiver.cs b/Packages/com.miner28.networkedeventcaller/Runtime/NetworkedEventCallerReceiver.cs index 0be29ff..ff984a9 100644 --- a/Packages/com.miner28.networkedeventcaller/Runtime/NetworkedEventCallerReceiver.cs +++ b/Packages/com.miner28.networkedeventcaller/Runtime/NetworkedEventCallerReceiver.cs @@ -8,7 +8,7 @@ namespace Miner28.UdonUtils.Network { public partial class NetworkedEventCaller : UdonSharpBehaviour { - private int ReceiveData(int startIndex) + int ReceiveData(int startIndex) { _bufferOffset = startIndex; @@ -149,7 +149,6 @@ private int ReceiveData(int startIndex) _parameters[_iter] = Convert.ToUInt16((syncBuffer[_bufferOffset] << Bit8) | syncBuffer[_bufferOffset + 1]); _bufferOffset += 2; - break; } break; @@ -231,7 +230,6 @@ private int ReceiveData(int startIndex) (syncBuffer[_bufferOffset + 2] << Bit8) | syncBuffer[_bufferOffset + 3]); _bufferOffset += 4; - break; } break; @@ -364,10 +362,10 @@ private int ReceiveData(int startIndex) if (length == 5) { - _parameters[_iter] = Convert.ToUInt64((syncBuffer[_bufferOffset] << Bit32) | - (syncBuffer[_bufferOffset + 1] << Bit24) | - (syncBuffer[_bufferOffset + 2] << Bit16) | - (syncBuffer[_bufferOffset + 3] << Bit8) | + _parameters[_iter] = Convert.ToUInt64(((ulong) syncBuffer[_bufferOffset] << Bit32) | + ((ulong)syncBuffer[_bufferOffset + 1] << Bit24) | + ((ulong)syncBuffer[_bufferOffset + 2] << Bit16) | + ((ulong)syncBuffer[_bufferOffset + 3] << Bit8) | syncBuffer[_bufferOffset + 4]); _bufferOffset += 5; break; @@ -375,11 +373,11 @@ private int ReceiveData(int startIndex) if (length == 6) { - _parameters[_iter] = Convert.ToUInt64((syncBuffer[_bufferOffset] << Bit40) | - (syncBuffer[_bufferOffset + 1] << Bit32) | - (syncBuffer[_bufferOffset + 2] << Bit24) | - (syncBuffer[_bufferOffset + 3] << Bit16) | - (syncBuffer[_bufferOffset + 4] << Bit8) | + _parameters[_iter] = Convert.ToUInt64(((ulong)syncBuffer[_bufferOffset] << Bit40) | + ((ulong)syncBuffer[_bufferOffset + 1] << Bit32) | + ((ulong)syncBuffer[_bufferOffset + 2] << Bit24) | + ((ulong)syncBuffer[_bufferOffset + 3] << Bit16) | + ((ulong)syncBuffer[_bufferOffset + 4] << Bit8) | syncBuffer[_bufferOffset + 5]); _bufferOffset += 6; break; @@ -387,12 +385,12 @@ private int ReceiveData(int startIndex) if (length == 7) { - _parameters[_iter] = Convert.ToUInt64((syncBuffer[_bufferOffset] << Bit48) | - (syncBuffer[_bufferOffset + 1] << Bit40) | - (syncBuffer[_bufferOffset + 2] << Bit32) | - (syncBuffer[_bufferOffset + 3] << Bit24) | - (syncBuffer[_bufferOffset + 4] << Bit16) | - (syncBuffer[_bufferOffset + 5] << Bit8) | + _parameters[_iter] = Convert.ToUInt64(((ulong)syncBuffer[_bufferOffset] << Bit48) | + ((ulong)syncBuffer[_bufferOffset + 1] << Bit40) | + ((ulong)syncBuffer[_bufferOffset + 2] << Bit32) | + ((ulong)syncBuffer[_bufferOffset + 3] << Bit24) | + ((ulong)syncBuffer[_bufferOffset + 4] << Bit16) | + ((ulong)syncBuffer[_bufferOffset + 5] << Bit8) | syncBuffer[_bufferOffset + 6]); _bufferOffset += 7; break; @@ -400,18 +398,16 @@ private int ReceiveData(int startIndex) if (length == 8) { - _parameters[_iter] = Convert.ToUInt64((syncBuffer[_bufferOffset] << Bit56) | - (syncBuffer[_bufferOffset + 1] << Bit48) | - (syncBuffer[_bufferOffset + 2] << Bit40) | - (syncBuffer[_bufferOffset + 3] << Bit32) | - (syncBuffer[_bufferOffset + 4] << Bit24) | - (syncBuffer[_bufferOffset + 5] << Bit16) | - (syncBuffer[_bufferOffset + 6] << Bit8) | + _parameters[_iter] = Convert.ToUInt64(((ulong)syncBuffer[_bufferOffset] << Bit56) | + ((ulong)syncBuffer[_bufferOffset + 1] << Bit48) | + ((ulong)syncBuffer[_bufferOffset + 2] << Bit40) | + ((ulong)syncBuffer[_bufferOffset + 3] << Bit32) | + ((ulong)syncBuffer[_bufferOffset + 4] << Bit24) | + ((ulong)syncBuffer[_bufferOffset + 5] << Bit16) | + ((ulong)syncBuffer[_bufferOffset + 6] << Bit8) | syncBuffer[_bufferOffset + 7]); _bufferOffset += 8; - break; } - break; case Types.Single: { diff --git a/Packages/com.miner28.networkedeventcaller/package.json b/Packages/com.miner28.networkedeventcaller/package.json index f982dda..c6a3cb5 100644 --- a/Packages/com.miner28.networkedeventcaller/package.json +++ b/Packages/com.miner28.networkedeventcaller/package.json @@ -1,6 +1,6 @@ { "name": "com.miner28.networked-event-caller", - "version": "3.2.7", + "version": "3.2.8", "displayName": "NetworkedEventCaller", "description": "A UdonSharp prefab that allows you to call events on other UdonBehaviours across the network with support for parameters.", "author": {