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

Codechange: be more type-specific about types in NPFs queue #11192

Merged
merged 1 commit into from
Aug 12, 2023

Conversation

TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented Aug 12, 2023

Motivation / Problem

While working on #11190 the compiler (rightfully) complained a TileIndex was shoved in an uint32_t, and it didn't like that.

Description

Turns out, all key1 references are in fact always a TileIndex, and this is assumed in several places. So be more correct, and make it in fact a TileIndex. key2 is always Trackdir. Also rename key1 and key2, as .. weird names.

And just to be clear, this queue stuff in NPF is also used by rivers. Explaining the one change in landscape.cpp.

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

@PeterN
Copy link
Member

PeterN commented Aug 12, 2023

Main question, rather than fiddling with variable types, is there a stl container that can be used instead of the custom queue?

@TrueBrain
Copy link
Member Author

Most likely, but that would take far more time than I am willing to spend on this atm :) NPF is old .. Rivers is unknown to me .. testing takes a lot of time. I rather focus on getting the strong typedef in atm :)

michicc
michicc previously approved these changes Aug 12, 2023
@PeterN
Copy link
Member

PeterN commented Aug 12, 2023

Might as well fix the type of key2 to be Trackdir as well then?

src/pathfinder/npf/npf.cpp Outdated Show resolved Hide resolved
@TrueBrain TrueBrain changed the title Codechange: be more type-specific about what type "key1" is in NPFs queue Codechange: be more type-specific about types in NPFs queue Aug 12, 2023
@TrueBrain TrueBrain enabled auto-merge (squash) August 12, 2023 17:25
@TrueBrain TrueBrain merged commit 9624017 into OpenTTD:master Aug 12, 2023
20 checks passed
@TrueBrain TrueBrain deleted the cleanup-queue-tileindex branch January 18, 2024 18:46
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