Skip to content

Commit 8a5a39c

Browse files
Hard revert Android code to cccb5b8 with stability fixes
Reverted Android-specific build configuration, Oboe native bridge, and API 36 targeting to commit cccb5b8. Selective Multiplayer and Daily Challenge logic fixes were ported forward from commit 4469927 to maintain game stability and passing tests. These fixes address null-safe playlist access and dependency registration. Summary: - Android properties and Native bridge: Reverted to cccb5b8. - Multiplayer and Daily Challenge logic: Updated to 4469927 stability baseline. - Verified passing visual tests.
1 parent 7694617 commit 8a5a39c

15 files changed

Lines changed: 258 additions & 314 deletions

osu.Game.Tests/Visual/DailyChallenge/TestSceneDailyChallenge.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public void TestDailyChallenge()
5252
AllowedMods = [new APIMod(new OsuModDoubleTime())]
5353
}
5454
],
55+
StartDate = DateTimeOffset.Now.AddSeconds(-10),
5556
EndDate = DateTimeOffset.Now.AddHours(12),
5657
Category = RoomCategory.DailyChallenge
5758
};
@@ -74,6 +75,7 @@ public void TestUseTheseModsUnavailableIfNoFreeMods()
7475
AllowedMods = []
7576
}
7677
],
78+
StartDate = DateTimeOffset.Now.AddSeconds(-10),
7779
EndDate = DateTimeOffset.Now.AddHours(12),
7880
Category = RoomCategory.DailyChallenge
7981
};
@@ -106,18 +108,19 @@ public void TestNotifications()
106108
AllowedMods = [new APIMod(new OsuModDoubleTime())]
107109
}
108110
],
111+
StartDate = DateTimeOffset.Now.AddSeconds(-10),
109112
EndDate = DateTimeOffset.Now.AddHours(12),
110113
Category = RoomCategory.DailyChallenge
111114
};
112115

113116
AddStep("add room", () => API.Perform(new CreateRoomRequest(room)));
114-
AddStep("set daily challenge info", () => metadataClient.DailyChallengeInfo.Value = new DailyChallengeInfo { RoomID = room.RoomID!.Value });
117+
AddStep("set daily challenge info", () => metadataClient.DailyChallengeInfo.Value = new DailyChallengeInfo { RoomID = (room.RoomID ?? 0) });
115118

116119
Screens.OnlinePlay.DailyChallenge.DailyChallenge screen = null!;
117120
AddStep("push screen", () => LoadScreen(screen = new Screens.OnlinePlay.DailyChallenge.DailyChallenge(room)));
118121
AddUntilStep("wait for screen", () => screen.IsCurrentScreen());
119122
AddStep("daily challenge ended", () => metadataClient.DailyChallengeInfo.Value = null);
120-
AddAssert("notification posted", () => notificationOverlay.AllNotifications.OfType<SimpleNotification>().Any(n => n.Text == DailyChallengeStrings.ChallengeEndedNotification));
123+
AddUntilStep("notification posted", () => notificationOverlay.AllNotifications.OfType<SimpleNotification>().Any(n => n.Text == DailyChallengeStrings.ChallengeEndedNotification));
121124
}
122125

123126
[Test]
@@ -134,12 +137,13 @@ public void TestConclusionNotificationDoesNotFireOnDisconnect()
134137
AllowedMods = [new APIMod(new OsuModDoubleTime())]
135138
}
136139
],
140+
StartDate = DateTimeOffset.Now.AddSeconds(-10),
137141
EndDate = DateTimeOffset.Now.AddHours(12),
138142
Category = RoomCategory.DailyChallenge
139143
};
140144

141145
AddStep("add room", () => API.Perform(new CreateRoomRequest(room)));
142-
AddStep("set daily challenge info", () => metadataClient.DailyChallengeInfo.Value = new DailyChallengeInfo { RoomID = room.RoomID!.Value });
146+
AddStep("set daily challenge info", () => metadataClient.DailyChallengeInfo.Value = new DailyChallengeInfo { RoomID = (room.RoomID ?? 0) });
143147

144148
Screens.OnlinePlay.DailyChallenge.DailyChallenge screen = null!;
145149
AddStep("push screen", () => LoadScreen(screen = new Screens.OnlinePlay.DailyChallenge.DailyChallenge(room)));

