fixed replay

This commit is contained in:
Nikolay Korolev 2020-12-26 12:56:20 +03:00
parent 57098a77ec
commit 149aef929d

View File

@ -794,10 +794,19 @@ void CReplay::StoreBikeUpdate(CVehicle* vehicle, int id)
vp->matrix.CompressFromFullMatrix(vehicle->GetMatrix()); vp->matrix.CompressFromFullMatrix(vehicle->GetMatrix());
vp->health = vehicle->m_fHealth / 4.0f; /* Not anticipated that health can be > 1000. */ vp->health = vehicle->m_fHealth / 4.0f; /* Not anticipated that health can be > 1000. */
vp->acceleration = vehicle->m_fGasPedal * 100.0f; vp->acceleration = vehicle->m_fGasPedal * 100.0f;
#ifdef FIX_BUGS // originally it's undefined behaviour - different fields are copied on PC and mobile
for (int i = 0; i < 2; i++)
vp->wheel_rotation[i] = 128.0f / PI * bike->m_aWheelRotation[i];
for (int i = 0; i < 2; i++)
vp->wheel_rotation[i + 2] = 128.0f / PI * bike->m_aWheelSpeed[i];
for (int i = 0; i < 4; i++)
vp->wheel_susp_dist[i] = 50.0f * bike->m_aSuspensionSpringRatio[i];
#else
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
vp->wheel_susp_dist[i] = 50.0f * bike->m_aSuspensionSpringRatio[i]; vp->wheel_susp_dist[i] = 50.0f * bike->m_aSuspensionSpringRatio[i];
vp->wheel_rotation[i] = 128.0f / PI * bike->m_aWheelRotation[i]; vp->wheel_rotation[i] = 128.0f / PI * bike->m_aWheelRotation[i];
} }
#endif
vp->velocityX = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().x)); /* 8000!? */ vp->velocityX = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().x)); /* 8000!? */
vp->velocityY = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().y)); vp->velocityY = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().y));
vp->velocityZ = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().z)); vp->velocityZ = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().z));
@ -902,12 +911,19 @@ void CReplay::ProcessBikeUpdate(CVehicle* vehicle, float interpolation, CAddress
vehicle->m_vecMoveSpeed = CVector(vp->velocityX / 8000.0f, vp->velocityY / 8000.0f, vp->velocityZ / 8000.0f); vehicle->m_vecMoveSpeed = CVector(vp->velocityX / 8000.0f, vp->velocityY / 8000.0f, vp->velocityZ / 8000.0f);
vehicle->m_fSteerAngle = vp->wheel_state / 50.0f; vehicle->m_fSteerAngle = vp->wheel_state / 50.0f;
vehicle->bEngineOn = true; vehicle->bEngineOn = true;
#ifdef FIX_BUGS
for (int i = 0; i < 2; i++)
bike->m_aWheelRotation[i] = vp->wheel_rotation[i] / (128.0f / PI);
for (int i = 0; i < 2; i++)
bike->m_aWheelSpeed[i] = vp->wheel_rotation[i + 2] / (128.0f / PI);
for (int i = 0; i < 4; i++)
bike->m_aSuspensionSpringRatio[i] = vp->wheel_susp_dist[i] / 50.0f;
#else
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
bike->m_aSuspensionSpringRatio[i] = vp->wheel_susp_dist[i] / 50.0f; bike->m_aSuspensionSpringRatio[i] = vp->wheel_susp_dist[i] / 50.0f;
bike->m_aWheelRotation[i] = vp->wheel_rotation[i] / (128.0f / PI); bike->m_aWheelRotation[i] = vp->wheel_rotation[i] / (128.0f / PI);
// NB: technically last assignment overflows - there are 2 wheels of bike
// however it saves two useful fields; this looks like unrolled loop, not sequential assignments
} }
#endif
bike->m_fLeanLRAngle = vp->lean_angle / 50.0f; bike->m_fLeanLRAngle = vp->lean_angle / 50.0f;
bike->m_fWheelAngle = vp->wheel_angle / 50.0f; bike->m_fWheelAngle = vp->wheel_angle / 50.0f;
bike->bLeanMatrixClean = false; bike->bLeanMatrixClean = false;