Core/PacketIO: Use ByteBuffer from UpdateData instead of copying to it after (#28347)

This commit is contained in:
Gosha
2022-10-11 23:18:54 +03:00
committed by GitHub
parent 0d0954b355
commit 81bf8de989
3 changed files with 8 additions and 13 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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();