Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Source.Common/Bitbuffers/bf_read.cs
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ public uint ReadUBitVar() {
public uint ReadUBitLong(uint bits) => ReadUBitLong((int)bits); // macro

public uint ReadUBitLong(int bits) {
Assert(bits > 0 && bits <= 32);

if (BitsLeft < bits) {
curBit = dataBits;
TriggerOverflow();
Expand Down
15 changes: 14 additions & 1 deletion Source.Engine/DtEncode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,19 @@ public static void VectorXY_SkipProp(SendProp prop, bf_read p) {
}
#endregion
#region SendPropType.String
static bool AreBitsDifferent(bf_read buf1, bf_read buf2, int bits) {
int dwords = bits >> 5;
bool diff = false;
for (int i = 0; i < dwords; i++)
diff |= buf1.ReadUBitLong(32) != buf2.ReadUBitLong(32);

int remainingBits = bits - (dwords << 5);
if (remainingBits > 0)
diff |= buf1.ReadUBitLong(remainingBits) != buf2.ReadUBitLong(remainingBits);

return diff;
}

public static int String_CompareDeltas(SendProp prop, bf_read p1, bf_read p2) {
int len1 = (int)p1.ReadUBitLong(Constants.DT_MAX_STRING_BITS);
int len2 = (int)p2.ReadUBitLong(Constants.DT_MAX_STRING_BITS);
Expand All @@ -452,7 +465,7 @@ public static int String_CompareDeltas(SendProp prop, bf_read p1, bf_read p2) {
if (len1 == 0)
return 0;

return p1.CompareBits(p2, len1 * 8) ? 1 : 0;
return AreBitsDifferent(p1, p2, len1 * 8) ? 1 : 0;
}
else {
p1.SeekRelative(len1 * 8);
Expand Down
Loading