mirror of
https://github.com/ppy/osu.git
synced 2025-02-05 04:52:53 +08:00
Merge pull request #12537 from smoogipoo/fix-initial-playingusers
Fix current match playing users not updated on room join
This commit is contained in:
commit
3b77d02752
@ -41,6 +41,32 @@ namespace osu.Game.Tests.NonVisual.Multiplayer
|
|||||||
checkPlayingUserCount(0);
|
checkPlayingUserCount(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestPlayingUsersUpdatedOnJoin()
|
||||||
|
{
|
||||||
|
AddStep("leave room", () => Client.LeaveRoom());
|
||||||
|
AddUntilStep("wait for room part", () => Client.Room == null);
|
||||||
|
|
||||||
|
AddStep("create room initially in gameplay", () =>
|
||||||
|
{
|
||||||
|
Room.RoomID.Value = null;
|
||||||
|
Client.RoomSetupAction = room =>
|
||||||
|
{
|
||||||
|
room.State = MultiplayerRoomState.Playing;
|
||||||
|
room.Users.Add(new MultiplayerRoomUser(55)
|
||||||
|
{
|
||||||
|
User = new User { Id = 55 },
|
||||||
|
State = MultiplayerUserState.Playing
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
RoomManager.CreateRoom(Room);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for room join", () => Client.Room != null);
|
||||||
|
checkPlayingUserCount(1);
|
||||||
|
}
|
||||||
|
|
||||||
private void checkPlayingUserCount(int expectedCount)
|
private void checkPlayingUserCount(int expectedCount)
|
||||||
=> AddAssert($"{"user".ToQuantity(expectedCount)} playing", () => Client.CurrentMatchPlayingUserIds.Count == expectedCount);
|
=> AddAssert($"{"user".ToQuantity(expectedCount)} playing", () => Client.CurrentMatchPlayingUserIds.Count == expectedCount);
|
||||||
|
|
||||||
|
@ -144,6 +144,8 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
Room = joinedRoom;
|
Room = joinedRoom;
|
||||||
apiRoom = room;
|
apiRoom = room;
|
||||||
defaultPlaylistItemId = apiRoom.Playlist.FirstOrDefault()?.ID ?? 0;
|
defaultPlaylistItemId = apiRoom.Playlist.FirstOrDefault()?.ID ?? 0;
|
||||||
|
foreach (var user in joinedRoom.Users)
|
||||||
|
updateUserPlayingState(user.UserID, user.State);
|
||||||
}, cancellationSource.Token).ConfigureAwait(false);
|
}, cancellationSource.Token).ConfigureAwait(false);
|
||||||
|
|
||||||
// Update room settings.
|
// Update room settings.
|
||||||
|
@ -25,6 +25,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
public override IBindable<bool> IsConnected => isConnected;
|
public override IBindable<bool> IsConnected => isConnected;
|
||||||
private readonly Bindable<bool> isConnected = new Bindable<bool>(true);
|
private readonly Bindable<bool> isConnected = new Bindable<bool>(true);
|
||||||
|
|
||||||
|
public Action<MultiplayerRoom>? RoomSetupAction;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; } = null!;
|
private IAPIProvider api { get; set; } = null!;
|
||||||
|
|
||||||
@ -112,7 +114,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
var apiRoom = roomManager.Rooms.Single(r => r.RoomID.Value == roomId);
|
var apiRoom = roomManager.Rooms.Single(r => r.RoomID.Value == roomId);
|
||||||
|
|
||||||
var user = new MultiplayerRoomUser(api.LocalUser.Value.Id)
|
var localUser = new MultiplayerRoomUser(api.LocalUser.Value.Id)
|
||||||
{
|
{
|
||||||
User = api.LocalUser.Value
|
User = api.LocalUser.Value
|
||||||
};
|
};
|
||||||
@ -129,10 +131,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AllowedMods = apiRoom.Playlist.Last().AllowedMods.Select(m => new APIMod(m)).ToArray(),
|
AllowedMods = apiRoom.Playlist.Last().AllowedMods.Select(m => new APIMod(m)).ToArray(),
|
||||||
PlaylistItemId = apiRoom.Playlist.Last().ID
|
PlaylistItemId = apiRoom.Playlist.Last().ID
|
||||||
},
|
},
|
||||||
Users = { user },
|
Users = { localUser },
|
||||||
Host = user
|
Host = localUser
|
||||||
};
|
};
|
||||||
|
|
||||||
|
RoomSetupAction?.Invoke(room);
|
||||||
|
RoomSetupAction = null;
|
||||||
|
|
||||||
return Task.FromResult(room);
|
return Task.FromResult(room);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user