fix: PlatformResync writes its rotation w first

The client reads the rotation of a PlatformResync as w, x, y, z, and live
sent it that way (a NJ counterweight's resync began with its w). It was
written x, y, z, w, which only showed with a rotation other than none.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-11-11 18:07:42 -06:00
parent 1bcd9efa76
commit 5b35b5ceb3
3 changed files with 18 additions and 3 deletions

View File

@@ -66,10 +66,10 @@ namespace GameMessages {
const bool hasRotation = qUnexpectedRotation != QuatUtils::IDENTITY;
bitStream.Write(hasRotation);
if (hasRotation) {
bitStream.Write(qUnexpectedRotation.w);
bitStream.Write(qUnexpectedRotation.x);
bitStream.Write(qUnexpectedRotation.y);
bitStream.Write(qUnexpectedRotation.z);
bitStream.Write(qUnexpectedRotation.w);
}
}
@@ -92,10 +92,10 @@ namespace GameMessages {
VALIDATE_READ(bitStream.Read(hasRotation));
qUnexpectedRotation = QuatUtils::IDENTITY;
if (hasRotation) {
VALIDATE_READ(bitStream.Read(qUnexpectedRotation.w));
VALIDATE_READ(bitStream.Read(qUnexpectedRotation.x));
VALIDATE_READ(bitStream.Read(qUnexpectedRotation.y));
VALIDATE_READ(bitStream.Read(qUnexpectedRotation.z));
VALIDATE_READ(bitStream.Read(qUnexpectedRotation.w));
}
return true;
}

View File

@@ -64,7 +64,8 @@ namespace GameMessages {
int32_t iIndex{ 0 };
int32_t iNextIndex{ 1 };
NiPoint3 ptUnexpectedLocation{ NiPoint3Constant::ZERO };
// optional (default identity), written x, y, z, w
// optional (default identity), written w, x, y, z: the order the client reads and live sent (a NJ counterweight's
// resync began with its w, 0.936)
NiQuaternion qUnexpectedRotation{ QuatUtils::IDENTITY };
};

View File

@@ -116,6 +116,20 @@ TEST_F(RemainingMessagesTests, StartPathingAndPlatformResyncMatchLegacy) {
rotated.qUnexpectedRotation = NiQuaternion(0.5f, 0.5f, -0.5f, 0.5f);
const auto copy = RoundTrip(rotated);
EXPECT_EQ(copy.qUnexpectedRotation, rotated.qUnexpectedRotation);
// The rotation goes w first, as live sent a NJ counterweight's (w 0.936, y 0.352)
GameMessages::PlatformResync counterweight;
counterweight.qUnexpectedRotation = NiQuaternion(0.936f, 0.0f, 0.352f, 0.0f);
RakNet::BitStream stream;
counterweight.Serialize(stream);
// two flags, nine 32 bit values, the location and the flag for a rotation
stream.IgnoreBits(2 + 9 * 32 + 3 * 32 + 1);
float first{}, second{}, third{}, fourth{};
ASSERT_TRUE(stream.Read(first) && stream.Read(second) && stream.Read(third) && stream.Read(fourth));
EXPECT_FLOAT_EQ(first, 0.936f);
EXPECT_FLOAT_EQ(second, 0.0f);
EXPECT_FLOAT_EQ(third, 0.352f);
EXPECT_FLOAT_EQ(fourth, 0.0f);
}
TEST_F(RemainingMessagesTests, SmallMovementMessagesMatchLegacy) {