Avoid error when siphoning from vehicle with an empty tank #47804
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
Bugfixes "Avoid error when siphoning from vehicle with an empty tank"
Purpose of change
Vehicles having an empty fuel tank or other tank were getting a debug message from
contents.legacy_front()
since they did not check for emptiness first.Fix #47803
Describe the solution
Add
vehicle_part::contains_liquid()
to check for emptiness before callinglegacy_front()
, and use that function inact_vehicle_siphon()
.Describe alternatives you've considered
There may be other code using similar logic for checking vehicle tanks which could now use
contains_liquid
instead, but I did not attempt to refactor those here.Testing
See issue for test steps. Basically, get a vehicle with one of its tanks being empty, then
a
ctivate a hose (rubber hose or garden hose) while adjacent to the vehicle.There are two use cases - a single-tank vehicle such as a Beetle, and a vehicle with multiple tanks such as a luxury RV.
Additional context
Thanks @Jamuro-g for raising the issue and @anothersimulacrum for providing code to fix it.