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

(cherry picked from commit 81bf8de9895e050d5800a8a37316c0e6874b5e40)
This commit is contained in:
Gosha
2022-10-13 12:37:18 +02:00
committed by Shauren
parent 76631d0950
commit c1a9d7a3bc
16 changed files with 35 additions and 40 deletions
+8 -8
View File
@@ -178,14 +178,14 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
flags.CombatVictim = true;
}
ByteBuffer buf(0x400, ByteBuffer::Reserve{});
ByteBuffer& buf = data->GetBuffer();
buf << uint8(updateType);
buf << GetGUID();
buf << uint8(objectType);
BuildMovementUpdate(&buf, flags, target);
BuildValuesCreate(&buf, target);
data->AddUpdateBlock(buf);
data->AddUpdateBlock();
}
void Object::SendUpdateToPlayer(Player* player)
@@ -204,20 +204,20 @@ void Object::SendUpdateToPlayer(Player* player)
void Object::BuildValuesUpdateBlockForPlayer(UpdateData* data, Player const* target) const
{
ByteBuffer buf = PrepareValuesUpdateBuffer();
ByteBuffer& buf = PrepareValuesUpdateBuffer(data);
BuildValuesUpdate(&buf, target);
data->AddUpdateBlock(buf);
data->AddUpdateBlock();
}
void Object::BuildValuesUpdateBlockForPlayerWithFlag(UpdateData* data, UF::UpdateFieldFlag flags, Player const* target) const
{
ByteBuffer buf = PrepareValuesUpdateBuffer();
ByteBuffer& buf = PrepareValuesUpdateBuffer(data);
BuildValuesUpdateWithFlag(&buf, flags, target);
data->AddUpdateBlock(buf);
data->AddUpdateBlock();
}
void Object::BuildDestroyUpdateBlock(UpdateData* data) const
@@ -230,9 +230,9 @@ void Object::BuildOutOfRangeUpdateBlock(UpdateData* data) const
data->AddOutOfRangeGUID(GetGUID());
}
ByteBuffer Object::PrepareValuesUpdateBuffer() const
ByteBuffer& Object::PrepareValuesUpdateBuffer(UpdateData* data) const
{
ByteBuffer buffer(500, ByteBuffer::Reserve{});
ByteBuffer& buffer = data->GetBuffer();
buffer << uint8(UPDATETYPE_VALUES);
buffer << GetGUID();
return buffer;