Browse Source

engine: common: avoid sign bit loss in MSG_WriteBitLong

pull/2/head
Alibek Omarov 3 years ago
parent
commit
d54a648792
  1. 6
      engine/common/net_buffer.c
  2. 2
      engine/common/net_buffer.h

6
engine/common/net_buffer.c

@ -214,11 +214,11 @@ void MSG_WriteSBitLong( sizebuf_t *sb, int data, int numbits ) @@ -214,11 +214,11 @@ void MSG_WriteSBitLong( sizebuf_t *sb, int data, int numbits )
}
}
void MSG_WriteBitLong( sizebuf_t *sb, int data, int numbits, qboolean bSigned )
void MSG_WriteBitLong( sizebuf_t *sb, uint data, int numbits, qboolean bSigned )
{
if( bSigned )
MSG_WriteSBitLong( sb, data, numbits );
else MSG_WriteUBitLong( sb, (uint)data, numbits );
MSG_WriteSBitLong( sb, (int)data, numbits );
else MSG_WriteUBitLong( sb, data, numbits );
}
qboolean MSG_WriteBits( sizebuf_t *sb, const void *pData, int nBits )

2
engine/common/net_buffer.h

@ -73,7 +73,7 @@ void MSG_Clear( sizebuf_t *sb ); @@ -73,7 +73,7 @@ void MSG_Clear( sizebuf_t *sb );
void MSG_WriteOneBit( sizebuf_t *sb, int nValue );
void MSG_WriteUBitLong( sizebuf_t *sb, uint curData, int numbits );
void MSG_WriteSBitLong( sizebuf_t *sb, int data, int numbits );
void MSG_WriteBitLong( sizebuf_t *sb, int data, int numbits, qboolean bSigned );
void MSG_WriteBitLong( sizebuf_t *sb, uint data, int numbits, qboolean bSigned );
qboolean MSG_WriteBits( sizebuf_t *sb, const void *pData, int nBits );
void MSG_WriteBitAngle( sizebuf_t *sb, float fAngle, int numbits );
void MSG_WriteBitFloat( sizebuf_t *sb, float val );

Loading…
Cancel
Save