1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 15:33:05 +08:00

Harden and simplify logic to avoid weird issues

This commit is contained in:
Dean Herbert 2022-10-25 18:57:15 +09:00
parent 22ea9a8ab4
commit cf3bf41b49

View File

@ -118,13 +118,16 @@ namespace osu.Game.Screens.Select.Carousel
return null;
int forwardsIndex = lastSelectedIndex;
bool hasForwards;
int backwardsIndex = lastSelectedIndex;
bool hasBackwards;
while ((hasBackwards = backwardsIndex >= 0) | (hasForwards = forwardsIndex < Items.Count))
while (true)
{
bool hasBackwards = backwardsIndex >= 0 && backwardsIndex < Items.Count;
bool hasForwards = forwardsIndex < Items.Count;
if (!hasBackwards && !hasForwards)
return null;
if (hasForwards && !Items[forwardsIndex].Filtered.Value)
return Items[forwardsIndex];
@ -134,8 +137,6 @@ namespace osu.Game.Screens.Select.Carousel
forwardsIndex++;
backwardsIndex--;
}
return null;
}
protected virtual void PerformSelection()