Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented May 9, 2020

Context

When the vehicle's memory pool reaches its limit, then the streamer needs to stream out a vehicle to make room for a new vehicle. This causes a small delay when we call warpPedIntoVehicle, and the game detects that the ped is supposed to be in a vehicle that doesn't exist, so it sets the occupied state of ped to false. When that new vehicle is finally created after the small delay, too bad the ped doesn't occupy the vehicle anymore and isn't warpped back into the vehicle.

@ghost
Copy link
Author

ghost commented May 9, 2020

Oh, it turns out #863 and #1337 are related. Should I fix it? @botder

@qaisjp qaisjp added the bug Something isn't working label May 9, 2020
Copy link
Contributor

@qaisjp qaisjp left a comment

Choose a reason for hiding this comment

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

Looks good. What if the player is being warped into a different vehicle whilst it's previous vehicle is momentarily unloaded? (Is that even possible?)

@ghost
Copy link
Author

ghost commented May 9, 2020

Looks good. What if the player is being warped into a different vehicle whilst it's previous vehicle is momentarily unloaded? (Is that even possible?)

I believe that scenario is handled by warpPedIntoVehicle function.

// Toss the previous player out of it if neccessary
if (CClientPed* pPreviousOccupant = pVehicle->GetOccupant(uiSeat))
    RemovePedFromVehicle(pPreviousOccupant);

The vehicle occupant at a specific seat is kicked out of the vehicle when warpPedIntoVehicle is called and the occupant array of the previous vehicle is updated in CClientVehicle, so if the previous vehicle streams in before the new vehicle, it won't make a difference since it won't have the occupants in the array. And finally, when the new vehicle streams in, it will go through its occupant array and warp all peds into the vehicle.

The code at the bottom of CClientGame::UpdateVehicleInOut function looks like a hack to me, and it's responsible for the bug. Someone probably tried fixing a bug and didn't realize that it caused other bugs to pop up.

If you mean actual GTA internal warp, then obviously no. GTA SA gameplay logic runs on a single thread ;d

@ghost ghost merged commit 5dd446b into multitheftauto:master May 9, 2020
@ghost ghost deleted the wrap_ped_into_vehicle_fix branch May 9, 2020 18:59
@ghost ghost added this to the 1.5.8 milestone May 9, 2020
@PlatinMTA
Copy link
Contributor

I'm gonna test tomorrow (or later) if this fixes #1337, i hope it does.

Thanks.

@ghost
Copy link
Author

ghost commented May 9, 2020

@PlatinMTA It doesn't fix #1337. I'll write a separate fix for it tomorrow.

This pull request was closed.
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

Successfully merging this pull request may close these issues.

3 participants