diff options
| author | Shauren <shauren.trinity@gmail.com> | 2011-11-27 17:46:05 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2011-11-27 17:46:05 +0100 |
| commit | 6d1c770d8d5e6beddf304859de76d94473b6d221 (patch) | |
| tree | b22d2e62147a4d4da416af9b4edf118da5727b58 /src/server/shared/Packets | |
| parent | 5be5eae64fa801b6eedbc993d99ba3af61c273e9 (diff) | |
Cosmetic changes and typo fixes
Diffstat (limited to 'src/server/shared/Packets')
| -rw-r--r-- | src/server/shared/Packets/ByteBuffer.cpp | 6 | ||||
| -rwxr-xr-x | src/server/shared/Packets/ByteBuffer.h | 34 |
2 files changed, 20 insertions, 20 deletions
diff --git a/src/server/shared/Packets/ByteBuffer.cpp b/src/server/shared/Packets/ByteBuffer.cpp index e2efdccfbcb..2f669f9a428 100644 --- a/src/server/shared/Packets/ByteBuffer.cpp +++ b/src/server/shared/Packets/ByteBuffer.cpp @@ -49,14 +49,14 @@ template <typename T> void BitStream::WriteBits(T value, size_t bits) WriteBit((value >> i) & 1); } -bool BitStream::Empty () +bool BitStream::Empty() { return _data.empty(); } void BitStream::Reverse() { - uint32 len = GetLenght(); + uint32 len = GetLength(); std::vector<uint8> b = _data; Clear(); @@ -70,7 +70,7 @@ void BitStream::Print() return; std::stringstream ss; ss << "BitStream: "; - for (uint32 i = 0; i < GetLenght(); ++i) + for (uint32 i = 0; i < GetLength(); ++i) ss << uint32(GetBit(i)) << " "; sLog->outDebug(LOG_FILTER_NETWORKIO, ss.str().c_str()); diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index 0433145b028..bf4cf01b2be 100755 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -68,7 +68,7 @@ class BitStream void Reverse(); void Print(); - size_t GetLenght () { return _data.size();} + size_t GetLength() { return _data.size(); } uint32 GetReadPosition() { return _rpos; } uint32 GetWritePosition() { return _wpos; } void SetReadPos(uint32 pos) { _rpos = pos; } @@ -103,7 +103,10 @@ class ByteBuffer ByteBuffer(size_t res, bool init = false); // copy constructor - ByteBuffer(const ByteBuffer &buf): _rpos(buf._rpos), _wpos(buf._wpos), _storage(buf._storage), _bitpos(buf._bitpos), _curbitval(buf._curbitval) { } + ByteBuffer(const ByteBuffer &buf) : _rpos(buf._rpos), _wpos(buf._wpos), + _storage(buf._storage), _bitpos(buf._bitpos), _curbitval(buf._curbitval) + { + } void clear() { @@ -113,12 +116,12 @@ class ByteBuffer template <typename T> void append(T value) { - flushBits(); + FlushBits(); EndianConvert(value); append((uint8 *)&value, sizeof(value)); } - void flushBits() + void FlushBits() { if (_bitpos == 8) return; @@ -128,7 +131,7 @@ class ByteBuffer _bitpos = 8; } - bool writeBit(uint32 bit) + bool WriteBit(uint32 bit) { --_bitpos; if (bit) @@ -144,7 +147,7 @@ class ByteBuffer return (bit != 0); } - bool readBit() + bool ReadBit() { ++_bitpos; if (_bitpos > 7) @@ -152,26 +155,23 @@ class ByteBuffer _bitpos = 0; _curbitval = read<uint8>(); } - bool bit = ((_curbitval >> (7-_bitpos)) & 1) != 0; - return bit; + + return ((_curbitval >> (7-_bitpos)) & 1) != 0; } - template <typename T> void writeBits(T value, size_t bits) + template <typename T> void WriteBits(T value, size_t bits) { for (int32 i = bits-1; i >= 0; --i) - writeBit((value >> i) & 1); + WriteBit((value >> i) & 1); } - uint32 readBits(size_t bits) + uint32 ReadBits(size_t bits) { uint32 value = 0; for (int32 i = bits-1; i >= 0; --i) - { - if(readBit()) - { + if (ReadBit()) value |= (1 << (_bitpos)); - } - } + return value; } @@ -179,7 +179,7 @@ class ByteBuffer { BitStream b; for (uint32 i = 0; i < len; ++i) - b.WriteBit(readBit()); + b.WriteBit(ReadBit()); return b; } |
