Skip to content

Commit

Permalink
fix(client): parse sync info
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Jan 9, 2024
1 parent e2160bb commit 060b9ea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 39 deletions.
53 changes: 15 additions & 38 deletions api/AltV.Net.Client/Elements/Data/SyncInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,26 @@ internal struct SyncInfoInternal
public uint AckedSendTick;
public ushort PropertyCount;
public byte ComponentCount;
public IntPtr PropertiesUpdateTick;
public IntPtr ComponentPropertyIndex;
public IntPtr PropertyUpdateCount;
public IntPtr PropertyUpdateTicks;

public uint[] GetPropertiesUpdateTick()
{
if (PropertyCount == 0)
{
return Array.Empty<uint>();
}

var value = PropertiesUpdateTick;
var values = new uint[PropertyCount];
var buffer = new byte[4];

for (var i = 0; i < values.Length; i++)
{
values[i] = UIntArray.ReadUInt32(buffer, value);
value += UIntArray.UInt32Size;
}

return values;
}

public uint[] GetComponentPropertyIndex()
public uint[][] GetPropertyUpdateTicks()
{
if (ComponentCount == 0)
{
return Array.Empty<uint>();
return default;
}

var value = ComponentPropertyIndex;
var values = new uint[ComponentCount - 1];
var buffer = new byte[4];
var value = PropertyUpdateTicks;
var values = new uint[ComponentCount][];

/*var buffer = new byte[4];
for (var i = 0; i < values.Length; i++)
{
values[i] = UIntArray.ReadUInt32(buffer, value);
value += UIntArray.UInt32Size;
}
}*/

return values;
}
Expand All @@ -67,8 +48,7 @@ public SyncInfo ToPublic()
AckedSendTick,
PropertyCount,
ComponentCount,
GetPropertiesUpdateTick(),
GetComponentPropertyIndex());
GetPropertyUpdateTicks());
}
}

Expand All @@ -82,10 +62,9 @@ public struct SyncInfo : IEquatable<SyncInfo>
public uint AckedSendTick;
public ushort PropertyCount;
public byte ComponentCount;
public uint[] PropertiesUpdateTick;
public uint[] ComponentPropertyIndex;
public uint[][] PropertyUpdateTicks;

public SyncInfo(byte active, uint receivedTick, uint fullyReceivedTick, uint sendTick, uint ackedSendTick, ushort propertyCount, byte componentCount, uint[] propertiesUpdateTick, uint[] componentPropertyIndex)
public SyncInfo(byte active, uint receivedTick, uint fullyReceivedTick, uint sendTick, uint ackedSendTick, ushort propertyCount, byte componentCount, uint[][] propertyUpdateTicks)
{
Active = active;
ReceivedTick = receivedTick;
Expand All @@ -94,13 +73,12 @@ public SyncInfo(byte active, uint receivedTick, uint fullyReceivedTick, uint sen
AckedSendTick = ackedSendTick;
PropertyCount = propertyCount;
ComponentCount = componentCount;
PropertiesUpdateTick = propertiesUpdateTick;
ComponentPropertyIndex = componentPropertyIndex;
PropertyUpdateTicks = propertyUpdateTicks;
}

public bool Equals(SyncInfo other)
{
return Active == other.Active && ReceivedTick == other.ReceivedTick && FullyReceivedTick == other.FullyReceivedTick && SendTick == other.SendTick && AckedSendTick == other.AckedSendTick && PropertyCount == other.PropertyCount && ComponentCount == other.ComponentCount && PropertiesUpdateTick.Equals(other.PropertiesUpdateTick) && ComponentPropertyIndex.Equals(other.ComponentPropertyIndex);
return Active == other.Active && ReceivedTick == other.ReceivedTick && FullyReceivedTick == other.FullyReceivedTick && SendTick == other.SendTick && AckedSendTick == other.AckedSendTick && PropertyCount == other.PropertyCount && ComponentCount == other.ComponentCount && PropertyUpdateTicks.Equals(other.PropertyUpdateTicks);
}

public override bool Equals(object obj)
Expand All @@ -118,8 +96,7 @@ public override int GetHashCode()
hashCode.Add(AckedSendTick);
hashCode.Add(PropertyCount);
hashCode.Add(ComponentCount);
hashCode.Add(PropertiesUpdateTick);
hashCode.Add(ComponentPropertyIndex);
hashCode.Add(PropertyUpdateTicks);
return hashCode.ToHashCode();
}
}
2 changes: 1 addition & 1 deletion runtime

0 comments on commit 060b9ea

Please sign in to comment.