1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 06:03:08 +08:00

Fix password not copied from multiplayer client

This commit is contained in:
smoogipoo 2021-07-19 20:20:08 +09:00
parent d6aa15e5d7
commit 2eec524f27
2 changed files with 36 additions and 14 deletions

View File

@ -105,6 +105,27 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddAssert("room has password", () => client.APIRoom?.Password.Value == "password"); AddAssert("room has password", () => client.APIRoom?.Password.Value == "password");
} }
[Test]
public void TestLocalPasswordUpdatedWhenMultiplayerSettingsChange()
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Password = { Value = "password" },
Playlist =
{
new PlaylistItem
{
Beatmap = { Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.RulesetID == 0)).BeatmapInfo },
Ruleset = { Value = new OsuRuleset().RulesetInfo },
}
}
});
AddStep("change password", () => client.ChangeSettings(password: "password2"));
AddUntilStep("local password changed", () => client.APIRoom?.Password.Value == "password2");
}
[Test] [Test]
public void TestUserSetToIdleWhenBeatmapDeleted() public void TestUserSetToIdleWhenBeatmapDeleted()
{ {

View File

@ -92,7 +92,7 @@ namespace osu.Game.Online.Multiplayer
[Resolved] [Resolved]
private UserLookupCache userLookupCache { get; set; } = null!; private UserLookupCache userLookupCache { get; set; } = null!;
private Room? apiRoom; protected Room? APIRoom { get; private set; }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
@ -139,7 +139,7 @@ namespace osu.Game.Online.Multiplayer
await scheduleAsync(() => await scheduleAsync(() =>
{ {
Room = joinedRoom; Room = joinedRoom;
apiRoom = room; APIRoom = room;
foreach (var user in joinedRoom.Users) foreach (var user in joinedRoom.Users)
updateUserPlayingState(user.UserID, user.State); updateUserPlayingState(user.UserID, user.State);
}, cancellationSource.Token).ConfigureAwait(false); }, cancellationSource.Token).ConfigureAwait(false);
@ -168,7 +168,7 @@ namespace osu.Game.Online.Multiplayer
// For example, if a room was left and the user immediately pressed the "create room" button, then the user could be taken into the lobby if the value of Room is not reset in time. // For example, if a room was left and the user immediately pressed the "create room" button, then the user could be taken into the lobby if the value of Room is not reset in time.
var scheduledReset = scheduleAsync(() => var scheduledReset = scheduleAsync(() =>
{ {
apiRoom = null; APIRoom = null;
Room = null; Room = null;
CurrentMatchPlayingUserIds.Clear(); CurrentMatchPlayingUserIds.Clear();
@ -305,22 +305,22 @@ namespace osu.Game.Online.Multiplayer
if (Room == null) if (Room == null)
return; return;
Debug.Assert(apiRoom != null); Debug.Assert(APIRoom != null);
Room.State = state; Room.State = state;
switch (state) switch (state)
{ {
case MultiplayerRoomState.Open: case MultiplayerRoomState.Open:
apiRoom.Status.Value = new RoomStatusOpen(); APIRoom.Status.Value = new RoomStatusOpen();
break; break;
case MultiplayerRoomState.Playing: case MultiplayerRoomState.Playing:
apiRoom.Status.Value = new RoomStatusPlaying(); APIRoom.Status.Value = new RoomStatusPlaying();
break; break;
case MultiplayerRoomState.Closed: case MultiplayerRoomState.Closed:
apiRoom.Status.Value = new RoomStatusEnded(); APIRoom.Status.Value = new RoomStatusEnded();
break; break;
} }
@ -381,12 +381,12 @@ namespace osu.Game.Online.Multiplayer
if (Room == null) if (Room == null)
return; return;
Debug.Assert(apiRoom != null); Debug.Assert(APIRoom != null);
var user = Room.Users.FirstOrDefault(u => u.UserID == userId); var user = Room.Users.FirstOrDefault(u => u.UserID == userId);
Room.Host = user; Room.Host = user;
apiRoom.Host.Value = user?.User; APIRoom.Host.Value = user?.User;
RoomUpdated?.Invoke(); RoomUpdated?.Invoke();
}, false); }, false);
@ -529,11 +529,12 @@ namespace osu.Game.Online.Multiplayer
if (Room == null) if (Room == null)
return; return;
Debug.Assert(apiRoom != null); Debug.Assert(APIRoom != null);
// Update a few properties of the room instantaneously. // Update a few properties of the room instantaneously.
Room.Settings = settings; Room.Settings = settings;
apiRoom.Name.Value = Room.Settings.Name; APIRoom.Name.Value = Room.Settings.Name;
APIRoom.Password.Value = Room.Settings.Password;
// The current item update is delayed until an online beatmap lookup (below) succeeds. // The current item update is delayed until an online beatmap lookup (below) succeeds.
// In-order for the client to not display an outdated beatmap, the current item is forcefully cleared here. // In-order for the client to not display an outdated beatmap, the current item is forcefully cleared here.
@ -555,7 +556,7 @@ namespace osu.Game.Online.Multiplayer
if (Room == null || !Room.Settings.Equals(settings)) if (Room == null || !Room.Settings.Equals(settings))
return; return;
Debug.Assert(apiRoom != null); Debug.Assert(APIRoom != null);
var beatmap = beatmapSet.Beatmaps.Single(b => b.OnlineBeatmapID == settings.BeatmapID); var beatmap = beatmapSet.Beatmaps.Single(b => b.OnlineBeatmapID == settings.BeatmapID);
beatmap.MD5Hash = settings.BeatmapChecksum; beatmap.MD5Hash = settings.BeatmapChecksum;
@ -565,7 +566,7 @@ namespace osu.Game.Online.Multiplayer
var allowedMods = settings.AllowedMods.Select(m => m.ToMod(ruleset)); var allowedMods = settings.AllowedMods.Select(m => m.ToMod(ruleset));
// Try to retrieve the existing playlist item from the API room. // Try to retrieve the existing playlist item from the API room.
var playlistItem = apiRoom.Playlist.FirstOrDefault(i => i.ID == settings.PlaylistItemId); var playlistItem = APIRoom.Playlist.FirstOrDefault(i => i.ID == settings.PlaylistItemId);
if (playlistItem != null) if (playlistItem != null)
updateItem(playlistItem); updateItem(playlistItem);
@ -573,7 +574,7 @@ namespace osu.Game.Online.Multiplayer
{ {
// An existing playlist item does not exist, so append a new one. // An existing playlist item does not exist, so append a new one.
updateItem(playlistItem = new PlaylistItem()); updateItem(playlistItem = new PlaylistItem());
apiRoom.Playlist.Add(playlistItem); APIRoom.Playlist.Add(playlistItem);
} }
CurrentMatchPlayingItem.Value = playlistItem; CurrentMatchPlayingItem.Value = playlistItem;