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')
@TrueBrain TrueBrain force-pushed the TrueBrain:trams-lost-their-way branch from d3d6caf to 681ca8b Feb 23, 2021
Copy link
Member

@LordAro LordAro left a comment

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 TrueBrain force-pushed the TrueBrain:trams-lost-their-way branch from 681ca8b to 3363a1a Feb 24, 2021
@TrueBrain
Copy link
Member Author

@TrueBrain TrueBrain commented Feb 24, 2021

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 force-pushed the TrueBrain:trams-lost-their-way branch from 3363a1a to 269603a Feb 24, 2021
@TrueBrain TrueBrain merged commit d4583fa into OpenTTD:master Feb 25, 2021
11 checks passed
11 checks passed
Emscripten
Details
Commit checker
Details
Check preview needs update Check preview needs update
Details
Linux (clang, clang++, libsdl2-dev)
Details
Linux (gcc, g++, libsdl2-dev)
Details
Linux (gcc, g++, libsdl1.2-dev)
Details
Mac OS (x64, x86_64)
Details
Windows (windows-latest, x86)
Details
Windows (windows-latest, x64)
Details
Windows (windows-2016, x86) Windows (windows-2016, x86)
Details
Windows (windows-2016, x64) Windows (windows-2016, x64)
Details
@TrueBrain TrueBrain deleted the TrueBrain:trams-lost-their-way branch Feb 25, 2021
@TrueBrain TrueBrain restored the TrueBrain:trams-lost-their-way branch Feb 25, 2021
@TrueBrain TrueBrain deleted the TrueBrain:trams-lost-their-way branch Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants