mirror of
https://github.com/ppy/osu.git
synced 2025-01-18 05:42:56 +08:00
Fix potential index accounting mistake when creating spectator list with spectators already present
Noticed by accident, but if the `BindCollectionChanged()` callback fires
immediately in `LoadComplete()` when set up and there are spectators
present already, then `NewStartingIndex` in the related event is -1:
b03f83de36/src/libraries/System.ObjectModel/src/System/Collections/Specialized/NotifyCollectionChangedEventArgs.cs (L84-L92)
which kinda breaks the math introducing off-by-ones and in result causes
11 items to be displayed together rather than 10.
This commit is contained in:
parent
e3b780d0fb
commit
81f54507dd
@ -95,7 +95,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
for (int i = 0; i < e.NewItems!.Count; i++)
|
||||
{
|
||||
var spectator = (Spectator)e.NewItems![i]!;
|
||||
int index = e.NewStartingIndex + i;
|
||||
int index = Math.Max(e.NewStartingIndex, 0) + i;
|
||||
|
||||
if (index >= max_spectators_displayed)
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user