Fix incorrect ordering of items at song select when certain sort modes are used #25888
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.
This is quite an unfortunate one, but I can't see a good way of fixing beyond a "revert" for now. Which is to say, it reverts behaviour for the sort modes which will obviously fail due to oversights, but keeps the optimisation in place for the others. Unfortunately this affects most of the commonly used sort modes.
Basically, some sort modes rely on aggregating a "max" value for each
CarouselBeatmapSet
, which is then used to sort the full carousel. The value of this "max" will change as a constraining filter is applied, since it only aggregates visible beatmaps:osu/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs
Lines 127 to 142 in 87d0bef
The optimisation applied in #25679 assumed that sorting was applied to all sets (even filtered ones), but the above smashes a hole in this theory. Here are two failing cases:
#25820
In this case, we actually need to run a full sort, specifically for the difficulty sort type. I haven't special-cased this for now, but if we ever re-apply optimisation in the future it will need to be considered.
#25820 (comment)
Carousel.UpdateBeatmapSet
– this is common when playing the beatmap as theLastPlayed
will be updatedIn this case, the beatmap will be added back to the carousel group using
BinarySearch
:osu/osu.Game/Screens/Select/Carousel/CarouselGroup.cs
Lines 44 to 52 in 44efa2c
But due to some items being hidden when the last sort was applied, the binary search will not run successfully. I believe this case can be improved with some further thinking (sort could be run more comprehensively on filtered-away sets), but another more amicable path may be to cache the aggregate max value on a
BeatmapSet
(and only invalidating when count of difficulties changes), reducing the overhead of these filter operations massively.Closes #25820.
Note that I haven't added tests for now. I might get to it later or someone else might beat me. It's not going to be easy to test either of these – one needs fake star rating changes based on ruleset, which as far as i can tell won't be easy, the other needs a test crafted specifically to break
BinarySearch
, which I couldn't make happpen on a quick attempt.