diff --git a/raknet/BitStream.cpp b/raknet/BitStream.cpp index 9f4e22f..747a697 100644 --- a/raknet/BitStream.cpp +++ b/raknet/BitStream.cpp @@ -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(_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 ) { diff --git a/raknet/BitStream.h b/raknet/BitStream.h index fe1ff09..74634c7 100644 --- a/raknet/BitStream.h +++ b/raknet/BitStream.h @@ -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();