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

[Bugfixes] Vehicle tanks ui fix for PR #40399 #40473

Closed
wants to merge 2 commits into from

Conversation

Resok
Copy link
Contributor

@Resok Resok commented May 12, 2020

Summary

SUMMARY: Bugfixes "Fix behavior bug with all vehicle parts being listed under 'Tanks' in vehicle interaction UI with PR #40399."

Purpose of change

In PR #40399, this fixes a vehicle display issue found while helping @KorGgenT validate the changes. The vehicle interaction UI displayed all vehicle parts as entries in the 'tanks' category.

image

Describe the solution

Currently the vehicle_display.cpp goes through all vehicle parts to look for valid categories for engines, tanks, batteries, etc. Currently it determines if it's a 'tank' by checking:

is_tank() || base.is_magazine() || is_reactor()

I first fixed the issue by changing base.is_magazine() to is_battery() but this unhooked the UI for steam engines with fuel hoppers. I then added a new function for is_fuelbunker() to also check for a magazine that is restricted to charcoal fuel type to fix this issue.

Describe alternatives you've considered

I had considered changing the default behavior of vehicle_parts being created with empty magazines but when I made this change it unhooked a lot of other things with the PR.

We could add something like a new tag or similar to designate that the magazine (which is now far more universal than it was before) is a 'fuel' type magazine and then check for this, which would allow us to pull the majority of this logic into JSON instead.

Testing

Validated that these changes don't unhook anything without Korgs changes in PR #40399 as well as that they fix the issue with the changes. Validated with about 10 different types of vehicles, as well as some custom constructed setups which contain multiple types of batteries, steam engine, and diesel engines and tanks.

Additional context

This is a quick fix to address a major bug in PR #40399 for vehicle UI.

Resok added 2 commits May 12, 2020 00:02
… 'magazine' check and instead use a new 'is_fuelbunker()' and the existing 'is_battery()' checks.
@@ -486,6 +486,11 @@ bool vehicle_part::is_battery() const
return base.is_magazine() && base.ammo_types().count( ammotype( "battery" ) );
}

bool vehicle_part::is_fuelbunker() const
{
return base.is_magazine() && base.ammo_types().count( ammotype( "charcoal" ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

No.

It's bad enough that we're special casing batteries, but this code was written to support arbitrary solid fuel and needs to continue supporting arbitrary solid fuel. Figure something else out.

@mlangsdorf mlangsdorf added <Bugfix> This is a fix for a bug (or closes open issue) Info / User Interface Game - player communication, menus, etc. Vehicles Vehicles, parts, mechanics & interactions labels May 12, 2020
@KorGgenT
Copy link
Member

in addition to what mlangsdorf said, if you want to add a commit to my PR you need to make a PR to my branch on my fork.

@KorGgenT KorGgenT closed this May 12, 2020
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) Info / User Interface Game - player communication, menus, etc. Vehicles Vehicles, parts, mechanics & interactions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants