mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 12:43:16 +08:00
Merge pull request #10597 from bdach/fix-mania-spectator-crash
This commit is contained in:
commit
11ebd2d7f8
@ -4,6 +4,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -12,11 +13,13 @@ using osu.Framework.Input.Events;
|
||||
using osu.Framework.Input.StateChanges;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Visual.UserInterface;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
@ -33,6 +36,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private TestReplayRecorder recorder;
|
||||
|
||||
[Cached]
|
||||
private GameplayBeatmap gameplayBeatmap = new GameplayBeatmap(new Beatmap());
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
|
@ -2,17 +2,20 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Input.StateChanges;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Visual.UserInterface;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
@ -25,6 +28,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private readonly TestRulesetInputManager recordingManager;
|
||||
|
||||
[Cached]
|
||||
private GameplayBeatmap gameplayBeatmap = new GameplayBeatmap(new Beatmap());
|
||||
|
||||
public TestSceneReplayRecording()
|
||||
{
|
||||
Replay replay = new Replay();
|
||||
|
@ -27,6 +27,7 @@ using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.Replays.Types;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Visual.UserInterface;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
@ -58,6 +59,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Resolved]
|
||||
private SpectatorStreamingClient streamingClient { get; set; }
|
||||
|
||||
[Cached]
|
||||
private GameplayBeatmap gameplayBeatmap = new GameplayBeatmap(new Beatmap());
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Newtonsoft.Json;
|
||||
@ -19,6 +20,7 @@ using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.Replays.Types;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Online.Spectator
|
||||
{
|
||||
@ -44,14 +46,14 @@ namespace osu.Game.Online.Spectator
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
||||
[CanBeNull]
|
||||
private IBeatmap currentBeatmap;
|
||||
|
||||
[Resolved]
|
||||
private IBindable<RulesetInfo> ruleset { get; set; }
|
||||
private IBindable<RulesetInfo> currentRuleset { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
|
||||
private IBindable<IReadOnlyList<Mod>> currentMods { get; set; }
|
||||
|
||||
private readonly SpectatorState currentState = new SpectatorState();
|
||||
|
||||
@ -167,7 +169,7 @@ namespace osu.Game.Online.Spectator
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public void BeginPlaying()
|
||||
public void BeginPlaying(GameplayBeatmap beatmap)
|
||||
{
|
||||
if (isPlaying)
|
||||
throw new InvalidOperationException($"Cannot invoke {nameof(BeginPlaying)} when already playing");
|
||||
@ -175,10 +177,11 @@ namespace osu.Game.Online.Spectator
|
||||
isPlaying = true;
|
||||
|
||||
// transfer state at point of beginning play
|
||||
currentState.BeatmapID = beatmap.Value.BeatmapInfo.OnlineBeatmapID;
|
||||
currentState.RulesetID = ruleset.Value.ID;
|
||||
currentState.Mods = mods.Value.Select(m => new APIMod(m));
|
||||
currentState.BeatmapID = beatmap.BeatmapInfo.OnlineBeatmapID;
|
||||
currentState.RulesetID = currentRuleset.Value.ID;
|
||||
currentState.Mods = currentMods.Value.Select(m => new APIMod(m));
|
||||
|
||||
currentBeatmap = beatmap.PlayableBeatmap;
|
||||
beginPlaying();
|
||||
}
|
||||
|
||||
@ -201,6 +204,7 @@ namespace osu.Game.Online.Spectator
|
||||
public void EndPlaying()
|
||||
{
|
||||
isPlaying = false;
|
||||
currentBeatmap = null;
|
||||
|
||||
if (!isConnected) return;
|
||||
|
||||
@ -247,7 +251,7 @@ namespace osu.Game.Online.Spectator
|
||||
public void HandleFrame(ReplayFrame frame)
|
||||
{
|
||||
if (frame is IConvertibleReplayFrame convertible)
|
||||
pendingFrames.Enqueue(convertible.ToLegacy(beatmap.Value.Beatmap));
|
||||
pendingFrames.Enqueue(convertible.ToLegacy(currentBeatmap));
|
||||
|
||||
if (pendingFrames.Count > max_pending_frames)
|
||||
purgePendingFrames();
|
||||
|
@ -5,15 +5,14 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.Spectator;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Screens.Play;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.UI
|
||||
@ -33,7 +32,7 @@ namespace osu.Game.Rulesets.UI
|
||||
private SpectatorStreamingClient spectatorStreaming { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
||||
private GameplayBeatmap gameplayBeatmap { get; set; }
|
||||
|
||||
protected ReplayRecorder(Replay target)
|
||||
{
|
||||
@ -50,7 +49,7 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
inputManager = GetContainingInputManager();
|
||||
|
||||
spectatorStreaming?.BeginPlaying();
|
||||
spectatorStreaming?.BeginPlaying(gameplayBeatmap);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
|
Loading…
Reference in New Issue
Block a user