Update null fallback cases involving OnlineID

This commit is contained in:
Dean Herbert 2021-11-22 14:55:41 +09:00
parent 37673f4cf8
commit 213d89b479
12 changed files with 20 additions and 20 deletions

View File

@ -237,7 +237,7 @@ namespace osu.Game.Tests.Visual.Gameplay
createPlayerTest(false, r => createPlayerTest(false, r =>
{ {
var beatmap = createTestBeatmap(r); var beatmap = createTestBeatmap(r);
beatmap.BeatmapInfo.OnlineID = null; beatmap.BeatmapInfo.OnlineID = -1;
return beatmap; return beatmap;
}); });

View File

@ -62,7 +62,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("import beatmap", () => AddStep("import beatmap", () =>
{ {
importedBeatmap = ImportBeatmapTest.LoadOszIntoOsu(game, virtualTrack: true).GetResultSafely(); importedBeatmap = ImportBeatmapTest.LoadOszIntoOsu(game, virtualTrack: true).GetResultSafely();
importedBeatmapId = importedBeatmap.Beatmaps.First(b => b.RulesetID == 0).OnlineID ?? -1; importedBeatmapId = importedBeatmap.Beatmaps.First(b => b.RulesetID == 0).OnlineID;
}); });
} }

View File

@ -49,7 +49,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
importedSet = ImportBeatmapTest.LoadOszIntoOsu(game, virtualTrack: true).GetResultSafely(); importedSet = ImportBeatmapTest.LoadOszIntoOsu(game, virtualTrack: true).GetResultSafely();
importedBeatmap = importedSet.Beatmaps.First(b => b.RulesetID == 0); importedBeatmap = importedSet.Beatmaps.First(b => b.RulesetID == 0);
importedBeatmapId = importedBeatmap.OnlineID ?? -1; importedBeatmapId = importedBeatmap.OnlineID;
} }
[SetUp] [SetUp]

View File

@ -58,7 +58,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
foreach (int user in users) foreach (int user in users)
{ {
SpectatorClient.StartPlay(user, Beatmap.Value.BeatmapInfo.OnlineID ?? 0); SpectatorClient.StartPlay(user, Beatmap.Value.BeatmapInfo.OnlineID);
multiplayerUsers.Add(OnlinePlayDependencies.Client.AddUser(new APIUser { Id = user }, true)); multiplayerUsers.Add(OnlinePlayDependencies.Client.AddUser(new APIUser { Id = user }, true));
} }

View File

