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

Network trouble when calling warpPedIntoVehicle on resourceStart #475

Open
ArranTuna opened this issue Sep 16, 2018 · 3 comments
Open

Network trouble when calling warpPedIntoVehicle on resourceStart #475

ArranTuna opened this issue Sep 16, 2018 · 3 comments
Labels
bug Something isn't working
Milestone

Comments

@ArranTuna
Copy link
Collaborator

ArranTuna commented Sep 16, 2018

This issue was created by @Jusonex

Describe the bug

The code posted below leads to a network trouble. I did not test it completely, but I guess the desync is caused as follows:

  1. The following snippet from CStaticFunctionDefinitions::CreateVehicle(server) causes the vehicle to only spawn immediately if the resource has already been started:

    // Only sync if the resource has fully started
    if ( pResource->HasStarted() )
    {
        CEntityAddPacket Packet;
        Packet.Add ( pVehicle );
        m_pPlayerManager->BroadcastOnlyJoined ( Packet );
    }
  2. warpPedIntoVehicle warps the player into the vehicle that exists on the server, but not yet on the client. This causes a desync and therefore network trouble

I think a fix would require pretty much effort (i.e. queueing), but this situation happens practically never (probably mainly for debugging purposes). Therefore I think adding the same condition (CResource::HasStarted) to warpPedIntoVehicle plus a short warning message would be the most sensible way (ofc only if nobody finds a short(er) solution).

To Reproduce

addEventHandler("onResourceStart", resourceRoot,
    function()
        local vehicle = createVehicle(411, 0, 0, 5)
        warpPedIntoVehicle(getRandomPlayer(), vehicle)
    end
)

Expected behavior
No desync.

MTA Client (please complete the following information):
1.5.5-release-13192

MTA Server (please complete the following information):
1.5.5-release-13192

Additional context
From https://bugs.mtasa.com/view.php?id=7855

@ArranTuna ArranTuna added the bug Something isn't working label Sep 16, 2018
@qaisjp qaisjp added this to the Backlog milestone Sep 21, 2018
@Zangomangu
Copy link
Contributor

This issue just screwed me over for hours, because I thought I broke something.

Therefore I think adding the same condition (CResource::HasStarted) to warpPedIntoVehicle plus a short warning message would be the most sensible way (ofc only if nobody finds a short(er) solution).

I think this is a good solution. Nobody wants network trouble and a frozen game.

@lopezloo
Copy link
Member

lopezloo commented Mar 9, 2023

  1. The following snippet from CStaticFunctionDefinitions::CreateVehicle(server) causes the vehicle to only spawn immediately if the resource has already been started:

But isn't onResourceStart called after resource is fully started? If not, why not?

@Zangomangu
Copy link
Contributor

It's not started on the client at that point. onResourceStart is called before the resource is broadcast to clients, probably because it's cancellable.

So we just need to add this check, and a warning like the issue poster suggests

if (pResource->IsClientSynced())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants