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

Fix #2906: warpPedIntoVehicle causes a C++ runtime assertion failure #2920

Merged
merged 13 commits into from May 18, 2023

Conversation

TracerDS
Copy link
Contributor

@TracerDS TracerDS commented Mar 9, 2023

GetMaxPassengers() returns VEHICLE_PASSENGERS_UNDEFINED if the amount of seat is undefined (this happens mainly on trailers). We can't warp player to a vehicle that doesn't have seats.
By adding this fix, server wont crash from runtime exception when warping to a vehicle that doesnt have "enough" seats


In #2918 I fixed the issue but my repo and branch got corrupted and broke the whole PR (couldnt change the commit, add or remove files). Sorry

@TracerDS TracerDS marked this pull request as ready for review March 9, 2023 09:12
@lopezloo lopezloo added the bug Something isn't working label Mar 9, 2023
@lopezloo lopezloo linked an issue Mar 9, 2023 that may be closed by this pull request
1 task
@lopezloo lopezloo changed the title Fixed issue #2906 Fix #2906 (warpPedIntoVehicle causing C++ runtime assertion failure) Mar 9, 2023
Copy link
Member

@lopezloo lopezloo left a comment

Choose a reason for hiding this comment

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

Your change disables warping to trailers at driver seat too.

How about also adding seat < MAX_VEHICLE_SEATS checks to CVehicle::SetOccupant and CPed::SetOccupiedVehicle?

@TracerDS
Copy link
Contributor Author

TracerDS commented Mar 9, 2023

That would be a good idea, I'll check it
Although trailers shouldnt be driveable anyway

@lopezloo
Copy link
Member

lopezloo commented Mar 9, 2023

Or maybe just only to CVehicle::SetOccupant() though as MAX_VEHICLE_SEATS is vehicle related definition. Not sure if adding it also to CPed::SetOccupiedVehicle() would be good coding practice.

Damn, i mismatched the sign,

Co-authored-by: lopez <7338099+lopezloo@users.noreply.github.com>
Removed seat check in CPed.cpp
Changed seat check to include values less than 0 and bigger than max passengers of a vehicle
@lopezloo
Copy link
Member

It's still not possible to warp player to driver seat in trailer vehicles like it was before. Excluding seat 0 in pVehicle->GetMaxPassengers() == VEHICLE_PASSENGERS_UNDEFINED check would fix that.

TracerDS and others added 2 commits March 22, 2023 16:40
Increased readability

Co-authored-by: lopez <7338099+lopezloo@users.noreply.github.com>
@patrikjuvonen patrikjuvonen changed the title Fix #2906 (warpPedIntoVehicle causing C++ runtime assertion failure) Fix #2906: warpPedIntoVehicle causes a C++ runtime assertion failure Apr 7, 2023
Copy link
Member

@lopezloo lopezloo 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 to me. Thank you.

@lopezloo lopezloo merged commit eba619d into multitheftauto:master May 18, 2023
6 checks passed
@patrikjuvonen patrikjuvonen added this to the 1.6.0 milestone May 18, 2023
botder pushed a commit to botder/mtasa-blue that referenced this pull request Oct 3, 2023
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.

warpPedIntoVehicle causing C++ runtime assertion failure
3 participants