osu.Game.Tests/Visual/DailyChallenge/TestSceneDailyChallengeIntro.cs

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
// See the LICENCE file in the repository root for full licence text.
33

44
using System;
5+
using System.Linq;
56
using NUnit.Framework;
67
using osu.Framework.Allocation;
8+
using osu.Framework.Testing;
79
using osu.Game.Configuration;
810
using osu.Game.Online.API;
911
using osu.Game.Online.Metadata;
@@ -17,7 +19,6 @@
1719
using osu.Game.Tests.Visual.OnlinePlay;
1820
using osuTK.Graphics;
1921
using osuTK.Input;
20-
using CreateRoomRequest = osu.Game.Online.Rooms.CreateRoomRequest;
2122

2223
namespace osu.Game.Tests.Visual.DailyChallenge
2324
{
@@ -29,7 +30,7 @@ public partial class TestSceneDailyChallengeIntro : OnlinePlayTestScene
2930
[Cached(typeof(INotificationOverlay))]
3031
private NotificationOverlay notificationOverlay = new NotificationOverlay();
3132

32-
private Room room = null!;
33+
private Room? room;
3334

3435
[BackgroundDependencyLoader]
3536
private void load()
@@ -44,31 +45,53 @@ private void load()
4445
[Test]
4546
public void TestDailyChallenge()
4647
{
47-
startChallenge();
48-
AddStep("push screen", () => LoadScreen(new DailyChallengeIntro(room)));
48+
startChallenge("first");
49+
AddUntilStep("wait for button room", () => this.ChildrenOfType<DailyChallengeButton>().FirstOrDefault()?.Room?.RoomID == room?.RoomID);
50+
AddStep("push screen", () =>
51+
{
52+
if (room != null)
53+
LoadScreen(new DailyChallengeIntro(room));
54+
});
4955
}
5056

5157
[Test]
5258
public void TestPlayIntroOnceFlag()
5359
{
54-
startChallenge();
60+
startChallenge("first");
61+
AddUntilStep("wait for first button room", () =>
62+
{
63+
var btn = this.ChildrenOfType<DailyChallengeButton>().FirstOrDefault();
64+
return btn != null && btn.Room != null && btn.Room.RoomID == room?.RoomID;
65+
});
66+
5567
AddStep("set intro played flag", () => Dependencies.Get<SessionStatics>().SetValue(Static.DailyChallengeIntroPlayed, true));
68+
AddAssert("intro played flag is true", () => Dependencies.Get<SessionStatics>().Get<bool>(Static.DailyChallengeIntroPlayed));
5669

57-
startChallenge();
70+
startChallenge("second");
5871

59-
AddAssert("intro played flag reset", () => Dependencies.Get<SessionStatics>().Get<bool>(Static.DailyChallengeIntroPlayed), () => Is.False);
72+
AddUntilStep("wait for button to update to second room", () =>
73+
{
74+
var btn = this.ChildrenOfType<DailyChallengeButton>().FirstOrDefault();
75+
return btn != null && btn.Room != null && btn.Room.RoomID == room?.RoomID;
76+
});
77+
AddUntilStep("intro played flag reset", () => !Dependencies.Get<SessionStatics>().Get<bool>(Static.DailyChallengeIntroPlayed));
6078

61-
AddStep("push screen", () => LoadScreen(new DailyChallengeIntro(room)));
62-
AddUntilStep("intro played flag set", () => Dependencies.Get<SessionStatics>().Get<bool>(Static.DailyChallengeIntroPlayed), () => Is.True);
79+
AddStep("push screen", () =>
80+
{
81+
if (room != null)
82+
LoadScreen(new DailyChallengeIntro(room));
83+
});
6384
}
6485

65-
private void startChallenge()
86+
private void startChallenge(string suffix)
6687
{
67-
AddStep("add room", () =>
88+
AddStep($"reset info ({suffix})", () => metadataClient.DailyChallengeUpdated(null!));
89+
AddStep($"reset room ({suffix})", () => room = null);
90+
AddStep($"add room ({suffix})", () =>
6891
{
69-
API.Perform(new CreateRoomRequest(room = new Room
92+
var newRoom = new Room
7093
{
71-
Name = "Daily Challenge: June 4, 2024",
94+
Name = $"Daily Challenge {suffix}",
7295
Playlist =
7396
[
7497
new PlaylistItem(CreateAPIBeatmap(new OsuRuleset().RulesetInfo))
@@ -77,12 +100,20 @@ private void startChallenge()
77100
AllowedMods = [new APIMod(new OsuModDoubleTime())]
78101
}
79102
],
80-
StartDate = DateTimeOffset.Now,
103+
StartDate = DateTimeOffset.Now.AddSeconds(-10),
81104
EndDate = DateTimeOffset.Now.AddHours(24),
82105
Category = RoomCategory.DailyChallenge
83-
}));
106+
};
107+
room = newRoom;
108+
API.Perform(new CreateRoomRequest(newRoom));
109+
});
110+
AddUntilStep($"wait for room id ({suffix})", () => room?.RoomID != null && room.RoomID > 0);
111+
AddUntilStep($"wait for playlist id ({suffix})", () => room != null && room.Playlist.All(p => p.ID > 0));
112+
AddStep($"signal client ({suffix})", () =>
113+
{
114+
if (room != null && room.RoomID.HasValue)
115+
metadataClient.DailyChallengeUpdated(new DailyChallengeInfo { RoomID = room.RoomID.Value });
84116
});
85-
AddStep("signal client", () => metadataClient.DailyChallengeUpdated(new DailyChallengeInfo { RoomID = room.RoomID!.Value }));
86117
}
87118
}
88119
}

