mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 23:23:18 +08:00
Inline update/addRoom in usage sites
This commit is contained in:
parent
3db0b69f92
commit
81f9442471
@ -57,11 +57,10 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
{
|
{
|
||||||
joinedRoom.Value = room;
|
joinedRoom.Value = room;
|
||||||
|
|
||||||
update(room, result);
|
AddOrUpdateRoom(result);
|
||||||
addRoom(room);
|
room.CopyFrom(result); // Also copy back to the source model, since this is likely to have been stored elsewhere.
|
||||||
|
|
||||||
RoomsUpdated?.Invoke();
|
onSuccess?.Invoke(result);
|
||||||
onSuccess?.Invoke(room);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
req.Failure += exception =>
|
req.Failure += exception =>
|
||||||
@ -119,8 +118,14 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
update(room, room);
|
foreach (var pi in room.Playlist)
|
||||||
addRoom(room);
|
pi.MapObjects(beatmaps, rulesets);
|
||||||
|
|
||||||
|
var existing = rooms.FirstOrDefault(e => e.RoomID.Value == room.RoomID.Value);
|
||||||
|
if (existing == null)
|
||||||
|
rooms.Add(room);
|
||||||
|
else
|
||||||
|
existing.CopyFrom(room);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -145,32 +150,6 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
notifyRoomsUpdated();
|
notifyRoomsUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates a local <see cref="Room"/> with a remote copy.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="local">The local <see cref="Room"/> to update.</param>
|
|
||||||
/// <param name="remote">The remote <see cref="Room"/> to update with.</param>
|
|
||||||
private void update(Room local, Room remote)
|
|
||||||
{
|
|
||||||
foreach (var pi in remote.Playlist)
|
|
||||||
pi.MapObjects(beatmaps, rulesets);
|
|
||||||
|
|
||||||
local.CopyFrom(remote);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="Room"/> to the list of available rooms.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="room">The <see cref="Room"/> to add.</param>
|
|
||||||
private void addRoom(Room room)
|
|
||||||
{
|
|
||||||
var existing = rooms.FirstOrDefault(e => e.RoomID.Value == room.RoomID.Value);
|
|
||||||
if (existing == null)
|
|
||||||
rooms.Add(room);
|
|
||||||
else
|
|
||||||
existing.CopyFrom(room);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void notifyRoomsUpdated() => Scheduler.AddOnce(() => RoomsUpdated?.Invoke());
|
private void notifyRoomsUpdated() => Scheduler.AddOnce(() => RoomsUpdated?.Invoke());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user