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

Fix #8123: trams on half-tiles couldn't find depots #8738

Merged
merged 1 commit into from Feb 25, 2021

Conversation

TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented Feb 23, 2021

Motivation / Problem

See #8123. When a tram is on a half-tile, it cannot find any depot until it leaves the tile.

Description

Basically, follow_track.hpp contains a fix for half-tiles, but
this wasn't duplicated for when trying to find a depot and in
a few other places. This makes sure all places act the same.

Because TrackBits don't know the concept of half-tiles, there is a hack in place that if GetTileTrackStatus returns zero, it checks if the tile has a single bit of tram tracks. In that case, it acts like it is a tram track going on either the X or Y axis. in follow_track.hpp there is code preventing the pathfinder from exiting the tile on the wrong side in these cases, "fixing" the path finder in believing it is a half-tile.

This worked well for normal cases, but when clicking "Goto Depot" while on a half-tile, it aborted early thinking there was no way to find a way off its current tile. There were several other cases where the source tile could be empty because it didn't carry over this fix.

Limitations

I am touching the pathfinder. Who knows what the side-effects are.

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

Copy link
Member

@LordAro LordAro left a comment

Choose a reason for hiding this comment

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

I presume you've got a good reason for not just "fixing" GetTileTrackStatus_Road. Perhaps a comment somewhere close to both that and GetTrackdirBitsForRoad explaining what's going on?

@TrueBrain
Copy link
Member Author

I presume you've got a good reason for not just "fixing" GetTileTrackStatus_Road. Perhaps a comment somewhere close to both that and GetTrackdirBitsForRoad explaining what's going on?

I added some more words in the GetTrackdirBitsForRoad to explain why GetTileTrackStatus_Road does what it does. I do not think also documenting this at GetTileTrackStatus_Road adds a benefit, but let me know if you disagree.

Basically, follow_track.hpp contains a fix for half-tiles, but
this wasn't duplicated for when trying to find a depot and in
a few other places. This makes sure all places act the same.
@TrueBrain TrueBrain merged commit d4583fa into OpenTTD:master Feb 25, 2021
@TrueBrain TrueBrain deleted the trams-lost-their-way branch February 25, 2021 21:46
@TrueBrain TrueBrain restored the trams-lost-their-way branch February 25, 2021 21:47
@TrueBrain TrueBrain deleted the trams-lost-their-way branch February 25, 2021 21:47
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

2 participants