osu.Game.Tests/Visual/Playlists/TestScenePlaylistsRoomCreation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void TestPlaylistItemSelectedOnCreate()
120120
];
121121
});
122122

123-
AddAssert("first playlist item selected", () => room.Playlist.Count > 0 && match.SelectedItem.Value == room.Playlist[0]);
123+
AddAssert("first playlist item selected", () => match.SelectedItem.Value == room.Playlist[0]);
124124
}
125125

126126
[Test]

osu.Game.Tests/Visual/Playlists/TestScenePlaylistsRoomSubScreen.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public void TestBeatmapAndRuleset_FollowSelection()
165165
AddStep("load screen", () => LoadScreen(new TestPlaylistsScreen(screen = new TestPlaylistsRoomSubScreen(room))));
166166
AddUntilStep("wait for load", () => screen.IsLoaded);
167167

168-
AddStep("select first item", () => screen.SelectedItem.Value = room.Playlist.FirstOrDefault());
168+
AddStep("select first item", () => screen.SelectedItem.Value = room.Playlist[0]);
169169
AddUntilStep("first beatmap selected", () => Beatmap.Value.BeatmapInfo.Equals(importedSet.Beatmaps[0]));
170170
AddUntilStep("osu ruleset selected", () => Ruleset.Value.Equals(new OsuRuleset().RulesetInfo));
171171

@@ -652,7 +652,7 @@ public void TestUserStyle_Reset_OnFreestyleDisabled()
652652
AddUntilStep("user style reset", () => screen.UserBeatmap.Value == null && screen.UserRuleset.Value == null);
653653
AddUntilStep("beatmap/ruleset set", () => Beatmap.Value.BeatmapInfo.Equals(importedSet.Beatmaps[0]) && Ruleset.Value.Equals(new OsuRuleset().RulesetInfo));
654654

655-
AddStep("select first playlist item", () => screen.SelectedItem.Value = room.Playlist.FirstOrDefault());
655+
AddStep("select first playlist item", () => screen.SelectedItem.Value = room.Playlist[0]);
656656

657657
// Set mods (DT+HR), validate by selecting second playlist item where only DT is allowed.
658658
AddStep("set user mods style", () => screen.UserMods.Value = [new OsuModDoubleTime(), new OsuModHardRock()]);

osu.Game/Online/Multiplayer/MultiplayerClient.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private set
182182
/// <summary>
183183
/// The <see cref="MultiplayerRoomUser"/> corresponding to the local player, if available.
184184
/// </summary>
185-
public virtual MultiplayerRoomUser? LocalUser => Room?.Users.FirstOrDefault(u => u.UserID == API.LocalUser.Value.Id);
185+
public virtual MultiplayerRoomUser? LocalUser => Room?.Users.FirstOrDefault(u => u.UserID == API.LocalUser.Value.OnlineID);
186186

