Fixed bug where the air drag coefficient of a vehicle isn't updated when doors are opened/closed #39761
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
SUMMARY: Bugfixes "Updates vehicle drag when door opened/closed"
Purpose of change
When a vehicle's door is opened or closed, the drag doesn't appear to change when the vehicle is examined, even though drag is supposed to be different depending on whether doors and trunks are open. This causes vehicles to appear to have much higher drag when they are loaded with open doors/trunks which are subsequently closed.
Describe the solution
Set
coeff_air_dirty=true
at the end of the functionvehicle::open_or_close()
, so thatvehicle::coeff_air_drag()
performs a full calculation, instead of just returningcoefficient_air_resistance
.Describe alternatives you've considered
I considered trying to find a more complicated solution, but decided against it, since this was a very simple solution to a fairly simple problem (and I would like to get some sleep) (this also seemed like the approach which would result in me having the least likelihood of screwing anything else up).
Testing
Recompiled game and summoned two identical vehicles. Closed all doors and trunks on both vehicles to find that they had different drag coefficients. Saved game and reloaded, after which the vehicles had the same drag coefficient. Opened doors and trunks, checked the vehicles, and found that the drag coefficients were unchanged.
Repeated this after the fix, and found that drag coefficients changed when expected to.
Additional context
Sorry if this is really scuffed. I've never done one of these before.