mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-16 08:45:27 +00:00
fix: a simple physics construction keeps pending changes for the update
LWOSimplePhysicsComponent::Deserialize (0x00be4b00) reads the velocity and the motion state each behind its own flag bit. DLU cleared both dirty flags when it wrote a construction, which goes only to the client the object came into range of, so the clients already watching it never got a change that was waiting for the next update. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -73,13 +73,14 @@ void SimplePhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bIs
|
||||
outBitStream.Write(m_Velocity);
|
||||
outBitStream.Write(m_AngularVelocity);
|
||||
}
|
||||
if (writeVelocity || bIsInitialUpdate) m_DirtyVelocity = false;
|
||||
// A construction goes to the one client the object came into range of; the others still need the change
|
||||
if (writeVelocity && !bIsInitialUpdate) m_DirtyVelocity = false;
|
||||
|
||||
// Physics motion state
|
||||
outBitStream.Write(m_DirtyPhysicsMotionState || bIsInitialUpdate);
|
||||
if (m_DirtyPhysicsMotionState || bIsInitialUpdate) {
|
||||
outBitStream.Write<uint32_t>(m_PhysicsMotionState);
|
||||
m_DirtyPhysicsMotionState = false;
|
||||
if (!bIsInitialUpdate) m_DirtyPhysicsMotionState = false;
|
||||
}
|
||||
PhysicsComponent::Serialize(outBitStream, bIsInitialUpdate);
|
||||
}
|
||||
|
||||
@@ -131,6 +131,35 @@ TEST_F(SimplePhysicsTest, SimplePhysicsConstructionTest) {
|
||||
ASSERT_EQ(rotation, NiQuaternion(1.0f, 2.0f, 3.0f, 4.0f));
|
||||
}
|
||||
|
||||
// A construction (the object coming into one player's range) doesn't use up a velocity or motion state change the
|
||||
// players already watching it still have to get. LWOSimplePhysicsComponent::Deserialize (0x00be4b00) reads each
|
||||
// behind its own flag bit.
|
||||
TEST_F(SimplePhysicsTest, AConstructionKeepsPendingChangesForTheNextUpdate) {
|
||||
RakNet::BitStream construction;
|
||||
simplePhysicsComponent->Serialize(construction, true);
|
||||
|
||||
simplePhysicsComponent->Serialize(bitStream, false);
|
||||
bool hasVelocity{};
|
||||
bitStream.Read(hasVelocity);
|
||||
ASSERT_TRUE(hasVelocity);
|
||||
NiPoint3 velocity;
|
||||
NiPoint3 angularVelocity;
|
||||
bitStream.Read(velocity);
|
||||
bitStream.Read(angularVelocity);
|
||||
EXPECT_EQ(velocity, NiPoint3(5.0f, 6.0f, 7.0f));
|
||||
bool hasMotionState{};
|
||||
bitStream.Read(hasMotionState);
|
||||
ASSERT_TRUE(hasMotionState);
|
||||
uint32_t motionState{};
|
||||
bitStream.Read(motionState);
|
||||
EXPECT_EQ(motionState, 2u);
|
||||
|
||||
// Written once
|
||||
RakNet::BitStream again;
|
||||
simplePhysicsComponent->Serialize(again, false);
|
||||
EXPECT_EQ(again.GetNumberOfBitsUsed(), 3u);
|
||||
}
|
||||
|
||||
TEST_F(SimplePhysicsTest, SimplePhysicsGettersAndSettersTest) {
|
||||
ASSERT_EQ(simplePhysicsComponent->GetClimabbleType(), eClimbableType::CLIMBABLE_TYPE_WALL);
|
||||
ASSERT_EQ(simplePhysicsComponent->GetPosition(), NiPoint3(1.0f, 2.0f, 3.0f));
|
||||
|
||||
Reference in New Issue
Block a user