mirror of
https://github.com/ppy/osu.git
synced 2024-11-14 16:37:26 +08:00
Merge pull request #24438 from peppy/multi-spectator-flow-fixes
Fix issues switching to new beatmap in multiplayer spectator
This commit is contained in:
commit
dc9c68b642
@ -79,6 +79,20 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddWaitStep("wait a bit", 20);
|
AddWaitStep("wait a bit", 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMultipleStartRequests()
|
||||||
|
{
|
||||||
|
int[] userIds = getPlayerIds(2);
|
||||||
|
|
||||||
|
start(userIds);
|
||||||
|
loadSpectateScreen();
|
||||||
|
|
||||||
|
sendFrames(userIds, 1000);
|
||||||
|
AddWaitStep("wait a bit", 20);
|
||||||
|
|
||||||
|
start(userIds);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestDelayedStart()
|
public void TestDelayedStart()
|
||||||
{
|
{
|
||||||
|
@ -371,9 +371,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
|
|
||||||
private void onLoadRequested()
|
private void onLoadRequested()
|
||||||
{
|
{
|
||||||
if (BeatmapAvailability.Value.State != DownloadState.LocallyAvailable)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// In the case of spectating, IMultiplayerClient.LoadRequested can be fired while the game is still spectating a previous session.
|
// In the case of spectating, IMultiplayerClient.LoadRequested can be fired while the game is still spectating a previous session.
|
||||||
// For now, we want to game to switch to the new game so need to request exiting from the play screen.
|
// For now, we want to game to switch to the new game so need to request exiting from the play screen.
|
||||||
if (!ParentScreen.IsCurrentScreen())
|
if (!ParentScreen.IsCurrentScreen())
|
||||||
@ -391,6 +388,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
if (client.LocalUser?.State == MultiplayerUserState.Spectating && (SelectedItem.Value == null || Beatmap.IsDefault))
|
if (client.LocalUser?.State == MultiplayerUserState.Spectating && (SelectedItem.Value == null || Beatmap.IsDefault))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (BeatmapAvailability.Value.State != DownloadState.LocallyAvailable)
|
||||||
|
return;
|
||||||
|
|
||||||
StartPlay();
|
StartPlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +214,20 @@ 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);
|
{
|
||||||
|
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)
|
protected override void QuitGameplay(int userId)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user