engine: fix signed integers encoding with alternate format for GoldSrc protocol

This commit is contained in:
Alibek Omarov 2024-10-11 20:35:17 +03:00
parent 60ab13d216
commit 0b2cc066dd

View file

@ -213,27 +213,25 @@ void MSG_WriteSBitLong( sizebuf_t *sb, int data, int numbits )
// do we have a valid # of bits to encode with?
Assert( numbits >= 1 && numbits <= 32 );
if( sb->iAlternateSign )
{
MSG_WriteOneBit( sb, data < 0 ? 1 : 0 );
MSG_WriteUBitLong( sb, (uint)abs( data ), numbits - 1 );
}
else
{
if( data < 0 )
{
if( sb->iAlternateSign )
MSG_WriteOneBit( sb, 1 );
MSG_WriteUBitLong( sb, (uint)( 0x80000000 + data ), numbits - 1 );
if( !sb->iAlternateSign )
MSG_WriteOneBit( sb, 1 );
}
else
{
if( sb->iAlternateSign )
MSG_WriteOneBit( sb, 0 );
MSG_WriteUBitLong( sb, (uint)data, numbits - 1 );
if( !sb->iAlternateSign )
MSG_WriteOneBit( sb, 0 );
}
}
}
void MSG_WriteBitLong( sizebuf_t *sb, uint data, int numbits, qboolean bSigned )
{