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: migrate aystar to use YAPF's nodelist infrastructure #12670

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rubidium42
Copy link
Contributor

Motivation / Problem

Both aystar and YAPF have node lists with open/closed nodes and a priority queue. Heck, they are even based on the same code because both refer to the same website for the idea. So essentially we got the same code twice.

Next to that there's manual memory management with free, malloc and friends. @PeterN suggested to call Free from the destructor, but not having that at all is even better.

Description

Replace aystar's queue/hash tables with YAPF's incantations, and remove the C-style variants.

Replace C-style array with count, with std::vector for the neighbours. After all, it allocates 12 though there can be at most 4 potential neighbours.

Limitations

There are many things that could be done better in the code, but I'd deliberately chosen to stop here and not completely rewrite the code to keep reviewing this feasible.

Think of not using void pointers for "user data" with the associated nasty casts, or using references instead of pointers.

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

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

1 participant