mirror of
https://github.com/osukey/osukey.git
synced 2025-08-02 22:26:41 +09:00
Fix "server-side" room playlist not updated
Remove unused using
This commit is contained in:
@ -31,7 +31,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
public override IBindable<bool> IsConnected => isConnected;
|
||||
private readonly Bindable<bool> isConnected = new Bindable<bool>(true);
|
||||
|
||||
/// <summary>
|
||||
/// The local client's <see cref="Room"/>. This is not always equivalent to the server-side room.
|
||||
/// </summary>
|
||||
public new Room? APIRoom => base.APIRoom;
|
||||
|
||||
public Action<MultiplayerRoom>? RoomSetupAction;
|
||||
|
||||
public bool RoomJoined { get; private set; }
|
||||
@ -46,6 +50,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
/// </summary>
|
||||
private readonly List<MultiplayerPlaylistItem> serverSidePlaylist = new List<MultiplayerPlaylistItem>();
|
||||
|
||||
/// <summary>
|
||||
/// Guaranteed up-to-date API room.
|
||||
/// </summary>
|
||||
private Room? serverSideAPIRoom;
|
||||
|
||||
private MultiplayerPlaylistItem? currentItem => Room?.Playlist[currentIndex];
|
||||
private int currentIndex;
|
||||
private long lastPlaylistItemId;
|
||||
@ -192,13 +201,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
protected override async Task<MultiplayerRoom> JoinRoom(long roomId, string? password = null)
|
||||
{
|
||||
var apiRoom = roomManager.ServerSideRooms.Single(r => r.RoomID.Value == roomId);
|
||||
serverSideAPIRoom = roomManager.ServerSideRooms.Single(r => r.RoomID.Value == roomId);
|
||||
|
||||
if (password != apiRoom.Password.Value)
|
||||
if (password != serverSideAPIRoom.Password.Value)
|
||||
throw new InvalidOperationException("Invalid password.");
|
||||
|
||||
serverSidePlaylist.Clear();
|
||||
serverSidePlaylist.AddRange(apiRoom.Playlist.Select(item => new MultiplayerPlaylistItem(item)));
|
||||
serverSidePlaylist.AddRange(serverSideAPIRoom.Playlist.Select(item => new MultiplayerPlaylistItem(item)));
|
||||
lastPlaylistItemId = serverSidePlaylist.Max(item => item.ID);
|
||||
|
||||
var localUser = new MultiplayerRoomUser(api.LocalUser.Value.Id)
|
||||
@ -210,11 +219,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
Settings =
|
||||
{
|
||||
Name = apiRoom.Name.Value,
|
||||
MatchType = apiRoom.Type.Value,
|
||||
Name = serverSideAPIRoom.Name.Value,
|
||||
MatchType = serverSideAPIRoom.Type.Value,
|
||||
Password = password,
|
||||
QueueMode = apiRoom.QueueMode.Value,
|
||||
AutoStartDuration = apiRoom.AutoStartDuration.Value
|
||||
QueueMode = serverSideAPIRoom.QueueMode.Value,
|
||||
AutoStartDuration = serverSideAPIRoom.AutoStartDuration.Value
|
||||
},
|
||||
Playlist = serverSidePlaylist.ToList(),
|
||||
Users = { localUser },
|
||||
@ -479,6 +488,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
Debug.Assert(Room != null);
|
||||
Debug.Assert(APIRoom != null);
|
||||
Debug.Assert(serverSideAPIRoom != null);
|
||||
|
||||
var item = serverSidePlaylist.Find(i => i.ID == playlistItemId);
|
||||
|
||||
@ -495,6 +505,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
throw new InvalidOperationException("Attempted to remove an item which has already been played.");
|
||||
|
||||
serverSidePlaylist.Remove(item);
|
||||
serverSideAPIRoom.Playlist.RemoveAll(i => i.ID == item.ID);
|
||||
await ((IMultiplayerClient)this).PlaylistItemRemoved(playlistItemId).ConfigureAwait(false);
|
||||
|
||||
await updateCurrentItem(Room).ConfigureAwait(false);
|
||||
@ -576,10 +587,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
private async Task addItem(MultiplayerPlaylistItem item)
|
||||
{
|
||||
Debug.Assert(Room != null);
|
||||
Debug.Assert(serverSideAPIRoom != null);
|
||||
|
||||
item.ID = ++lastPlaylistItemId;
|
||||
|
||||
serverSidePlaylist.Add(item);
|
||||
serverSideAPIRoom.Playlist.Add(new PlaylistItem(item));
|
||||
await ((IMultiplayerClient)this).PlaylistItemAdded(item).ConfigureAwait(false);
|
||||
|
||||
await updatePlaylistOrder(Room).ConfigureAwait(false);
|
||||
@ -603,6 +616,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
private async Task updatePlaylistOrder(MultiplayerRoom room)
|
||||
{
|
||||
Debug.Assert(serverSideAPIRoom != null);
|
||||
|
||||
List<MultiplayerPlaylistItem> orderedActiveItems;
|
||||
|
||||
switch (room.Settings.QueueMode)
|
||||
@ -648,6 +663,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
await ((IMultiplayerClient)this).PlaylistItemChanged(item).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// Also ensure that the API room's playlist is correct.
|
||||
foreach (var item in serverSideAPIRoom.Playlist)
|
||||
item.PlaylistOrder = serverSidePlaylist.Single(i => i.ID == item.ID).PlaylistOrder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user