mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-08 03:34:10 +00:00
Fix vehicle serialization during races (#1122)
* Fix vehicle serialization during races - Add missing frame stats reading - correct the inversion of rotation - correct serialization order - use proper dirty flags Tested that racers are no longer sideways on certain vertical slopes and stay in sync throughout the whole race. * Update ClientPackets.cpp * Update ClientPackets.cpp * Update VehiclePhysicsComponent.h
This commit is contained in:
@@ -136,6 +136,33 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac
|
||||
inStream.Read(angVelocity.z);
|
||||
}
|
||||
|
||||
// TODO figure out how to use these. Ignoring for now, but reading in if they exist.
|
||||
bool hasLocalSpaceInfo{};
|
||||
LWOOBJID objectId{};
|
||||
NiPoint3 localSpacePosition{};
|
||||
bool hasLinearVelocity{};
|
||||
NiPoint3 linearVelocity{};
|
||||
if (inStream.Read(hasLocalSpaceInfo) && hasLocalSpaceInfo) {
|
||||
inStream.Read(objectId);
|
||||
inStream.Read(localSpacePosition.x);
|
||||
inStream.Read(localSpacePosition.y);
|
||||
inStream.Read(localSpacePosition.z);
|
||||
if (inStream.Read(hasLinearVelocity) && hasLinearVelocity) {
|
||||
inStream.Read(linearVelocity.x);
|
||||
inStream.Read(linearVelocity.y);
|
||||
inStream.Read(linearVelocity.z);
|
||||
}
|
||||
}
|
||||
bool hasRemoteInputInfo{};
|
||||
RemoteInputInfo remoteInput{};
|
||||
|
||||
if (inStream.Read(hasRemoteInputInfo) && hasRemoteInputInfo) {
|
||||
inStream.Read(remoteInput.m_RemoteInputX);
|
||||
inStream.Read(remoteInput.m_RemoteInputY);
|
||||
inStream.Read(remoteInput.m_IsPowersliding);
|
||||
inStream.Read(remoteInput.m_IsModified);
|
||||
}
|
||||
|
||||
bool updateChar = true;
|
||||
|
||||
if (possessorComponent != nullptr) {
|
||||
@@ -150,9 +177,6 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac
|
||||
|
||||
auto* vehiclePhysicsComponent = possassableEntity->GetComponent<VehiclePhysicsComponent>();
|
||||
if (vehiclePhysicsComponent != nullptr) {
|
||||
// This is flipped for whatever reason
|
||||
rotation = NiQuaternion(rotation.z, rotation.y, rotation.x, rotation.w);
|
||||
|
||||
vehiclePhysicsComponent->SetPosition(position);
|
||||
vehiclePhysicsComponent->SetRotation(rotation);
|
||||
vehiclePhysicsComponent->SetIsOnGround(onGround);
|
||||
@@ -161,6 +185,7 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac
|
||||
vehiclePhysicsComponent->SetDirtyVelocity(velocityFlag);
|
||||
vehiclePhysicsComponent->SetAngularVelocity(angVelocity);
|
||||
vehiclePhysicsComponent->SetDirtyAngularVelocity(angVelocityFlag);
|
||||
vehiclePhysicsComponent->SetRemoteInputInfo(remoteInput);
|
||||
} else {
|
||||
// Need to get the mount's controllable physics
|
||||
auto* controllablePhysicsComponent = possassableEntity->GetComponent<ControllablePhysicsComponent>();
|
||||
|
Reference in New Issue
Block a user