From 2a5ecab2eeea6de7770399c370962eac5aa3cf13 Mon Sep 17 00:00:00 2001 From: Luke1410 Date: Fri, 26 Jul 2019 18:45:00 +0200 Subject: [PATCH] - move BitStream::SetReadOffset() and ::AlignReadToByteBoundary() definitions to cpp (#130) --- Source/include/slikenet/BitStream.h | 6 +++--- Source/src/BitStream.cpp | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Source/include/slikenet/BitStream.h b/Source/include/slikenet/BitStream.h index 0b8762be6..d6f1b0d77 100644 --- a/Source/include/slikenet/BitStream.h +++ b/Source/include/slikenet/BitStream.h @@ -7,7 +7,7 @@ * of patent rights can be found in the RakNet Patents.txt file in the same directory. * * - * Modified work: Copyright (c) 2016-2018, SLikeSoft UG (haftungsbeschränkt) + * Modified work: Copyright (c) 2016-2019, SLikeSoft UG (haftungsbeschränkt) * * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style * license found in the license.txt file in the root directory of this source tree. @@ -528,7 +528,7 @@ namespace SLNet inline BitSize_t GetReadOffset( void ) const {return readOffset;} /// \brief Sets the read bit index - void SetReadOffset( const BitSize_t newReadOffset ) {readOffset=newReadOffset;} + void SetReadOffset(const BitSize_t newReadOffset); /// \brief Returns the number of bits left in the stream that haven't been read inline BitSize_t GetNumberOfUnreadBits( void ) const {return numberOfBitsUsed - readOffset;} @@ -611,7 +611,7 @@ namespace SLNet /// can also be used to force coalesced bitstreams to start on byte /// boundaries so so WriteAlignedBits and ReadAlignedBits both /// calculate the same offset when aligning. - inline void AlignReadToByteBoundary( void ) {readOffset += 8 - ( (( readOffset - 1 ) & 7 ) + 1 );} + inline void AlignReadToByteBoundary(void); /// \brief Read \a numberOfBitsToRead bits to the output source. /// \details alignBitsToRight should be set to true to convert internal diff --git a/Source/src/BitStream.cpp b/Source/src/BitStream.cpp index aea42b1ec..d1b25f262 100644 --- a/Source/src/BitStream.cpp +++ b/Source/src/BitStream.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the RakNet Patents.txt file in the same directory. * * - * Modified work: Copyright (c) 2016-2018, SLikeSoft UG (haftungsbeschränkt) + * Modified work: Copyright (c) 2016-2019, SLikeSoft UG (haftungsbeschränkt) * * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style * license found in the license.txt file in the root directory of this source tree. @@ -272,10 +272,8 @@ bool BitStream::Read( char* outByteArray, const unsigned int numberOfBytes ) readOffset += numberOfBytes << 3; return true; } - else - { - return ReadBits( ( unsigned char* ) outByteArray, numberOfBytes * 8 ); - } + + return ReadBits( ( unsigned char* ) outByteArray, numberOfBytes * 8 ); } // Sets the read pointer back to the beginning of your data. @@ -534,6 +532,11 @@ void BitStream::WriteCompressed( const unsigned char* inByteArray, } } +void BitStream::AlignReadToByteBoundary() +{ + readOffset += 8 - ( (( readOffset - 1 ) & 7 ) + 1 ); +} + // Read numberOfBitsToRead bits to the output source // alignBitsToRight should be set to true to convert internal bitstream data to userdata // It should be false if you used WriteBits with rightAlignedBits false @@ -939,6 +942,11 @@ void BitStream::PrintHex( void ) const RAKNET_DEBUG_PRINTF("%s", out); } +void BitStream::SetReadOffset(const BitSize_t newReadOffset) +{ + readOffset = newReadOffset; +} + // Exposes the data for you to look at, like PrintBits does. // Data will point to the stream. Returns the length in bits of the stream. BitSize_t BitStream::CopyData( unsigned char** _data ) const