diff options
| author | Sovak <Sovak007@gmail.com> | 2012-09-02 12:17:38 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2012-09-02 12:17:38 +0200 |
| commit | 13e1e2361170c6e4a1fb5bcddc21b007d8681352 (patch) | |
| tree | c2dd220b88563ecff7e136f66effab535ea22bbf /src/server/shared | |
| parent | 2e1de60593fda0c1ad766fb0333a1992b17c35b9 (diff) | |
Core/Battlegrounds: More battleground fixes
Signed-off-by: Shauren <shauren.trinity@gmail.com>
Diffstat (limited to 'src/server/shared')
| -rwxr-xr-x | src/server/shared/Packets/ByteBuffer.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index bed09e8e372..39d3724835c 100755 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -191,7 +191,9 @@ class ByteBuffer /** * @name PutBits - * @brief Places specified amount of bits of value at specified position in packet + * @brief Places specified amount of bits of value at specified position in packet. + * To ensure all bits are correctly written, only call this method after + * bit flush has been performed * @param pos Position to place the value at, in bits. The entire value must fit in the packet * It is advised to obtain the position using bitwpos() function. @@ -201,8 +203,11 @@ class ByteBuffer */ template <typename T> void PutBits(size_t pos, T value, uint32 bitCount) { + if (!bitCount) + throw ByteBufferSourceException((pos + bitCount) / 8, , size(), 0); + if (pos + bitCount > size() * 8) - throw ByteBufferPositionException(false, (pos + bitCount) / 8, size()); + throw ByteBufferPositionException(false, (pos + bitCount) / 8, size(), (bitCount - 1) / 8 + 1); for (int32 i = 0; i < bitCount; ++i) { |
