From 02b21f73864a4ccff1e3f1cc2f908b16d26ce72f Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Wed, 11 Nov 2026 18:21:18 -0600 Subject: [PATCH] fix: a mover without a path is constructed as live did Live constructed movers that have no path (LOTs 2349, 9265, 9266, 12047 and others, in every capture) waiting (state 9) at waypoint 0 and at no position (0, 0, 0). The server sent them stopped (12) at the object's position. Co-Authored-By: Claude Fable 5.2 --- dGame/dComponents/MovingPlatformComponent.cpp | 16 +++++++++----- dGame/dComponents/MovingPlatformComponent.h | 4 +--- .../ReplicaConstructionTests.cpp | 22 +++++++++++++++++-- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/dGame/dComponents/MovingPlatformComponent.cpp b/dGame/dComponents/MovingPlatformComponent.cpp index 7aec9bf2d..e8f171548 100644 --- a/dGame/dComponents/MovingPlatformComponent.cpp +++ b/dGame/dComponents/MovingPlatformComponent.cpp @@ -155,9 +155,9 @@ void MovingPlatformComponent::LoadDataFromTemplate() { } m_SubComponents.push_back(std::move(simpleMover)); } else if (type == eMoverSubComponentType::rotater) { - m_SubComponents.push_back(std::make_unique(m_Parent->GetDefaultPosition())); + m_SubComponents.push_back(std::make_unique()); } else { - m_SubComponents.push_back(std::make_unique(m_Parent->GetDefaultPosition())); + m_SubComponents.push_back(std::make_unique()); } } m_MoverSubComponentType = m_SubComponents.empty() ? eMoverSubComponentType::none : m_SubComponents.front()->GetType(); @@ -236,10 +236,14 @@ void MovingPlatformComponent::SetupSimpleMover(SimpleMoverSubComponent& simpleMo } // A mover is at its starting waypoint, stopped (12, as live constructed movers nothing had started). Unless -// startPathingOnLoad is false it then waits the waypoint's wait and leaves (live: 9). +// startPathingOnLoad is false it then waits the waypoint's wait and leaves (live: 9). Live constructed a mover without +// a path waiting too (9), at waypoint 0 and at no position (0, 0, 0): it has nowhere to go. void MovingPlatformComponent::SetupMoverPath(PlatformSubComponent& mover) { mover.mPath = m_Path != nullptr && !m_Path->pathWaypoints.empty() ? m_Path : nullptr; - if (mover.mPath == nullptr) return; + if (mover.mPath == nullptr) { + if (StartsOnLoad()) StartWaiting(mover); + return; + } mover.mTimeBased = m_Path->movingPlatform.timeBasedMovement != 0; mover.mInReverse = m_PathReverse; PlatformProcessStateChange(mover, m_StartWaypoint); @@ -281,10 +285,10 @@ bool MovingPlatformComponent::SetCurrentPath(const std::string& pathName, const for (auto& subComponent : m_SubComponents) { if (subComponent->GetType() == eMoverSubComponentType::mover) { - subComponent = std::make_unique(m_Parent->GetPosition()); + subComponent = std::make_unique(); SetupMoverPath(*subComponent); } else if (subComponent->GetType() == eMoverSubComponentType::rotater) { - subComponent = std::make_unique(m_Parent->GetPosition()); + subComponent = std::make_unique(); SetupRotator(static_cast(*subComponent)); } } diff --git a/dGame/dComponents/MovingPlatformComponent.h b/dGame/dComponents/MovingPlatformComponent.h index 82717f30f..26291357e 100644 --- a/dGame/dComponents/MovingPlatformComponent.h +++ b/dGame/dComponents/MovingPlatformComponent.h @@ -97,7 +97,7 @@ public: bool mShouldStopAtDesiredWaypoint = false; // From the current waypoint (0) to the next (1) float mPercentBetweenPoints = 0; - // Where it is now: its object's position, which its linear velocity moves + // Where it is now: its object's position, which its linear velocity moves. Nowhere (0, 0, 0) without a path. NiPoint3 mPosition{}; // The linear velocity the platform gave its object when it last set off (or last looked, between waypoints of // different speeds). It is only taken away where the platform stops and at either end of the path, so through a @@ -132,7 +132,6 @@ public: */ class MoverSubComponent final : public PlatformSubComponent { public: - MoverSubComponent(const NiPoint3& startPos) { mPosition = startPos; } eMoverSubComponentType GetType() const override { return eMoverSubComponentType::mover; } }; @@ -151,7 +150,6 @@ NiPoint3 CalcRotatorAngularVelocity(float rotX, float rotY, float rotZ, float ra */ class RotatorSubComponent final : public PlatformSubComponent { public: - RotatorSubComponent(const NiPoint3& startPos) { mPosition = startPos; } eMoverSubComponentType GetType() const override { return eMoverSubComponentType::rotater; } // rotX, rotY and rotZ times pi, and rate (seconds) diff --git a/tests/dGameTests/dComponentsTests/ReplicaConstructionTests.cpp b/tests/dGameTests/dComponentsTests/ReplicaConstructionTests.cpp index d882871b5..432c2ed2a 100644 --- a/tests/dGameTests/dComponentsTests/ReplicaConstructionTests.cpp +++ b/tests/dGameTests/dComponentsTests/ReplicaConstructionTests.cpp @@ -706,8 +706,26 @@ TEST_F(ReplicaConstructionTest, MovingPlatformEndsItsSubcomponentList) { uint32_t type{}; ASSERT_TRUE(stream.Read(type)); EXPECT_EQ(type, 4u); // mover - // The mover: a 1 bit, state, desired waypoint, 2 flags, percent, position, current and next waypoint, 2 times - stream.IgnoreBits(1 + 32 + 32 + 2 + 32 + 96 + 32 + 32 + 32 + 32); + // The mover: a 1 bit, state, desired waypoint, 2 flags, percent, position, current and next waypoint, 2 times. + // Live constructed a mover without a path (this LOT among them) waiting (9) at waypoint 0, at no position. + ASSERT_TRUE(stream.Read(bit)); + EXPECT_TRUE(bit); + uint32_t state{}; + int32_t desiredWaypoint{}; + ASSERT_TRUE(stream.Read(state)); + EXPECT_EQ(state, 9u); + ASSERT_TRUE(stream.Read(desiredWaypoint)); + EXPECT_EQ(desiredWaypoint, -1); + ASSERT_TRUE(stream.Read(bit)); + EXPECT_FALSE(bit); // not stopping at the desired waypoint + ASSERT_TRUE(stream.Read(bit)); + EXPECT_FALSE(bit); // not reversing + for (int32_t i = 0; i < 8; i++) { + // percent, position, current and next waypoint, time waited and travelled: all nothing + uint32_t value{}; + ASSERT_TRUE(stream.Read(value)); + EXPECT_EQ(value, 0u); + } ASSERT_TRUE(stream.Read(bit)); EXPECT_FALSE(bit); // no more subcomponents EXPECT_EQ(stream.GetNumberOfUnreadBits(), 0u);