mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-10 12:09:14 +01:00
Core/Packets: moved chat packet building function to packet builder class
This commit is contained in:
@@ -26,8 +26,7 @@ ByteBuffer::ByteBuffer(MessageBuffer&& buffer) : _rpos(0), _wpos(0), _bitpos(Ini
|
||||
{
|
||||
}
|
||||
|
||||
ByteBufferPositionException::ByteBufferPositionException(bool add, size_t pos,
|
||||
size_t size, size_t valueSize)
|
||||
ByteBufferPositionException::ByteBufferPositionException(bool add, size_t pos, size_t size, size_t valueSize)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
|
||||
@@ -38,8 +37,7 @@ ByteBufferPositionException::ByteBufferPositionException(bool add, size_t pos,
|
||||
message().assign(ss.str());
|
||||
}
|
||||
|
||||
ByteBufferSourceException::ByteBufferSourceException(size_t pos, size_t size,
|
||||
size_t valueSize)
|
||||
ByteBufferSourceException::ByteBufferSourceException(size_t pos, size_t size, size_t valueSize)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
|
||||
|
||||
@@ -86,13 +86,22 @@ class ByteBuffer
|
||||
}
|
||||
|
||||
ByteBuffer(ByteBuffer&& buf) : _rpos(buf._rpos), _wpos(buf._wpos),
|
||||
_bitpos(buf._bitpos), _curbitval(buf._curbitval), _storage(std::move(buf._storage)) { }
|
||||
_bitpos(buf._bitpos), _curbitval(buf._curbitval), _storage(buf.Move()) { }
|
||||
|
||||
ByteBuffer(ByteBuffer const& right) : _rpos(right._rpos), _wpos(right._wpos),
|
||||
_bitpos(right._bitpos), _curbitval(right._curbitval), _storage(right._storage) { }
|
||||
|
||||
ByteBuffer(MessageBuffer&& buffer);
|
||||
|
||||
std::vector<uint8>&& Move()
|
||||
{
|
||||
_rpos = 0;
|
||||
_wpos = 0;
|
||||
_bitpos = InitialBitPos;
|
||||
_curbitval = 0;
|
||||
return std::move(_storage);
|
||||
}
|
||||
|
||||
ByteBuffer& operator=(ByteBuffer const& right)
|
||||
{
|
||||
if (this != &right)
|
||||
@@ -107,12 +116,29 @@ class ByteBuffer
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer& operator=(ByteBuffer&& right)
|
||||
{
|
||||
if (this != &right)
|
||||
{
|
||||
_rpos = right._rpos;
|
||||
_wpos = right._wpos;
|
||||
_bitpos = right._bitpos;
|
||||
_curbitval = right._curbitval;
|
||||
_storage = right.Move();
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual ~ByteBuffer() { }
|
||||
|
||||
void clear()
|
||||
{
|
||||
_rpos = 0;
|
||||
_wpos = 0;
|
||||
_bitpos = InitialBitPos;
|
||||
_curbitval = 0;
|
||||
_storage.clear();
|
||||
_rpos = _wpos = 0;
|
||||
}
|
||||
|
||||
template <typename T> void append(T value)
|
||||
|
||||
Reference in New Issue
Block a user