mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-30 01:41:40 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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<RotatorSubComponent>(m_Parent->GetDefaultPosition()));
|
||||
m_SubComponents.push_back(std::make_unique<RotatorSubComponent>());
|
||||
} else {
|
||||
m_SubComponents.push_back(std::make_unique<MoverSubComponent>(m_Parent->GetDefaultPosition()));
|
||||
m_SubComponents.push_back(std::make_unique<MoverSubComponent>());
|
||||
}
|
||||
}
|
||||
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<MoverSubComponent>(m_Parent->GetPosition());
|
||||
subComponent = std::make_unique<MoverSubComponent>();
|
||||
SetupMoverPath(*subComponent);
|
||||
} else if (subComponent->GetType() == eMoverSubComponentType::rotater) {
|
||||
subComponent = std::make_unique<RotatorSubComponent>(m_Parent->GetPosition());
|
||||
subComponent = std::make_unique<RotatorSubComponent>();
|
||||
SetupRotator(static_cast<RotatorSubComponent&>(*subComponent));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user