mirror of
https://github.com/dashr9230/SA-MP.git
synced 2025-07-18 09:28:07 +08:00
[raknet] Implement/match BitStream constructor
This commit is contained in:
@ -123,6 +123,43 @@ BitStream::BitStream( unsigned char* _data, unsigned int lengthInBytes, bool _co
|
||||
data = ( unsigned char* ) _data;
|
||||
}
|
||||
|
||||
// SAMPSRV (adding this just as a tag for next RakNet upgrade)
|
||||
BitStream::BitStream( char* _dataC, unsigned int lengthInBytes, bool _copyData )
|
||||
{
|
||||
unsigned char* _data = reinterpret_cast<unsigned char*>(_dataC);
|
||||
|
||||
numberOfBitsUsed = lengthInBytes << 3;
|
||||
readOffset = 0;
|
||||
copyData = _copyData;
|
||||
numberOfBitsAllocated = lengthInBytes << 3;
|
||||
|
||||
if ( copyData )
|
||||
{
|
||||
if ( lengthInBytes > 0 )
|
||||
{
|
||||
if (lengthInBytes < BITSTREAM_STACK_ALLOCATION_SIZE)
|
||||
{
|
||||
data = ( unsigned char* ) stackData;
|
||||
numberOfBitsAllocated = BITSTREAM_STACK_ALLOCATION_SIZE << 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = ( unsigned char* ) malloc( lengthInBytes );
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
assert( data );
|
||||
#endif
|
||||
memcpy( data, _data, lengthInBytes );
|
||||
}
|
||||
else
|
||||
data = 0;
|
||||
}
|
||||
else
|
||||
data = ( unsigned char* ) _data;
|
||||
|
||||
}
|
||||
// SAMPSRV end
|
||||
|
||||
// Use this if you pass a pointer copy to the constructor (_copyData==false) and want to overallocate to prevent reallocation
|
||||
void BitStream::SetNumberOfBitsAllocated( const unsigned int lengthInBits )
|
||||
{
|
||||
|
@ -67,7 +67,11 @@ namespace RakNet
|
||||
/// \param[in] lengthInBytes Size of the \a _data.
|
||||
/// \param[in] _copyData true or false to make a copy of \a _data or not.
|
||||
BitStream( unsigned char* _data, unsigned int lengthInBytes, bool _copyData );
|
||||
|
||||
|
||||
// SAMPSRV (adding this just as a tag for next RakNet upgrade)
|
||||
BitStream( char* _dataC, unsigned int lengthInBytes, bool _copyData );
|
||||
// SAMPSRV end
|
||||
|
||||
/// Destructor
|
||||
~BitStream();
|
||||
|
||||
|
Reference in New Issue
Block a user