-
Notifications
You must be signed in to change notification settings - Fork 37
fix: 🐛 Transitive Comparator for script sorting #277
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
Conversation
The current algorithm returns a random result unless a is in b's type hierarchy. Random results are disallowed in the sort_custom API https://docs.godotengine.org/en/3.5/classes/class_array.html?highlight=sort_custom The new algorithm sorts alphabetically by names in the type hierarchy paths until one of the trees stop then it sorts the shorter tree first. Aims to fix the following errors that gets spammed at startup (and i think causes startup crashes): E 0:00:00.815 SortArray<class Variant,struct _ArrayVariantSortCustom,1>::partitioner: bad comparison function; sorting will be broken <C++ Source> .\core/sort_array.h:179 @ SortArray<class Variant,struct _ArrayVariantSortCustom,1>::partitioner() <Stack Trace> script_extension.gd:39 @ handle_script_extensions() mod_loader.gd:164 @ _load_mods() mod_loader.gd:67 @ _init()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thank you for the contribution 😃
Comparing the stacks looks wrong at first glance since it just compares the scripts at the same index in the stack, but with push_front
it starts to make sense. Both stacks start after the native Godot classes and work up from there. No matter where both stacks would go apart, they will always arrive at the same vanilla script at the same time.
On that note - I assume get_base_script
does not return Godot classes, right? Otherwise it could cause issues
Another thing: The code does not use ModLoaderStore.loaded_vanilla_parents_cache.keys()
anymore. I think this was the only place where it was used, so it can be removed from the store and also where it is updated. Please have a look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocked until the bug we discussed on discord is fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
important fix, thank you 👍
The current algorithm returns a random result unless a is in b's type hierarchy. Random results are disallowed in the sort_custom API
https://docs.godotengine.org/en/3.5/classes/class_array.html?highlight=sort_custom
The new algorithm sorts alphabetically by names in the type hierarchy paths until one of the trees stop then it sorts the shorter tree first.
Aims to fix the following errors that gets spammed at startup (and i think causes startup crashes):
E 0:00:00.815 SortArray<class Variant,struct _ArrayVariantSortCustom,1>::partitioner: bad comparison function; sorting will be broken
<C++ Source> .\core/sort_array.h:179 @ SortArray<class Variant,struct _ArrayVariantSortCustom,1>::partitioner()
script_extension.gd:39 @ handle_script_extensions()
mod_loader.gd:164 @ _load_mods()
mod_loader.gd:67 @ _init()