aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared
diff options
context:
space:
mode:
authorSovak <Sovak007@gmail.com>2012-09-02 12:17:38 +0200
committerShauren <shauren.trinity@gmail.com>2012-09-02 12:17:38 +0200
commit13e1e2361170c6e4a1fb5bcddc21b007d8681352 (patch)
treec2dd220b88563ecff7e136f66effab535ea22bbf /src/server/shared
parent2e1de60593fda0c1ad766fb0333a1992b17c35b9 (diff)
Core/Battlegrounds: More battleground fixes
Signed-off-by: Shauren <shauren.trinity@gmail.com>
Diffstat (limited to 'src/server/shared')
-rwxr-xr-xsrc/server/shared/Packets/ByteBuffer.h9
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)
{