@ -62,7 +62,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
foreach (int user in users) foreach (int user in users)
{ {
SpectatorClient.StartPlay(user, Beatmap.Value.BeatmapInfo.OnlineID ?? 0); SpectatorClient.StartPlay(user, Beatmap.Value.BeatmapInfo.OnlineID);
var roomUser = OnlinePlayDependencies.Client.AddUser(new APIUser { Id = user }, true); var roomUser = OnlinePlayDependencies.Client.AddUser(new APIUser { Id = user }, true);
roomUser.MatchState = new TeamVersusUserState roomUser.MatchState = new TeamVersusUserState

View File

@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
PlaylistItem playlistItem = new PlaylistItem PlaylistItem playlistItem = new PlaylistItem
{ {
BeatmapID = beatmapInfo.OnlineID ?? -1, BeatmapID = beatmapInfo.OnlineID,
}; };
Stack.Push(screen = new MultiplayerResultsScreen(score, 1, playlistItem)); Stack.Push(screen = new MultiplayerResultsScreen(score, 1, playlistItem));

View File

@ -28,7 +28,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
PlaylistItem playlistItem = new PlaylistItem PlaylistItem playlistItem = new PlaylistItem
{ {
BeatmapID = beatmapInfo.OnlineID ?? -1, BeatmapID = beatmapInfo.OnlineID,
}; };
SortedDictionary<int, BindableInt> teamScores = new SortedDictionary<int, BindableInt> SortedDictionary<int, BindableInt> teamScores = new SortedDictionary<int, BindableInt>

View File

@ -101,7 +101,7 @@ namespace osu.Game.Beatmaps
{ {
if (beatmapSet.OnlineID != null) if (beatmapSet.OnlineID != null)
{ {
beatmapSet.OnlineID = null; beatmapSet.OnlineID = -1;
LogForModel(beatmapSet, "Disassociating beatmap set ID due to loss of all beatmap IDs"); LogForModel(beatmapSet, "Disassociating beatmap set ID due to loss of all beatmap IDs");
} }
} }
@ -122,9 +122,9 @@ namespace osu.Game.Beatmaps
Delete(existingSetWithSameOnlineID); Delete(existingSetWithSameOnlineID);
// in order to avoid a unique key constraint, immediately remove the online ID from the previous set. // in order to avoid a unique key constraint, immediately remove the online ID from the previous set.
existingSetWithSameOnlineID.OnlineID = null; existingSetWithSameOnlineID.OnlineID = -1;
foreach (var b in existingSetWithSameOnlineID.Beatmaps) foreach (var b in existingSetWithSameOnlineID.Beatmaps)
b.OnlineID = null; b.OnlineID = -1;
LogForModel(beatmapSet, $"Found existing beatmap set with same OnlineBeatmapSetID ({beatmapSet.OnlineID}). It has been deleted."); LogForModel(beatmapSet, $"Found existing beatmap set with same OnlineBeatmapSetID ({beatmapSet.OnlineID}). It has been deleted.");
} }
@ -159,7 +159,7 @@ namespace osu.Game.Beatmaps
} }
} }
void resetIds() => beatmapSet.Beatmaps.ForEach(b => b.OnlineID = null); void resetIds() => beatmapSet.Beatmaps.ForEach(b => b.OnlineID = -1);
} }
/// <summary> /// <summary>

View File

@ -103,7 +103,7 @@ namespace osu.Game.Beatmaps
void fail(Exception e) void fail(Exception e)
{ {
beatmapInfo.OnlineID = null; beatmapInfo.OnlineID = -1;
logForModel(set, $"Online retrieval failed for {beatmapInfo} ({e.Message})"); logForModel(set, $"Online retrieval failed for {beatmapInfo} ({e.Message})");
} }
} }
@ -161,7 +161,7 @@ namespace osu.Game.Beatmaps
if (string.IsNullOrEmpty(beatmapInfo.MD5Hash) if (string.IsNullOrEmpty(beatmapInfo.MD5Hash)
&& string.IsNullOrEmpty(beatmapInfo.Path) && string.IsNullOrEmpty(beatmapInfo.Path)
&& beatmapInfo.OnlineID == null) && beatmapInfo.OnlineID <= 0)
return false; return false;
try try
@ -175,7 +175,7 @@ namespace osu.Game.Beatmaps
cmd.CommandText = "SELECT beatmapset_id, beatmap_id, approved, user_id FROM osu_beatmaps WHERE checksum = @MD5Hash OR beatmap_id = @OnlineID OR filename = @Path"; cmd.CommandText = "SELECT beatmapset_id, beatmap_id, approved, user_id FROM osu_beatmaps WHERE checksum = @MD5Hash OR beatmap_id = @OnlineID OR filename = @Path";
cmd.Parameters.Add(new SqliteParameter("@MD5Hash", beatmapInfo.MD5Hash)); cmd.Parameters.Add(new SqliteParameter("@MD5Hash", beatmapInfo.MD5Hash));
cmd.Parameters.Add(new SqliteParameter("@OnlineID", beatmapInfo.OnlineID ?? (object)DBNull.Value)); cmd.Parameters.Add(new SqliteParameter("@OnlineID", beatmapInfo.OnlineID));
cmd.Parameters.Add(new SqliteParameter("@Path", beatmapInfo.Path)); cmd.Parameters.Add(new SqliteParameter("@Path", beatmapInfo.Path));
using (var reader = cmd.ExecuteReader()) using (var reader = cmd.ExecuteReader())

View File

