mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-01-05 17:13:36 +08:00
Added WriteVarInt32 and ByteSizeVarInt32 to tier1 bf_write.
This commit is contained in:
parent
eb6ef53ad8
commit
4322ebcfb8
@ -143,6 +143,9 @@ public:
|
||||
// writes an unsigned integer with variable bit length
|
||||
void WriteUBitVar( unsigned int data );
|
||||
|
||||
void WriteVarInt32( uint32 data );
|
||||
int ByteSizeVarInt32( uint32 data );
|
||||
|
||||
// Copy the bits straight out of pIn. This seeks pIn forward by nBits.
|
||||
// Returns an error if this buffer or the read buffer overflows.
|
||||
bool WriteBitsFromBuffer( class bf_read *pIn, int nBits );
|
||||
|
@ -236,6 +236,27 @@ void bf_write::WriteSBitLong( int data, int numbits )
|
||||
}
|
||||
}
|
||||
|
||||
void bf_write::WriteVarInt32( uint32 data )
|
||||
{
|
||||
while ( data > 0x7F )
|
||||
{
|
||||
WriteUBitLong( (data & 0x7F) | 0x80, 8 );
|
||||
data >>= 7;
|
||||
}
|
||||
WriteUBitLong( data & 0x7F, 8 );
|
||||
}
|
||||
|
||||
int bf_write::ByteSizeVarInt32( uint32 data )
|
||||
{
|
||||
int size = 1;
|
||||
while ( data > 0x7F )
|
||||
{
|
||||
size++;
|
||||
data >>= 7;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
#if _WIN32
|
||||
inline unsigned int BitCountNeededToEncode(unsigned int data)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user