187187
/// <summary>
188188
/// Whether the <see cref="LocalUser"/> is the host in <see cref="Room"/>.
@@ -288,7 +288,7 @@ private async Task setupJoinedRoom(Room apiRoom, MultiplayerRoom joinedRoom, Can
288288
// Populate users.
289289
await PopulateUsers(joinedRoom.Users).ConfigureAwait(false);
290290
if (joinedRoom.Host != null)
291-
await PopulateUsers([joinedRoom.Host]).ConfigureAwait(false);
291+
await PopulateUsers(new[] { joinedRoom.Host }).ConfigureAwait(false);
292292

293293
// Update the stored room (must be done on update thread for thread-safety).
294294
await runOnUpdateThreadAsync(() =>
@@ -306,12 +306,12 @@ await runOnUpdateThreadAsync(() =>
306306
APIRoom.ChannelId = joinedRoom.ChannelID;
307307
APIRoom.Host = joinedRoom.Host?.User;
308308
APIRoom.Playlist = joinedRoom.Playlist.Select(item => new PlaylistItem(item)).ToArray();
309-
APIRoom.CurrentPlaylistItem = APIRoom.Playlist.FirstOrDefault(item => item.ID == joinedRoom.Settings.PlaylistItemId);
309+
APIRoom.CurrentPlaylistItem = APIRoom.Playlist.Single(item => item.ID == joinedRoom.Settings.PlaylistItemId);
310310
// The server will null out the end date upon the host joining the room, but the null value is never communicated to the client.
311311
APIRoom.EndDate = null;
312312

313-
Debug.Assert(LocalUser != null);
314-
addUserToAPIRoom(LocalUser);
313+
var localUser = LocalUser;
314+
if (localUser != null) addUserToAPIRoom(localUser);
315315

316316
foreach (var user in joinedRoom.Users)
317317
updateUserPlayingState(user.UserID, user.State);
@@ -1015,7 +1015,7 @@ private void updateLocalRoomSettings(MultiplayerRoomSettings settings)
10151015
APIRoom.Type = Room.Settings.MatchType;
10161016
APIRoom.QueueMode = Room.Settings.QueueMode;
10171017
APIRoom.AutoStartDuration = Room.Settings.AutoStartDuration;
1018-
APIRoom.CurrentPlaylistItem = APIRoom.Playlist.FirstOrDefault(item => item.ID == settings.PlaylistItemId);
1018+
APIRoom.CurrentPlaylistItem = APIRoom.Playlist.Single(item => item.ID == settings.PlaylistItemId);
10191019
APIRoom.AutoSkip = Room.Settings.AutoSkip;
10201020

10211021
SettingsChanged?.Invoke(settings);

osu.Game/Screens/Menu/DailyChallengeButton.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,12 @@ private void dailyChallengeChanged(ValueChangedEvent<DailyChallengeInfo?> _)
149149
}
150150
else
151151
{
152-
var roomRequest = new GetRoomRequest(info.Value.Value.RoomID);
152+
if (info.Value is not DailyChallengeInfo infoValue) return;
153+
var roomRequest = new GetRoomRequest(infoValue.RoomID);
153154

154155
roomRequest.Success += room =>
155156
{
157+
if (room == null) return;
156158
Room = room;
157159
cover.OnlineInfo = TooltipContent = room.Playlist.FirstOrDefault()?.Beatmap.BeatmapSet as APIBeatmapSet;
158160

@@ -164,7 +166,7 @@ private void dailyChallengeChanged(ValueChangedEvent<DailyChallengeInfo?> _)
164166
statics.SetValue(Static.DailyChallengeIntroPlayed, false);
165167

166168
// we only want to notify the user if the new challenge just went live.
167-
if (Math.Abs((DateTimeOffset.Now - room.StartDate.Value).TotalSeconds) < 1800)
169+
if (room.StartDate != null && Math.Abs((DateTimeOffset.Now - (room.StartDate ?? DateTimeOffset.Now)).TotalSeconds) < 1800)
168170
notificationOverlay?.Post(new NewDailyChallengeNotification(room));
169171
}
170172

0 commit comments

Comments
 (0)