Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve player sync when exiting vehicle #2084

Merged

Conversation

Zangomangu
Copy link
Contributor

Fixes #409

Before pr: https://streamable.com/1hqzd8
Currently players are unsynced while exiting a vehicle (ie. rolling out), when they finish exiting the position is corrected by player puresync. It provides an unfair advantage to the player jumping out. Latency and vehicle speed makes it worse.

After pr: https://streamable.com/rrwul7
Players are now synced while exiting.
The fix makes the exiting player send player puresync when he is exiting and actually outside the car. This involves a few changes on the server to allow this.
The driver wont be sending vehicle puresync now, so instead he starts sending unoccupied vehicle sync.

The changes aren't backwards compatible, so should be planned for a major release.

@@ -514,21 +514,17 @@ void CClientPed::SetPosition(const CVector& vecPosition, bool bResetInterpolatio
// Don't set the actual position if we're in a vehicle
if (!GetRealOccupiedVehicle())
{
// Set it only if we're not in a vehicle or not working on getting in/out
if (!m_pOccupiedVehicle || GetVehicleInOutState() != VEHICLE_INOUT_GETTING_OUT)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check was here, because when vehicle position is updated from puresync it also updates passengers, so it would have warped him to the roof when exiting. Now we receive player puresync when exiting, we need to allow it.

for (int i = 0; i <= NUMELMS(m_pPassengers); i++)
if (CClientPed* pOccupant = GetOccupant(i))
pOccupant->SetPosition(vecPosition);
if (pOccupant->GetVehicleInOutState() != VEHICLE_INOUT_GETTING_OUT || pOccupant->GetRealOccupiedVehicle())
pOccupant->SetPosition(vecPosition);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When vehicle position is updated, we dont want to update position for peds who are exiting, because we removed the check in CClientPed::SetPosition (see above comment).


// Remove our vehicle again
if (pVehicle)
m_List.remove(pVehicle);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I put this here here (vs. sending it from CNetAPI::DoPulse), is that it must send the packets at the correct rate as remote clients expect them to come in at 400 ms or whatever the sync rate is and apply interpolation based on that.
Maybe there's a better way to achieve this.

@botder botder added this to the Next Stage milestone Feb 13, 2021
@botder botder added the enhancement New feature or request label Feb 13, 2021
@patrikjuvonen patrikjuvonen added the backwards-incompatible Should be merged after the release of 1.6.1 label Aug 30, 2021
Copy link
Contributor

@patrikjuvonen patrikjuvonen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requires more of a beta test, so didn't do much testing myself, looks good, thanks.

@patrikjuvonen patrikjuvonen merged commit e5026e7 into multitheftauto:master Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backwards-incompatible Should be merged after the release of 1.6.1 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Desync whilst exiting vehicles at high speed
3 participants