From d54a6487926b5571c4f5d718711c3fe3f691f3c1 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 1 Jun 2021 17:57:54 +0300 Subject: [PATCH] engine: common: avoid sign bit loss in MSG_WriteBitLong --- engine/common/net_buffer.c | 6 +++--- engine/common/net_buffer.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/engine/common/net_buffer.c b/engine/common/net_buffer.c index bfc8f10b..ebf58599 100644 --- a/engine/common/net_buffer.c +++ b/engine/common/net_buffer.c @@ -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 ) diff --git a/engine/common/net_buffer.h b/engine/common/net_buffer.h index e91f4f00..50cb7361 100644 --- a/engine/common/net_buffer.h +++ b/engine/common/net_buffer.h @@ -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 );