aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDDuarte <dnpd.dd@gmail.com>2014-09-27 22:06:34 +0100
committerDDuarte <dnpd.dd@gmail.com>2014-09-27 22:07:09 +0100
commit9b14efd6f70508a25d750bd1f131610f09bf57a9 (patch)
tree0b9a414355306a878118f74c4fc728d00f302e2b
parent295a8a8dc164878ff26a41ec8a85abf90a223530 (diff)
Core/ByteBuffer: Call FlushBits() in every append, not only on fundamental types
-rw-r--r--src/server/shared/Packets/ByteBuffer.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h
index f7d27697f24..d65b6c58a51 100644
--- a/src/server/shared/Packets/ByteBuffer.h
+++ b/src/server/shared/Packets/ByteBuffer.h
@@ -118,7 +118,6 @@ class ByteBuffer
template <typename T> void append(T value)
{
static_assert(std::is_fundamental<T>::value, "append(compound)");
- FlushBits();
EndianConvert(value);
append((uint8 *)&value, sizeof(value));
}
@@ -128,9 +127,10 @@ class ByteBuffer
if (_bitpos == 8)
return;
+ _bitpos = 8;
+
append((uint8 *)&_curbitval, sizeof(uint8));
_curbitval = 0;
- _bitpos = 8;
}
bool WriteBit(uint32 bit)
@@ -583,6 +583,8 @@ class ByteBuffer
ASSERT(size() < 10000000);
+ FlushBits();
+
if (_storage.size() < _wpos + cnt)
_storage.resize(_wpos + cnt);
std::memcpy(&_storage[_wpos], src, cnt);