@ -133,8 +133,8 @@ namespace osu.Game.Beatmaps.Formats
writer.WriteLine(FormattableString.Invariant($"Version: {beatmap.BeatmapInfo.DifficultyName}")); writer.WriteLine(FormattableString.Invariant($"Version: {beatmap.BeatmapInfo.DifficultyName}"));
if (!string.IsNullOrEmpty(beatmap.Metadata.Source)) writer.WriteLine(FormattableString.Invariant($"Source: {beatmap.Metadata.Source}")); if (!string.IsNullOrEmpty(beatmap.Metadata.Source)) writer.WriteLine(FormattableString.Invariant($"Source: {beatmap.Metadata.Source}"));
if (!string.IsNullOrEmpty(beatmap.Metadata.Tags)) writer.WriteLine(FormattableString.Invariant($"Tags: {beatmap.Metadata.Tags}")); if (!string.IsNullOrEmpty(beatmap.Metadata.Tags)) writer.WriteLine(FormattableString.Invariant($"Tags: {beatmap.Metadata.Tags}"));
if (beatmap.BeatmapInfo.OnlineID != null) writer.WriteLine(FormattableString.Invariant($"BeatmapID: {beatmap.BeatmapInfo.OnlineID}")); if (beatmap.BeatmapInfo.OnlineID > 0) writer.WriteLine(FormattableString.Invariant($"BeatmapID: {beatmap.BeatmapInfo.OnlineID}"));
if (beatmap.BeatmapInfo.BeatmapSet?.OnlineID != null) writer.WriteLine(FormattableString.Invariant($"BeatmapSetID: {beatmap.BeatmapInfo.BeatmapSet.OnlineID}")); if (beatmap.BeatmapInfo.BeatmapSet?.OnlineID > 0) writer.WriteLine(FormattableString.Invariant($"BeatmapSetID: {beatmap.BeatmapInfo.BeatmapSet.OnlineID}"));
} }
private void handleDifficulty(TextWriter writer) private void handleDifficulty(TextWriter writer)

View File

@ -238,8 +238,8 @@ namespace osu.Game.Screens.Select.Carousel
if (editRequested != null) if (editRequested != null)
items.Add(new OsuMenuItem("Edit", MenuItemType.Standard, () => editRequested(beatmapInfo))); items.Add(new OsuMenuItem("Edit", MenuItemType.Standard, () => editRequested(beatmapInfo)));
if (beatmapInfo.OnlineID.HasValue && beatmapOverlay != null) if (beatmapInfo.OnlineID > 0 && beatmapOverlay != null)
items.Add(new OsuMenuItem("Details...", MenuItemType.Standard, () => beatmapOverlay.FetchAndShowBeatmap(beatmapInfo.OnlineID.Value))); items.Add(new OsuMenuItem("Details...", MenuItemType.Standard, () => beatmapOverlay.FetchAndShowBeatmap(beatmapInfo.OnlineID)));
if (collectionManager != null) if (collectionManager != null)
{ {

View File

@ -240,7 +240,7 @@ namespace osu.Game.Stores
ArtistUnicode = decoded.Metadata.ArtistUnicode, ArtistUnicode = decoded.Metadata.ArtistUnicode,
Author = Author =
{ {
OnlineID = decoded.Metadata.Author.Id, OnlineID = decoded.Metadata.Author.OnlineID,
Username = decoded.Metadata.Author.Username Username = decoded.Metadata.Author.Username
}, },
Source = decoded.Metadata.Source, Source = decoded.Metadata.Source,
@ -254,7 +254,7 @@ namespace osu.Game.Stores
{ {
Hash = hash, Hash = hash,
DifficultyName = decodedInfo.DifficultyName, DifficultyName = decodedInfo.DifficultyName,
OnlineID = decodedInfo.OnlineID ?? -1, OnlineID = decodedInfo.OnlineID,
AudioLeadIn = decodedInfo.AudioLeadIn, AudioLeadIn = decodedInfo.AudioLeadIn,
StackLeniency = decodedInfo.StackLeniency, StackLeniency = decodedInfo.StackLeniency,
SpecialStyle = decodedInfo.SpecialStyle, SpecialStyle = decodedInfo.SpecialStyle,