Skip to content

Commit 2a5ecab

Browse files
committed
- move BitStream::SetReadOffset() and ::AlignReadToByteBoundary() definitions to cpp (facebookarchive#130)
1 parent e67c8fd commit 2a5ecab

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

Source/include/slikenet/BitStream.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
88
*
99
*
10-
* Modified work: Copyright (c) 2016-2018, SLikeSoft UG (haftungsbeschränkt)
10+
* Modified work: Copyright (c) 2016-2019, SLikeSoft UG (haftungsbeschränkt)
1111
*
1212
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
1313
* license found in the license.txt file in the root directory of this source tree.
@@ -528,7 +528,7 @@ namespace SLNet
528528
inline BitSize_t GetReadOffset( void ) const {return readOffset;}
529529

530530
/// \brief Sets the read bit index
531-
void SetReadOffset( const BitSize_t newReadOffset ) {readOffset=newReadOffset;}
531+
void SetReadOffset(const BitSize_t newReadOffset);
532532

533533
/// \brief Returns the number of bits left in the stream that haven't been read
534534
inline BitSize_t GetNumberOfUnreadBits( void ) const {return numberOfBitsUsed - readOffset;}
@@ -611,7 +611,7 @@ namespace SLNet
611611
/// can also be used to force coalesced bitstreams to start on byte
612612
/// boundaries so so WriteAlignedBits and ReadAlignedBits both
613613
/// calculate the same offset when aligning.
614-
inline void AlignReadToByteBoundary( void ) {readOffset += 8 - ( (( readOffset - 1 ) & 7 ) + 1 );}
614+
inline void AlignReadToByteBoundary(void);
615615

616616
/// \brief Read \a numberOfBitsToRead bits to the output source.
617617
/// \details alignBitsToRight should be set to true to convert internal

Source/src/BitStream.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
88
*
99
*
10-
* Modified work: Copyright (c) 2016-2018, SLikeSoft UG (haftungsbeschränkt)
10+
* Modified work: Copyright (c) 2016-2019, SLikeSoft UG (haftungsbeschränkt)
1111
*
1212
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
1313
* 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 )
272272
readOffset += numberOfBytes << 3;
273273
return true;
274274
}
275-
else
276-
{
277-
return ReadBits( ( unsigned char* ) outByteArray, numberOfBytes * 8 );
278-
}
275+
276+
return ReadBits( ( unsigned char* ) outByteArray, numberOfBytes * 8 );
279277
}
280278

281279
// Sets the read pointer back to the beginning of your data.
@@ -534,6 +532,11 @@ void BitStream::WriteCompressed( const unsigned char* inByteArray,
534532
}
535533
}
536534

535+
void BitStream::AlignReadToByteBoundary()
536+
{
537+
readOffset += 8 - ( (( readOffset - 1 ) & 7 ) + 1 );
538+
}
539+
537540
// Read numberOfBitsToRead bits to the output source
538541
// alignBitsToRight should be set to true to convert internal bitstream data to userdata
539542
// It should be false if you used WriteBits with rightAlignedBits false
@@ -939,6 +942,11 @@ void BitStream::PrintHex( void ) const
939942
RAKNET_DEBUG_PRINTF("%s", out);
940943
}
941944

945+
void BitStream::SetReadOffset(const BitSize_t newReadOffset)
946+
{
947+
readOffset = newReadOffset;
948+
}
949+
942950
// Exposes the data for you to look at, like PrintBits does.
943951
// Data will point to the stream. Returns the length in bits of the stream.
944952
BitSize_t BitStream::CopyData( unsigned char** _data ) const

0 commit comments

Comments
 (0)