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 #11629: AirportGetNearestTown for rotated airports #11631

Merged
merged 1 commit into from Dec 28, 2023

Conversation

JGRennison
Copy link
Contributor

Motivation / Problem

Fix #11629.

Description

Add rotation parameter to AirportGetNearestTown, use for width/height assertions.
Add wrapper for existing stations, to reduce the number of parameters that need to be forwarded from struct Station/Airport.
Remove unnecessary iterator cloning.

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 touches english.txt or translations? Check the guidelines
  • 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, game_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

@@ -155,7 +154,7 @@
if (!as->IsWithinMapBounds(0, tile)) return INVALID_TOWN;

uint dist;
return AirportGetNearestTown(as, tile, AirportTileTableIterator(as->table[0], tile), dist)->index;
return AirportGetNearestTown(as, DIR_N, tile, AirportTileTableIterator(as->table[0], tile), dist)->index;
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct me if I'm wrong. AIs can place rotated airports. They get a list of airport types with each type repeated 4 times, one for reach rotation. Or is that how OpenGFX+ Airports 0.5.0 coded them? What happens now when an AI tries placing an airport of one of the rotated types?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Scripts can only build airports using the first layout for a given airport type.
I've adjusted it to use the corresponding rotation.

Add rotation parameter to AirportGetNearestTown
Add wrapper for existing stations
Remove unnecessary iterator cloning
@PeterN PeterN merged commit 3b18877 into OpenTTD:master Dec 28, 2023
20 checks passed
@JGRennison JGRennison deleted the fix-11629 branch January 9, 2024 19:21
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.

[Crash]: Assertion triggered when getting nearest town of rotated airport
4 participants