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: Allow converting track under trains when compatible with the new rail type #8505

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LordAro
Copy link
Member

@LordAro LordAro commented Jan 5, 2021

Motivation / Problem

Probably fixes #8314

Cherry-picked from JGRennison/OpenTTD-patches@a18ebba with some modifications due to no per-vehicle-type HasVehicleOnPos function

At the request of @markspolakovs ;)

10:51:06 <marks> > Allow converting track type under trains when compatible with the new rail type. fucken POG
10:51:19 <marks> LordAro: why is this not in core :P

Description

Allows converting track under trains when compatible with the new rail type

Limitations

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')

@frosch123 frosch123 added the preview This PR is receiving preview builds label Jan 5, 2021
@DorpsGek DorpsGek temporarily deployed to preview-pr-8505 January 5, 2021 22:02 Inactive
@frosch123
Copy link
Member

This allows converting elrail to rail, while an elrail train is on the tile.
I think it should check for "poweredness" instead.

How do road/tramtypes behave?

@DorpsGek DorpsGek temporarily deployed to preview-pr-8505 January 5, 2021 22:37 Inactive

Train *t = Train::From(v);
if (HasBit(t->First()->compatible_railtypes, procdata->type) && HasPowerOnRail(t->First()->railtype, procdata->type)) return nullptr;
if (rail_bits & TRACK_BIT_WORMHOLE) {
Copy link
Contributor

@JGRennison JGRennison Jan 5, 2021

Choose a reason for hiding this comment

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

The TRACK_BIT_WORMHOLE masking/etc is specific to the custom bridge heads implementation in my branch, so you can probably simplify this section a bit.


if (v->z_pos > procdata->z) return nullptr;
Train *t = Train::From(v)->First();
if (HasBit(t->compatible_railtypes, procdata->type) && HasPowerOnRail(t->railtype, procdata->type)) return nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

HasPowerOnRail(t->railtype, procdata->type) is not correct as this only tests the rail type of the first engine.
It's perfectly legal to create mixed power consists of compatible but not necessarily mutually powered rail types.

See the calculation of Train::compatible_railtypes in Train::ConsistChanged.

For testing you also need to note the current value of VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I did wonder. Not as simple as I thought! I'll get there... probably.

@DorpsGek DorpsGek temporarily deployed to preview-pr-8505 February 3, 2022 18:24 Inactive
@2TallTyler 2TallTyler added the work: needs more work This Pull Request needs more work before it can be accepted label Oct 27, 2022
@TrueBrain TrueBrain removed the preview This PR is receiving preview builds label Jul 8, 2023
@TrueBrain
Copy link
Member

Any chance of you continuing this patch? It sounds like a lovely idea :)

@PeterN
Copy link
Member

PeterN commented Sep 13, 2023

This already seems possible so I don't know if this is just outdated, or does something different than the existing behaviour?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
work: needs more work This Pull Request needs more work before it can be accepted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Converting railtypes under a train
7 participants