mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/PacketIO: Use ByteBuffer from UpdateData instead of copying to it after (#28347)
This commit is contained in:
@@ -166,14 +166,14 @@ void Object::RemoveFromWorld()
|
||||
|
||||
void Object::BuildMovementUpdateBlock(UpdateData* data, uint32 flags) const
|
||||
{
|
||||
ByteBuffer buf(500);
|
||||
ByteBuffer& buf = data->GetBuffer();
|
||||
|
||||
buf << uint8(UPDATETYPE_MOVEMENT);
|
||||
buf << GetPackGUID();
|
||||
|
||||
BuildMovementUpdate(&buf, flags);
|
||||
|
||||
data->AddUpdateBlock(buf);
|
||||
data->AddUpdateBlock();
|
||||
}
|
||||
|
||||
void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const
|
||||
@@ -196,14 +196,14 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
|
||||
|
||||
//TC_LOG_DEBUG("BuildCreateUpdate: update-type: %u, object-type: %u got flags: %X, flags2: %X", updateType, m_objectTypeId, flags, flags2);
|
||||
|
||||
ByteBuffer buf(500);
|
||||
ByteBuffer& buf = data->GetBuffer();
|
||||
buf << uint8(updateType);
|
||||
buf << GetPackGUID();
|
||||
buf << uint8(m_objectTypeId);
|
||||
|
||||
BuildMovementUpdate(&buf, flags);
|
||||
BuildValuesUpdate(updateType, &buf, target);
|
||||
data->AddUpdateBlock(buf);
|
||||
data->AddUpdateBlock();
|
||||
}
|
||||
|
||||
void Object::SendUpdateToPlayer(Player* player)
|
||||
@@ -222,14 +222,14 @@ void Object::SendUpdateToPlayer(Player* player)
|
||||
|
||||
void Object::BuildValuesUpdateBlockForPlayer(UpdateData* data, Player const* target) const
|
||||
{
|
||||
ByteBuffer buf(500);
|
||||
ByteBuffer& buf = data->GetBuffer();
|
||||
|
||||
buf << uint8(UPDATETYPE_VALUES);
|
||||
buf << GetPackGUID();
|
||||
|
||||
BuildValuesUpdate(UPDATETYPE_VALUES, &buf, target);
|
||||
|
||||
data->AddUpdateBlock(buf);
|
||||
data->AddUpdateBlock();
|
||||
}
|
||||
|
||||
void Object::BuildOutOfRangeUpdateBlock(UpdateData* data) const
|
||||
|
||||
@@ -35,12 +35,6 @@ void UpdateData::AddOutOfRangeGUID(ObjectGuid guid)
|
||||
m_outOfRangeGUIDs.insert(guid);
|
||||
}
|
||||
|
||||
void UpdateData::AddUpdateBlock(ByteBuffer const& block)
|
||||
{
|
||||
m_data.append(block);
|
||||
++m_blockCount;
|
||||
}
|
||||
|
||||
void UpdateData::Compress(void* dst, uint32 *dst_size, void* src, int src_size)
|
||||
{
|
||||
z_stream c_stream;
|
||||
|
||||
@@ -62,7 +62,8 @@ class UpdateData
|
||||
|
||||
void AddOutOfRangeGUID(GuidSet& guids);
|
||||
void AddOutOfRangeGUID(ObjectGuid guid);
|
||||
void AddUpdateBlock(ByteBuffer const& block);
|
||||
void AddUpdateBlock() { ++m_blockCount; }
|
||||
ByteBuffer& GetBuffer() { return m_data; }
|
||||
bool BuildPacket(WorldPacket* packet);
|
||||
bool HasData() const { return m_blockCount > 0 || !m_outOfRangeGUIDs.empty(); }
|
||||
void Clear();
|
||||
|
||||
Reference in New Issue
Block a user