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

change default entry sector value from null #1731

Merged
merged 1 commit into from
Dec 15, 2024

Conversation

jere8184
Copy link
Contributor

@jere8184 jere8184 commented Dec 11, 2024

closes #1730

@jere8184 jere8184 force-pushed the default_entry_sector_value branch from e001b7e to 309cbf2 Compare December 11, 2024 18:45
Copy link
Member

@heinezen heinezen left a comment

Choose a reason for hiding this comment

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

You should not assign 0 or any valid portal ID. If you need to have this value uninitialized at the start, use std::optional.

@jere8184
Copy link
Contributor Author

jere8184 commented Dec 12, 2024

You should not assign 0 or any valid portal ID. If you need to have this value uninitialized at the start, use std::optional.

There's not necessarily a need for it to be uninitialized. The algorithm works fine no matter the value it starts with, which is why there's also no reason for it to be initialized in the first place; any initial value you choose is meaningless.

@heinezen
Copy link
Member

There's not necessarily a need for it to be uninitialized. The algorithm works fine no matter the value it starts with, which is why there's also no reason for it to be initialized in the first place; any initial value you choose is meaningless.

This may be the case now but if we change the code and a bug is introduced that reads from the initial value 0, it might be really hard to debug since 0 is a valid ID. With std::optional, we could check for correct behavior. Using std::optional is also a good signifier to communicate that the value should be uninitialized at the start which is essentially how the initial state of the A* search is supposed to work.

@jere8184 jere8184 force-pushed the default_entry_sector_value branch from 309cbf2 to 28a6df3 Compare December 13, 2024 14:35
@jere8184 jere8184 force-pushed the default_entry_sector_value branch from 28a6df3 to 775b3f6 Compare December 14, 2024 20:22
@jere8184 jere8184 requested a review from heinezen December 14, 2024 20:23
@heinezen heinezen added lang: c++ Done in C++ code area: simulation Involved in the game mechanics and simulation bugfix Restores intended behavior kevin-rebuild-pl0x instruct kevin to rebuild this pull request labels Dec 15, 2024
@SFTbot SFTbot removed the kevin-rebuild-pl0x instruct kevin to rebuild this pull request label Dec 15, 2024
@heinezen heinezen added the kevin-rebuild-pl0x instruct kevin to rebuild this pull request label Dec 15, 2024
@SFTbot SFTbot removed the kevin-rebuild-pl0x instruct kevin to rebuild this pull request label Dec 15, 2024
Copy link
Member

@heinezen heinezen left a comment

Choose a reason for hiding this comment

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

Very good!

@heinezen heinezen added the kevin-rebuild-pl0x instruct kevin to rebuild this pull request label Dec 15, 2024
@SFTbot SFTbot removed the kevin-rebuild-pl0x instruct kevin to rebuild this pull request label Dec 15, 2024
@heinezen heinezen enabled auto-merge December 15, 2024 20:05
@heinezen heinezen merged commit 846c1fa into SFTtech:master Dec 15, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: simulation Involved in the game mechanics and simulation bugfix Restores intended behavior lang: c++ Done in C++ code
Projects
Status: ✅ Done
3 participants