Core/GameObjects: Refactor GetPauseTimes to return std::span

This commit is contained in:
Shauren
2025-12-26 22:05:11 +01:00
parent da6db9f37e
commit df6de8c4ee
3 changed files with 13 additions and 12 deletions

View File

@@ -430,9 +430,9 @@ public:
return 1;
}
std::vector<uint32> const* GetPauseTimes() const
std::span<uint32 const> GetPauseTimes() const
{
return &_stopFrames;
return _stopFrames;
}
ObjectGuid GetTransportGUID() const override { return _owner.GetGUID(); }
@@ -4136,12 +4136,13 @@ void GameObject::ClearUpdateMask(bool remove)
Object::ClearUpdateMask(remove);
}
std::vector<uint32> const* GameObject::GetPauseTimes() const
std::span<uint32 const> GameObject::GetPauseTimes() const
{
std::span<uint32 const> result;
if (GameObjectType::Transport const* transport = dynamic_cast<GameObjectType::Transport const*>(m_goTypeImpl.get()))
return transport->GetPauseTimes();
result = transport->GetPauseTimes();
return nullptr;
return result;
}
void GameObject::SetPathProgressForClient(float progress)

View File

@@ -290,7 +290,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
void SetGoAnimProgress(uint8 animprogress) { SetUpdateFieldValue(m_values.ModifyValue(&GameObject::m_gameObjectData).ModifyValue(&UF::GameObjectData::PercentHealth), animprogress); }
static void SetGoArtKit(uint32 artkit, GameObject* go, ObjectGuid::LowType lowguid = UI64LIT(0));
std::vector<uint32> const* GetPauseTimes() const;
std::span<uint32 const> GetPauseTimes() const;
Optional<float> GetPathProgressForClient() const { return m_transportPathProgress; }
void SetPathProgressForClient(float progress);

View File

@@ -284,9 +284,9 @@ void Object::SendOutOfRangeForPlayer(Player* target) const
void Object::BuildMovementUpdate(ByteBuffer* data, CreateObjectBits flags, Player const* target) const
{
std::vector<uint32> const* PauseTimes = nullptr;
if (GameObject const* go = ToGameObject())
PauseTimes = go->GetPauseTimes();
std::span<uint32 const> PauseTimes;
if (IsGameObject())
PauseTimes = static_cast<GameObject const*>(this)->GetPauseTimes();
data->WriteBit(IsWorldObject()); // HasPositionFragment
data->WriteBit(flags.NoBirthAnim);
@@ -445,7 +445,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, CreateObjectBits flags, Playe
WorldPackets::Movement::CommonMovement::WriteCreateObjectSplineDataBlock(*unit->movespline, *data);
}
*data << uint32(PauseTimes ? PauseTimes->size() : 0);
*data << uint32(PauseTimes.size());
if (flags.Stationary)
{
@@ -498,8 +498,8 @@ void Object::BuildMovementUpdate(ByteBuffer* data, CreateObjectBits flags, Playe
// *data << uint8(AttachmentFlags);
//}
if (PauseTimes && !PauseTimes->empty())
data->append(PauseTimes->data(), PauseTimes->size());
if (!PauseTimes.empty())
data->append(PauseTimes.data(), PauseTimes.size());
if (flags.MovementTransport)
{