mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-16 13:09:50 -04:00
Core/Objects: Refactor building SMSG_UPDATE_OBJECT to make CGObject fragment optional as well as making integrating additional entity fragments easier
This commit is contained in:
@@ -103,8 +103,16 @@ void BaseEntity::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* targe
|
||||
buf << uint32(0);
|
||||
buf << uint8(fieldFlags);
|
||||
BuildEntityFragments(&buf, m_entityFragments.GetIds());
|
||||
buf << uint8(1); // IndirectFragmentActive: CGObject
|
||||
BuildValuesCreate(&buf, fieldFlags, target);
|
||||
|
||||
for (std::size_t i = 0; i < m_entityFragments.UpdateableCount; ++i)
|
||||
{
|
||||
WowCS::EntityFragment fragmentId = m_entityFragments.Updateable.Ids[i];
|
||||
if (WowCS::IsIndirectFragment(fragmentId))
|
||||
buf << uint8(1); // IndirectFragmentActive
|
||||
|
||||
m_entityFragments.Updateable.SerializeCreate[i](this, buf, fieldFlags, target);
|
||||
}
|
||||
|
||||
buf.put<uint32>(sizePos, buf.wpos() - sizePos - 4);
|
||||
|
||||
data->AddUpdateBlock();
|
||||
@@ -140,13 +148,20 @@ void BaseEntity::BuildValuesUpdateBlockForPlayer(UpdateData* data, Player const*
|
||||
}
|
||||
buf << uint8(m_entityFragments.ContentsChangedMask);
|
||||
|
||||
BuildValuesUpdate(&buf, fieldFlags, target);
|
||||
for (std::size_t i = 0; i < m_entityFragments.UpdateableCount; ++i)
|
||||
{
|
||||
if (!(m_entityFragments.ContentsChangedMask & m_entityFragments.Updateable.Masks[i]))
|
||||
continue;
|
||||
|
||||
m_entityFragments.Updateable.SerializeUpdate[i](this, buf, fieldFlags, target);
|
||||
}
|
||||
|
||||
buf.put<uint32>(sizePos, buf.wpos() - sizePos - 4);
|
||||
|
||||
data->AddUpdateBlock();
|
||||
}
|
||||
|
||||
void BaseEntity::BuildEntityFragments(ByteBuffer* data, std::span<WowCS::EntityFragment const> fragments)
|
||||
inline void BaseEntity::BuildEntityFragments(ByteBuffer* data, std::span<WowCS::EntityFragment const> fragments)
|
||||
{
|
||||
data->append(fragments.data(), fragments.size());
|
||||
*data << uint8(WowCS::EntityFragment::End);
|
||||
@@ -635,6 +650,17 @@ void BaseEntity::ClearUpdateMask(bool remove)
|
||||
}
|
||||
}
|
||||
|
||||
void BaseEntity::BuildUpdateChangesMask()
|
||||
{
|
||||
for (std::size_t i = 0; i < m_entityFragments.UpdateableCount; ++i)
|
||||
{
|
||||
if (m_entityFragments.Updateable.IsChanged[i](this))
|
||||
m_entityFragments.ContentsChangedMask |= m_entityFragments.Updateable.Masks[i];
|
||||
else
|
||||
m_entityFragments.ContentsChangedMask &= ~m_entityFragments.Updateable.Masks[i];
|
||||
}
|
||||
}
|
||||
|
||||
void BaseEntity::BuildFieldsUpdate(Player* player, UpdateDataMapType& data_map) const
|
||||
{
|
||||
UpdateDataMapType::iterator iter = data_map.emplace(player, player->GetMapId()).first;
|
||||
|
||||
Reference in New Issue
Block a user