Skip to content

Commit 339564c

Browse files
committed
Fix WriteBitAngle to match GMod's float math
1 parent a49a58e commit 339564c

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎Source.Common/Bitbuffers/bf_write.cs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,14 +418,14 @@ public bool WriteBitsFromBuffer(bf_read pIn, int nBits) {
418418

419419
public void WriteBitAngle(float fAngle, int numbits) {
420420
int d;
421-
int mask;
422-
int shift;
421+
uint mask;
422+
uint shift;
423423

424-
shift = (int)BitForBitnum(numbits);
424+
shift = BitForBitnum(numbits);
425425
mask = shift - 1;
426426

427-
d = (int)(fAngle / 360.0 * shift);
428-
d &= mask;
427+
d = MathLib.TruncateOrMinValue(fAngle * (1f / 360f) * shift);
428+
d &= (int)mask;
429429

430430
WriteUBitLong((uint)d, numbits);
431431
}

0 commit comments

Comments
 (0)