diff options
| author | Shauren <shauren.trinity@gmail.com> | 2025-10-14 13:11:41 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2025-10-14 13:11:41 +0200 |
| commit | a8f01e07d111ea14cbe843d82fbfce19f63faa12 (patch) | |
| tree | 2aca52b9b4dfa9723ec170e672e2a4ddb7481178 /src/server/game/Entities/GameObject | |
| parent | d48e97731538b01c4005cd7c73653a0f33015098 (diff) | |
Core/Entities: Merge duplicate functions calculating relative positions - remove CalculatePassengerPosition/CalculatePassengerOffset from TransportBase class
Diffstat (limited to 'src/server/game/Entities/GameObject')
| -rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 36 | ||||
| -rw-r--r-- | src/server/game/Entities/GameObject/GameObject.h | 2 |
2 files changed, 12 insertions, 26 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index d0076bc282b..b43c8c19049 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -418,12 +418,7 @@ public: void UpdatePassengerPositions() { for (WorldObject* passenger : _passengers) - { - float x, y, z, o; - passenger->m_movementInfo.transport.pos.GetPosition(x, y, z, o); - CalculatePassengerPosition(x, y, z, &o); - UpdatePassengerPosition(_owner.GetMap(), passenger, x, y, z, o, true); - } + UpdatePassengerPosition(_owner.GetMap(), passenger, _owner.GetPositionWithOffset(passenger->m_movementInfo.transport.pos), true); } uint32 GetTransportPeriod() const @@ -443,7 +438,7 @@ public: float GetTransportOrientation() const override { return _owner.GetOrientation(); } - void AddPassenger(WorldObject* passenger) override + void AddPassenger(WorldObject* passenger, Position const& offset) override { if (!_owner.IsInWorld()) return; @@ -452,6 +447,7 @@ public: { passenger->SetTransport(this); passenger->m_movementInfo.transport.guid = GetTransportGUID(); + passenger->m_movementInfo.transport.pos = offset; TC_LOG_DEBUG("entities.transport", "Object {} boarded transport {}.", passenger->GetName(), _owner.GetName()); } } @@ -471,14 +467,14 @@ public: return this; } - void CalculatePassengerPosition(float& x, float& y, float& z, float* o) const override + Position GetPositionWithOffset(Position const& offset) const override { - TransportBase::CalculatePassengerPosition(x, y, z, o, _owner.GetPositionX(), _owner.GetPositionY(), _owner.GetPositionZ(), _owner.GetOrientation()); + return _owner.GetPositionWithOffset(offset); } - void CalculatePassengerOffset(float& x, float& y, float& z, float* o) const override + Position GetPositionOffsetTo(Position const& endPos) const override { - TransportBase::CalculatePassengerOffset(x, y, z, o, _owner.GetPositionX(), _owner.GetPositionY(), _owner.GetPositionZ(), _owner.GetOrientation()); + return _owner.GetPositionOffsetTo(endPos); } int32 GetMapIdForSpawning() const override @@ -4129,22 +4125,12 @@ void GameObject::SetPathProgressForClient(float progress) m_transportPathProgress = progress; } -void GameObject::GetRespawnPosition(float &x, float &y, float &z, float* ori /* = nullptr*/) const +Position GameObject::GetRespawnPosition() const { if (m_goData) - { - if (ori) - m_goData->spawnPoint.GetPosition(x, y, z, *ori); - else - m_goData->spawnPoint.GetPosition(x, y, z); - } - else - { - if (ori) - GetPosition(x, y, z, *ori); - else - GetPosition(x, y, z); - } + return m_goData->spawnPoint; + + return GetPosition(); } TransportBase const* GameObject::ToTransportBase() const diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 582e73efd00..40c38ac3518 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -397,7 +397,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject> void SetFaction(uint32 faction) override { SetUpdateFieldValue(m_values.ModifyValue(&GameObject::m_gameObjectData).ModifyValue(&UF::GameObjectData::FactionTemplate), faction); } GameObjectModel* m_model; - void GetRespawnPosition(float &x, float &y, float &z, float* ori = nullptr) const; + Position GetRespawnPosition() const; TransportBase* ToTransportBase() { return const_cast<TransportBase*>(const_cast<GameObject const*>(this)->ToTransportBase()); } TransportBase const* ToTransportBase() const; |
