Fix MultiSpectatorScreen not continuing to results

This commit is contained in:
Dan Balasescu 2022-02-03 21:50:15 +09:00
parent 483977d5c8
commit f285060148
3 changed files with 15 additions and 8 deletions

View File

@ -215,8 +215,11 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
protected override void StartGameplay(int userId, SpectatorGameplayState spectatorGameplayState) protected override void StartGameplay(int userId, SpectatorGameplayState spectatorGameplayState)
=> instances.Single(i => i.UserId == userId).LoadScore(spectatorGameplayState.Score); => instances.Single(i => i.UserId == userId).LoadScore(spectatorGameplayState.Score);
protected override void EndGameplay(int userId) protected override void EndGameplay(int userId, SpectatorState state)
{ {
if (state.State == SpectatingUserState.Completed || state.State == SpectatingUserState.Failed)
return;
RemoveUser(userId); RemoveUser(userId);
var instance = instances.Single(i => i.UserId == userId); var instance = instances.Single(i => i.UserId == userId);

View File

@ -180,7 +180,7 @@ namespace osu.Game.Screens.Play
scheduleStart(spectatorGameplayState); scheduleStart(spectatorGameplayState);
} }
protected override void EndGameplay(int userId) protected override void EndGameplay(int userId, SpectatorState state)
{ {
scheduledStart?.Cancel(); scheduledStart?.Cancel();
immediateSpectatorGameplayState = null; immediateSpectatorGameplayState = null;

View File

@ -118,8 +118,8 @@ namespace osu.Game.Screens.Spectate
break; break;
case NotifyDictionaryChangedAction.Remove: case NotifyDictionaryChangedAction.Remove:
foreach ((int userId, _) in e.OldItems.AsNonNull()) foreach ((int userId, SpectatorState state) in e.OldItems.AsNonNull())
onUserStateRemoved(userId); onUserStateRemoved(userId, state);
break; break;
} }
} }
@ -147,7 +147,7 @@ namespace osu.Game.Screens.Spectate
} }
} }
private void onUserStateRemoved(int userId) private void onUserStateRemoved(int userId, SpectatorState state)
{ {
if (!userMap.ContainsKey(userId)) if (!userMap.ContainsKey(userId))
return; return;
@ -158,7 +158,7 @@ namespace osu.Game.Screens.Spectate
gameplayState.Score.Replay.HasReceivedAllFrames = true; gameplayState.Score.Replay.HasReceivedAllFrames = true;
gameplayStates.Remove(userId); gameplayStates.Remove(userId);
Schedule(() => EndGameplay(userId)); Schedule(() => EndGameplay(userId, state));
} }
private void updateGameplayState(int userId) private void updateGameplayState(int userId)
@ -212,7 +212,8 @@ namespace osu.Game.Screens.Spectate
/// Ends gameplay for a user. /// Ends gameplay for a user.
/// </summary> /// </summary>
/// <param name="userId">The user to end gameplay for.</param> /// <param name="userId">The user to end gameplay for.</param>
protected abstract void EndGameplay(int userId); /// <param name="state">The final user state.</param>
protected abstract void EndGameplay(int userId, SpectatorState state);
/// <summary> /// <summary>
/// Stops spectating a user. /// Stops spectating a user.
@ -220,7 +221,10 @@ namespace osu.Game.Screens.Spectate
/// <param name="userId">The user to stop spectating.</param> /// <param name="userId">The user to stop spectating.</param>
protected void RemoveUser(int userId) protected void RemoveUser(int userId)
{ {
onUserStateRemoved(userId); if (!userStates.TryGetValue(userId, out var state))
return;
onUserStateRemoved(userId, state);
users.Remove(userId); users.Remove(userId);
userMap.Remove(userId); userMap.Remove(userId);