Skip to content

Commit eaa46aa

Browse files
committed
Merge branch 'dev' into rc
2 parents b890d68 + 1279cae commit eaa46aa

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

api/AltV.Net.Client/Elements/Data/SyncInfo.cs

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,47 @@ internal struct SyncInfoInternal
1717
public IntPtr PropertyUpdateCount;
1818
public IntPtr PropertyUpdateTicks;
1919

20-
public uint[][] GetPropertyUpdateTicks()
20+
private uint[] GetCompPropertySize()
21+
{
22+
var value = PropertyUpdateCount;
23+
var values = new uint[ComponentCount];
24+
var buffer = new byte[4];
25+
26+
for (var i = 0; i < values.Length; i++)
27+
{
28+
values[i] = UIntArray.ReadUInt32(buffer, value);
29+
value += UIntArray.UInt32Size;
30+
}
31+
32+
return values;
33+
}
34+
35+
private uint[][] GetPropertyUpdateTicks()
2136
{
2237
if (ComponentCount == 0)
2338
{
2439
return default;
2540
}
2641

27-
var value = PropertyUpdateTicks;
28-
var values = new uint[ComponentCount][];
42+
var compPropertySize = GetCompPropertySize();
2943

30-
/*var buffer = new byte[4];
44+
uint[][] result = new uint[ComponentCount][];
3145

32-
for (var i = 0; i < values.Length; i++)
46+
for (var i = 0; i < ComponentCount; i++)
3347
{
34-
values[i] = UIntArray.ReadUInt32(buffer, value);
35-
value += UIntArray.UInt32Size;
36-
}*/
48+
result[i] = new uint[compPropertySize[i]];
3749

38-
return values;
50+
for (var j = 0; j < compPropertySize[i]; j++)
51+
{
52+
// Calculate the index in the one-dimensional array
53+
var index = i * (int)compPropertySize[i] + j;
54+
55+
// Use Marshal to read the value at the specified index
56+
result[i][j] = (uint)Marshal.PtrToStructure(PropertyUpdateTicks + index * sizeof(uint), typeof(uint));
57+
}
58+
}
59+
60+
return result;
3961
}
4062

4163
public SyncInfo ToPublic()

0 commit comments

Comments
 (0)