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

Avoid error when siphoning from vehicle with an empty tank #47804

Merged
merged 1 commit into from
Mar 1, 2021

Conversation

wapcaplet
Copy link
Contributor

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 calling legacy_front(), and use that function in act_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 activate 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.

@anothersimulacrum anothersimulacrum added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Vehicles Vehicles, parts, mechanics & interactions labels Feb 28, 2021
src/vehicle_part.cpp Outdated Show resolved Hide resolved
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.

Add vehicle_part::contains_liquid() to check for emptiness before
calling only_item(), and use that function in act_vehicle_siphon().

Fix CleverRaven#47803
@ZhilkinSerg ZhilkinSerg merged commit 64a9290 into CleverRaven:master Mar 1, 2021
@wapcaplet wapcaplet deleted the w-suck-fuel branch March 1, 2021 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Vehicles Vehicles, parts, mechanics & interactions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Activating a hose to siphon fuel gives a debug message
4 participants