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:
parent
ed0c7e8880
commit
9fe9ea2c90
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user