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

Feature: Build train locomotive filter #8733

Merged
merged 1 commit into from Mar 8, 2021
Merged

Conversation

perezdidac
Copy link
Contributor

@perezdidac perezdidac commented Feb 23, 2021

Motivation / Problem

When creating a train, there is no way of filtering by engines, given that the 'None' cargo filter removes all engines that also carry cargo, typically passengers and mail. As a player, I want to be able to see all the available engines regardless of whether they can carry cargo or not. This is especially helpful when creating passenger trains.

Description

This PR adds a new filter in the train vehicle window drop down menu so in addition to (1) any cargo, (2) no cargo, and (3) a specific cargo, players can also filter by engines only, regardless of whether they carry cargo or not.

This is how it looks, observe that some of the engines can carry passengers, like the selected one:

image

Note that

static const CargoID CF_ANY     = CT_NO_REFIT;   ///< Show all vehicles independent of carried cargo (i.e. no filtering)
static const CargoID CF_NONE    = CT_INVALID;    ///< Show only vehicles which do not carry cargo (e.g. train engines)
static const CargoID CF_ENGINES = CT_AUTO_REFIT; ///< Show only engines (for rail vehicles only)

seems a little hacky to me, so I just reused the same pattern using CT_AUTO_REFIT as there wasn't a better option.

Limitations

N/A

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

@perezdidac perezdidac marked this pull request as ready for review February 23, 2021 05:37
@perezdidac
Copy link
Contributor Author

Hi! Anyone could review? It'd be nice to add the Preview tag so people can try this out on their browser.

@LordAro LordAro added this to the 1.11.0 milestone Feb 28, 2021
src/build_vehicle_gui.cpp Outdated Show resolved Hide resolved
src/build_vehicle_gui.cpp Show resolved Hide resolved
@TrueBrain TrueBrain merged commit 6e2a96c into OpenTTD:master Mar 8, 2021
@TrueBrain
Copy link
Member

Rewrote the commit message a bit, as I couldn't make sense of "Build train locomotive filter" :D Hope you don't mind!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants