Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
SUMMARY: Bugfixes "Main menu being unordered"
Purpose of change
Describe the solution
used
std::vector
overstd::set
.Testing
Additional context
GPT told me so.
# Git bisect menu sortingYou
git bisect tells me that this diff causes the game menu entry to not be sorted correctly. what's the problem?
ChatGPT
The new code introduces a function
make_register_actions()
that wraps the originalregister_action()
code into a lambda function. This new lambda function now accepts astd::set<action_id> names
parameter and transforms that set intouilist_entry
elements. The problem is thatstd::set
is an ordered collection that sorts its elements by their natural ordering, or if a comparison function is provided, by the provided comparison function.In your diff, the
std::set
would sort theaction_id
elements by their natural ordering, which could potentially be different from the original order in the code. This might be why the game menu entries are not sorted correctly.A possible solution could be to change the
std::set<action_id> names
parameter tostd::vector<action_id> names
sincestd::vector
maintains the order of its elements. Your refactored lambda function could look like this: