1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 21:43:04 +08:00

Fix potential crash on multiple StartGameplay calls in multiplayer spectator

This commit is contained in:
Dean Herbert 2023-08-01 19:18:18 +09:00
parent ed0c7e8880
commit 9fe9ea2c90

View File

@ -214,7 +214,20 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
}
protected override void StartGameplay(int userId, SpectatorGameplayState spectatorGameplayState)
=> instances.Single(i => i.UserId == userId).LoadScore(spectatorGameplayState.Score);
{
var playerArea = instances.Single(i => i.UserId == userId);
// The multiplayer spectator flow requires the client to return to a higher level screen
// (ie. StartGameplay should only be called once per player).
//
// Meanwhile, the solo spectator flow supports multiple `StartGameplay` calls.
// To ensure we don't crash out in an edge case where this is called more than once in multiplayer,
// guard against re-entry for the same player.
if (playerArea.Score != null)
return;
playerArea.LoadScore(spectatorGameplayState.Score);
}
protected override void QuitGameplay(int userId)
{