From 23a5ed71de0a6518ed291397bbe461163ca5bbde Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 15 Oct 2024 06:14:37 +0300 Subject: [PATCH] engine: easier MSG_EndBitWriting byte padding --- engine/common/net_buffer.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/common/net_buffer.h b/engine/common/net_buffer.h index 46470d02..9b371d58 100644 --- a/engine/common/net_buffer.h +++ b/engine/common/net_buffer.h @@ -184,7 +184,8 @@ static inline void MSG_EndBitWriting( sizebuf_t *sb ) } // we have native bit ops here, just pad to closest byte - MSG_SeekToBit( sb, MSG_GetNumBytesWritten( sb ) << 3, SEEK_SET ); + if(( sb->iCurBit & 7 ) != 0 ) + MSG_SeekToBit( sb, 8 - ( sb->iCurBit & 7 ), SEEK_CUR ); } static inline void MSG_StartBitWriting( sizebuf_t *sb )