1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-05 08:22:56 +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; return null;
int forwardsIndex = lastSelectedIndex; int forwardsIndex = lastSelectedIndex;
bool hasForwards;
int backwardsIndex = lastSelectedIndex; 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) if (hasForwards && !Items[forwardsIndex].Filtered.Value)
return Items[forwardsIndex]; return Items[forwardsIndex];
@ -134,8 +137,6 @@ namespace osu.Game.Screens.Select.Carousel
forwardsIndex++; forwardsIndex++;
backwardsIndex--; backwardsIndex--;
} }
return null;
} }
protected virtual void PerformSelection() protected virtual void PerformSelection()