1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 12:33:01 +08:00

Merge pull request #15778 from peppy/ruleset-info-id-usage

Update usages of `RulesetInfo.ID` to use `OnlineID` instead
This commit is contained in:
Dan Balasescu 2021-11-24 16:55:28 +09:00 committed by GitHub
commit 74b6c33fab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 89 additions and 73 deletions

View File

@ -108,7 +108,10 @@ namespace osu.Desktop
presence.Assets.LargeImageText = $"{user.Value.Username}" + (user.Value.Statistics?.GlobalRank > 0 ? $" (rank #{user.Value.Statistics.GlobalRank:N0})" : string.Empty); presence.Assets.LargeImageText = $"{user.Value.Username}" + (user.Value.Statistics?.GlobalRank > 0 ? $" (rank #{user.Value.Statistics.GlobalRank:N0})" : string.Empty);
// update ruleset // update ruleset
presence.Assets.SmallImageKey = ruleset.Value.ID <= 3 ? $"mode_{ruleset.Value.ID}" : "mode_custom"; int onlineID = ruleset.Value.OnlineID;
bool isLegacyRuleset = onlineID >= 0 && onlineID <= ILegacyRuleset.MAX_LEGACY_RULESET_ID;
presence.Assets.SmallImageKey = isLegacyRuleset ? $"mode_{onlineID}" : "mode_custom";
presence.Assets.SmallImageText = ruleset.Value.Name; presence.Assets.SmallImageText = ruleset.Value.Name;
client.SetPresence(presence); client.SetPresence(presence);

View File

@ -30,7 +30,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
{ {
var score = decoder.Parse(resourceStream); var score = decoder.Parse(resourceStream);
Assert.AreEqual(3, score.ScoreInfo.Ruleset.ID); Assert.AreEqual(3, score.ScoreInfo.Ruleset.OnlineID);
Assert.AreEqual(2, score.ScoreInfo.Statistics[HitResult.Great]); Assert.AreEqual(2, score.ScoreInfo.Statistics[HitResult.Great]);
Assert.AreEqual(1, score.ScoreInfo.Statistics[HitResult.Good]); Assert.AreEqual(1, score.ScoreInfo.Statistics[HitResult.Good]);

View File

@ -100,8 +100,8 @@ namespace osu.Game.Tests.Beatmaps
[Test] [Test]
public void TestKeyEqualsWithDifferentModInstances() public void TestKeyEqualsWithDifferentModInstances()
{ {
var key1 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { ID = 0 }, new Mod[] { new OsuModHardRock(), new OsuModHidden() }); var key1 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModHardRock(), new OsuModHidden() });
var key2 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { ID = 0 }, new Mod[] { new OsuModHardRock(), new OsuModHidden() }); var key2 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModHardRock(), new OsuModHidden() });
Assert.That(key1, Is.EqualTo(key2)); Assert.That(key1, Is.EqualTo(key2));
Assert.That(key1.GetHashCode(), Is.EqualTo(key2.GetHashCode())); Assert.That(key1.GetHashCode(), Is.EqualTo(key2.GetHashCode()));
@ -110,8 +110,8 @@ namespace osu.Game.Tests.Beatmaps
[Test] [Test]
public void TestKeyEqualsWithDifferentModOrder() public void TestKeyEqualsWithDifferentModOrder()
{ {
var key1 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { ID = 0 }, new Mod[] { new OsuModHardRock(), new OsuModHidden() }); var key1 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModHardRock(), new OsuModHidden() });
var key2 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { ID = 0 }, new Mod[] { new OsuModHidden(), new OsuModHardRock() }); var key2 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModHidden(), new OsuModHardRock() });
Assert.That(key1, Is.EqualTo(key2)); Assert.That(key1, Is.EqualTo(key2));
Assert.That(key1.GetHashCode(), Is.EqualTo(key2.GetHashCode())); Assert.That(key1.GetHashCode(), Is.EqualTo(key2.GetHashCode()));
@ -120,8 +120,8 @@ namespace osu.Game.Tests.Beatmaps
[Test] [Test]
public void TestKeyDoesntEqualWithDifferentModSettings() public void TestKeyDoesntEqualWithDifferentModSettings()
{ {
var key1 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { ID = 0 }, new Mod[] { new OsuModDoubleTime { SpeedChange = { Value = 1.1 } } }); var key1 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModDoubleTime { SpeedChange = { Value = 1.1 } } });
var key2 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { ID = 0 }, new Mod[] { new OsuModDoubleTime { SpeedChange = { Value = 1.9 } } }); var key2 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModDoubleTime { SpeedChange = { Value = 1.9 } } });
Assert.That(key1, Is.Not.EqualTo(key2)); Assert.That(key1, Is.Not.EqualTo(key2));
Assert.That(key1.GetHashCode(), Is.Not.EqualTo(key2.GetHashCode())); Assert.That(key1.GetHashCode(), Is.Not.EqualTo(key2.GetHashCode()));
@ -130,8 +130,8 @@ namespace osu.Game.Tests.Beatmaps
[Test] [Test]
public void TestKeyEqualWithMatchingModSettings() public void TestKeyEqualWithMatchingModSettings()
{ {
var key1 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { ID = 0 }, new Mod[] { new OsuModDoubleTime { SpeedChange = { Value = 1.25 } } }); var key1 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModDoubleTime { SpeedChange = { Value = 1.25 } } });
var key2 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { ID = 0 }, new Mod[] { new OsuModDoubleTime { SpeedChange = { Value = 1.25 } } }); var key2 = new BeatmapDifficultyCache.DifficultyCacheLookup(new BeatmapInfo { ID = 1234 }, new RulesetInfo { OnlineID = 0 }, new Mod[] { new OsuModDoubleTime { SpeedChange = { Value = 1.25 } } });
Assert.That(key1, Is.EqualTo(key2)); Assert.That(key1, Is.EqualTo(key2));
Assert.That(key1.GetHashCode(), Is.EqualTo(key2.GetHashCode())); Assert.That(key1.GetHashCode(), Is.EqualTo(key2.GetHashCode()));

View File

@ -16,7 +16,7 @@ namespace osu.Game.Tests.NonVisual.Filtering
{ {
private BeatmapInfo getExampleBeatmap() => new BeatmapInfo private BeatmapInfo getExampleBeatmap() => new BeatmapInfo
{ {
Ruleset = new RulesetInfo { ID = 5 }, Ruleset = new RulesetInfo { OnlineID = 5 },
StarRating = 4.0d, StarRating = 4.0d,
BaseDifficulty = new BeatmapDifficulty BaseDifficulty = new BeatmapDifficulty
{ {
@ -57,7 +57,7 @@ namespace osu.Game.Tests.NonVisual.Filtering
var exampleBeatmapInfo = getExampleBeatmap(); var exampleBeatmapInfo = getExampleBeatmap();
var criteria = new FilterCriteria var criteria = new FilterCriteria
{ {
Ruleset = new RulesetInfo { ID = 6 } Ruleset = new RulesetInfo { OnlineID = 6 }
}; };
var carouselItem = new CarouselBeatmap(exampleBeatmapInfo); var carouselItem = new CarouselBeatmap(exampleBeatmapInfo);
carouselItem.Filter(criteria); carouselItem.Filter(criteria);
@ -70,7 +70,7 @@ namespace osu.Game.Tests.NonVisual.Filtering
var exampleBeatmapInfo = getExampleBeatmap(); var exampleBeatmapInfo = getExampleBeatmap();
var criteria = new FilterCriteria var criteria = new FilterCriteria
{ {
Ruleset = new RulesetInfo { ID = 6 }, Ruleset = new RulesetInfo { OnlineID = 6 },
AllowConvertedBeatmaps = true AllowConvertedBeatmaps = true
}; };
var carouselItem = new CarouselBeatmap(exampleBeatmapInfo); var carouselItem = new CarouselBeatmap(exampleBeatmapInfo);
@ -86,7 +86,7 @@ namespace osu.Game.Tests.NonVisual.Filtering
var exampleBeatmapInfo = getExampleBeatmap(); var exampleBeatmapInfo = getExampleBeatmap();
var criteria = new FilterCriteria var criteria = new FilterCriteria
{ {
Ruleset = new RulesetInfo { ID = 6 }, Ruleset = new RulesetInfo { OnlineID = 6 },
AllowConvertedBeatmaps = true, AllowConvertedBeatmaps = true,
ApproachRate = new FilterCriteria.OptionalRange<float> ApproachRate = new FilterCriteria.OptionalRange<float>
{ {
@ -107,7 +107,7 @@ namespace osu.Game.Tests.NonVisual.Filtering
var exampleBeatmapInfo = getExampleBeatmap(); var exampleBeatmapInfo = getExampleBeatmap();
var criteria = new FilterCriteria var criteria = new FilterCriteria
{ {
Ruleset = new RulesetInfo { ID = 6 }, Ruleset = new RulesetInfo { OnlineID = 6 },
AllowConvertedBeatmaps = true, AllowConvertedBeatmaps = true,
BPM = new FilterCriteria.OptionalRange<double> BPM = new FilterCriteria.OptionalRange<double>
{ {
@ -132,7 +132,7 @@ namespace osu.Game.Tests.NonVisual.Filtering
var exampleBeatmapInfo = getExampleBeatmap(); var exampleBeatmapInfo = getExampleBeatmap();
var criteria = new FilterCriteria var criteria = new FilterCriteria
{ {
Ruleset = new RulesetInfo { ID = 6 }, Ruleset = new RulesetInfo { OnlineID = 6 },
AllowConvertedBeatmaps = true, AllowConvertedBeatmaps = true,
SearchText = terms SearchText = terms
}; };

View File

@ -70,7 +70,7 @@ namespace osu.Game.Tests.Testing
{ {
// temporary ID to let RulesetConfigCache pass our // temporary ID to let RulesetConfigCache pass our
// config manager to the ruleset dependencies. // config manager to the ruleset dependencies.
RulesetInfo.ID = -1; RulesetInfo.OnlineID = -1;
} }
public override IResourceStore<byte[]> CreateResourceStore() => new NamespacedResourceStore<byte[]>(TestResources.GetStore(), @"Resources"); public override IResourceStore<byte[]> CreateResourceStore() => new NamespacedResourceStore<byte[]>(TestResources.GetStore(), @"Resources");

View File

@ -233,7 +233,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
prepareTokenResponse(true); prepareTokenResponse(true);
createPlayerTest(false, createRuleset: () => new OsuRuleset { RulesetInfo = { ID = rulesetId } }); createPlayerTest(false, createRuleset: () => new OsuRuleset { RulesetInfo = { OnlineID = rulesetId ?? -1 } });
AddUntilStep("wait for token request", () => Player.TokenCreationRequested); AddUntilStep("wait for token request", () => Player.TokenCreationRequested);

View File

@ -38,7 +38,7 @@ namespace osu.Game.Tests.Visual.Gameplay
public void TestClientSendsCorrectRuleset() public void TestClientSendsCorrectRuleset()
{ {
AddUntilStep("spectator client sending frames", () => spectatorClient.PlayingUserStates.ContainsKey(dummy_user_id)); AddUntilStep("spectator client sending frames", () => spectatorClient.PlayingUserStates.ContainsKey(dummy_user_id));
AddAssert("spectator client sent correct ruleset", () => spectatorClient.PlayingUserStates[dummy_user_id].RulesetID == Ruleset.Value.ID); AddAssert("spectator client sent correct ruleset", () => spectatorClient.PlayingUserStates[dummy_user_id].RulesetID == Ruleset.Value.OnlineID);
} }
public override void TearDownSteps() public override void TearDownSteps()

View File

@ -257,7 +257,7 @@ namespace osu.Game.Tests.Visual.Navigation
InputManager.ReleaseKey(Key.ControlLeft); InputManager.ReleaseKey(Key.ControlLeft);
}); });
AddAssert("Ruleset changed to osu!taiko", () => Game.Toolbar.ChildrenOfType<ToolbarRulesetSelector>().Single().Current.Value.ID == 1); AddAssert("Ruleset changed to osu!taiko", () => Game.Toolbar.ChildrenOfType<ToolbarRulesetSelector>().Single().Current.Value.OnlineID == 1);
AddAssert("Mods overlay still visible", () => songSelect.ModSelectOverlay.State.Value == Visibility.Visible); AddAssert("Mods overlay still visible", () => songSelect.ModSelectOverlay.State.Value == Visibility.Visible);
} }
@ -278,7 +278,7 @@ namespace osu.Game.Tests.Visual.Navigation
InputManager.ReleaseKey(Key.ControlLeft); InputManager.ReleaseKey(Key.ControlLeft);
}); });
AddAssert("Ruleset changed to osu!taiko", () => Game.Toolbar.ChildrenOfType<ToolbarRulesetSelector>().Single().Current.Value.ID == 1); AddAssert("Ruleset changed to osu!taiko", () => Game.Toolbar.ChildrenOfType<ToolbarRulesetSelector>().Single().Current.Value.OnlineID == 1);
AddAssert("Options overlay still visible", () => songSelect.BeatmapOptionsOverlay.State.Value == Visibility.Visible); AddAssert("Options overlay still visible", () => songSelect.BeatmapOptionsOverlay.State.Value == Visibility.Visible);
} }

View File

@ -200,7 +200,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
OnlineID = i * 10, OnlineID = i * 10,
DifficultyName = $"Test #{i}", DifficultyName = $"Test #{i}",
RulesetID = Ruleset.Value.ID ?? -1, RulesetID = Ruleset.Value.OnlineID,
StarRating = 2 + i * 0.1, StarRating = 2 + i * 0.1,
OverallDifficulty = 3.5f, OverallDifficulty = 3.5f,
FailTimes = new APIFailTimes FailTimes = new APIFailTimes

View File

@ -94,7 +94,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
new APIBeatmap new APIBeatmap
{ {
RulesetID = Ruleset.Value.ID ?? 0, RulesetID = Ruleset.Value.OnlineID,
DifficultyName = "Test", DifficultyName = "Test",
StarRating = 6.42, StarRating = 6.42,
} }

View File

@ -64,7 +64,7 @@ namespace osu.Game.Tests.Visual.Online
AddStep("Set beatmap", () => Beatmap.Value = new DummyWorkingBeatmap(Audio, null) AddStep("Set beatmap", () => Beatmap.Value = new DummyWorkingBeatmap(Audio, null)
{ {
BeatmapInfo = { OnlineID = hasOnlineId ? 1234 : (int?)null } BeatmapInfo = { OnlineID = hasOnlineId ? 1234 : -1 }
}); });
AddStep("Run command", () => Add(new NowPlayingCommand())); AddStep("Run command", () => Add(new NowPlayingCommand()));

View File

@ -32,7 +32,7 @@ namespace osu.Game.Tests.Visual.SongSelect
switch (req) switch (req)
{ {
case GetUserRequest userRequest: case GetUserRequest userRequest:
userRequest.TriggerSuccess(getUser(userRequest.Ruleset.ID)); userRequest.TriggerSuccess(getUser(userRequest.Ruleset.OnlineID));
return true; return true;
} }

View File

@ -258,7 +258,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
AddStep("import multi-ruleset map", () => AddStep("import multi-ruleset map", () =>
{ {
var usableRulesets = rulesets.AvailableRulesets.Where(r => r.ID != 2).ToArray(); var usableRulesets = rulesets.AvailableRulesets.Where(r => r.OnlineID != 2).ToArray();
manager.Import(createTestBeatmapSet(usableRulesets)).Wait(); manager.Import(createTestBeatmapSet(usableRulesets)).Wait();
}); });
} }
@ -354,7 +354,7 @@ namespace osu.Game.Tests.Visual.SongSelect
target = manager.GetAllUsableBeatmapSets() target = manager.GetAllUsableBeatmapSets()
.Last(b => b.Beatmaps.Any(bi => bi.RulesetID == 0)).Beatmaps.Last(); .Last(b => b.Beatmaps.Any(bi => bi.RulesetID == 0)).Beatmaps.Last();
Ruleset.Value = rulesets.AvailableRulesets.First(r => r.ID == 0); Ruleset.Value = rulesets.AvailableRulesets.First(r => r.OnlineID == 0);
Beatmap.Value = manager.GetWorkingBeatmap(target); Beatmap.Value = manager.GetWorkingBeatmap(target);
}); });
@ -385,12 +385,12 @@ namespace osu.Game.Tests.Visual.SongSelect
.Last(b => b.Beatmaps.Any(bi => bi.RulesetID == 0)).Beatmaps.Last(); .Last(b => b.Beatmaps.Any(bi => bi.RulesetID == 0)).Beatmaps.Last();
Beatmap.Value = manager.GetWorkingBeatmap(target); Beatmap.Value = manager.GetWorkingBeatmap(target);
Ruleset.Value = rulesets.AvailableRulesets.First(r => r.ID == 0); Ruleset.Value = rulesets.AvailableRulesets.First(r => r.OnlineID == 0);
}); });
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo.Equals(target)); AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo.Equals(target));
AddUntilStep("has correct ruleset", () => Ruleset.Value.ID == 0); AddUntilStep("has correct ruleset", () => Ruleset.Value.OnlineID == 0);
// this is an important check, to make sure updateComponentFromBeatmap() was actually run // this is an important check, to make sure updateComponentFromBeatmap() was actually run
AddUntilStep("selection shown on wedge", () => songSelect.CurrentBeatmapDetailsBeatmap.BeatmapInfo.MatchesOnlineID(target)); AddUntilStep("selection shown on wedge", () => songSelect.CurrentBeatmapDetailsBeatmap.BeatmapInfo.MatchesOnlineID(target));
@ -505,7 +505,7 @@ namespace osu.Game.Tests.Visual.SongSelect
// special case for converts checked here. // special case for converts checked here.
return selectedPanel.ChildrenOfType<FilterableDifficultyIcon>().All(i => return selectedPanel.ChildrenOfType<FilterableDifficultyIcon>().All(i =>
i.IsFiltered || i.Item.BeatmapInfo.Ruleset.ID == targetRuleset || i.Item.BeatmapInfo.Ruleset.ID == 0); i.IsFiltered || i.Item.BeatmapInfo.Ruleset.OnlineID == targetRuleset || i.Item.BeatmapInfo.Ruleset.OnlineID == 0);
}); });
AddUntilStep("carousel has correct", () => songSelect.Carousel.SelectedBeatmapInfo?.MatchesOnlineID(target) == true); AddUntilStep("carousel has correct", () => songSelect.Carousel.SelectedBeatmapInfo?.MatchesOnlineID(target) == true);
@ -665,7 +665,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("import multi-ruleset map", () => AddStep("import multi-ruleset map", () =>
{ {
var usableRulesets = rulesets.AvailableRulesets.Where(r => r.ID != 2).ToArray(); var usableRulesets = rulesets.AvailableRulesets.Where(r => r.OnlineID != 2).ToArray();
manager.Import(createTestBeatmapSet(usableRulesets)).Wait(); manager.Import(createTestBeatmapSet(usableRulesets)).Wait();
}); });
@ -676,11 +676,11 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("record set ID", () => previousSetID = ((IBeatmapSetInfo)Beatmap.Value.BeatmapSetInfo).OnlineID); AddStep("record set ID", () => previousSetID = ((IBeatmapSetInfo)Beatmap.Value.BeatmapSetInfo).OnlineID);
AddAssert("selection changed once", () => changeCount == 1); AddAssert("selection changed once", () => changeCount == 1);
AddAssert("Check ruleset is osu!", () => Ruleset.Value.ID == 0); AddAssert("Check ruleset is osu!", () => Ruleset.Value.OnlineID == 0);
changeRuleset(3); changeRuleset(3);
AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.ID == 3); AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.OnlineID == 3);
AddUntilStep("selection changed", () => changeCount > 1); AddUntilStep("selection changed", () => changeCount > 1);
@ -705,7 +705,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("import multi-ruleset map", () => AddStep("import multi-ruleset map", () =>
{ {
var usableRulesets = rulesets.AvailableRulesets.Where(r => r.ID != 2).ToArray(); var usableRulesets = rulesets.AvailableRulesets.Where(r => r.OnlineID != 2).ToArray();
manager.Import(createTestBeatmapSet(usableRulesets)).Wait(); manager.Import(createTestBeatmapSet(usableRulesets)).Wait();
}); });
@ -720,11 +720,11 @@ namespace osu.Game.Tests.Visual.SongSelect
AddUntilStep("Find an icon for different ruleset", () => AddUntilStep("Find an icon for different ruleset", () =>
{ {
difficultyIcon = set.ChildrenOfType<FilterableDifficultyIcon>() difficultyIcon = set.ChildrenOfType<FilterableDifficultyIcon>()
.FirstOrDefault(icon => icon.Item.BeatmapInfo.Ruleset.ID == 3); .FirstOrDefault(icon => icon.Item.BeatmapInfo.Ruleset.OnlineID == 3);
return difficultyIcon != null; return difficultyIcon != null;
}); });
AddAssert("Check ruleset is osu!", () => Ruleset.Value.ID == 0); AddAssert("Check ruleset is osu!", () => Ruleset.Value.OnlineID == 0);
int previousSetID = 0; int previousSetID = 0;
@ -737,7 +737,7 @@ namespace osu.Game.Tests.Visual.SongSelect
InputManager.Click(MouseButton.Left); InputManager.Click(MouseButton.Left);
}); });
AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.ID == 3); AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.OnlineID == 3);
AddAssert("Selected beatmap still same set", () => songSelect.Carousel.SelectedBeatmapInfo.BeatmapSet.OnlineID == previousSetID); AddAssert("Selected beatmap still same set", () => songSelect.Carousel.SelectedBeatmapInfo.BeatmapSet.OnlineID == previousSetID);
AddAssert("Selected beatmap is mania", () => Beatmap.Value.BeatmapInfo.Ruleset.OnlineID == 3); AddAssert("Selected beatmap is mania", () => Beatmap.Value.BeatmapInfo.Ruleset.OnlineID == 3);
@ -754,7 +754,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("import huge difficulty count map", () => AddStep("import huge difficulty count map", () =>
{ {
var usableRulesets = rulesets.AvailableRulesets.Where(r => r.ID != 2).ToArray(); var usableRulesets = rulesets.AvailableRulesets.Where(r => r.OnlineID != 2).ToArray();
imported = manager.Import(createTestBeatmapSet(usableRulesets, 50)).Result.Value; imported = manager.Import(createTestBeatmapSet(usableRulesets, 50)).Result.Value;
}); });
@ -771,10 +771,10 @@ namespace osu.Game.Tests.Visual.SongSelect
AddUntilStep("Find group icon for different ruleset", () => AddUntilStep("Find group icon for different ruleset", () =>
{ {
return (groupIcon = set.ChildrenOfType<FilterableGroupedDifficultyIcon>() return (groupIcon = set.ChildrenOfType<FilterableGroupedDifficultyIcon>()
.FirstOrDefault(icon => icon.Items.First().BeatmapInfo.Ruleset.ID == 3)) != null; .FirstOrDefault(icon => icon.Items.First().BeatmapInfo.Ruleset.OnlineID == 3)) != null;
}); });
AddAssert("Check ruleset is osu!", () => Ruleset.Value.ID == 0); AddAssert("Check ruleset is osu!", () => Ruleset.Value.OnlineID == 0);
AddStep("Click on group", () => AddStep("Click on group", () =>
{ {
@ -783,7 +783,7 @@ namespace osu.Game.Tests.Visual.SongSelect
InputManager.Click(MouseButton.Left); InputManager.Click(MouseButton.Left);
}); });
AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.ID == 3); AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.OnlineID == 3);
AddAssert("Check first item in group selected", () => Beatmap.Value.BeatmapInfo.MatchesOnlineID(groupIcon.Items.First().BeatmapInfo)); AddAssert("Check first item in group selected", () => Beatmap.Value.BeatmapInfo.MatchesOnlineID(groupIcon.Items.First().BeatmapInfo));
} }
@ -817,7 +817,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddUntilStep("wait for results screen presented", () => !songSelect.IsCurrentScreen()); AddUntilStep("wait for results screen presented", () => !songSelect.IsCurrentScreen());
AddAssert("check beatmap is correct for score", () => Beatmap.Value.BeatmapInfo.MatchesOnlineID(getPresentBeatmap())); AddAssert("check beatmap is correct for score", () => Beatmap.Value.BeatmapInfo.MatchesOnlineID(getPresentBeatmap()));
AddAssert("check ruleset is correct for score", () => Ruleset.Value.ID == 0); AddAssert("check ruleset is correct for score", () => Ruleset.Value.OnlineID == 0);
} }
[Test] [Test]
@ -849,7 +849,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddUntilStep("wait for results screen presented", () => !songSelect.IsCurrentScreen()); AddUntilStep("wait for results screen presented", () => !songSelect.IsCurrentScreen());
AddAssert("check beatmap is correct for score", () => Beatmap.Value.BeatmapInfo.MatchesOnlineID(getPresentBeatmap())); AddAssert("check beatmap is correct for score", () => Beatmap.Value.BeatmapInfo.MatchesOnlineID(getPresentBeatmap()));
AddAssert("check ruleset is correct for score", () => Ruleset.Value.ID == 0); AddAssert("check ruleset is correct for score", () => Ruleset.Value.OnlineID == 0);
} }
private void waitForInitialSelection() private void waitForInitialSelection()
@ -869,7 +869,7 @@ namespace osu.Game.Tests.Visual.SongSelect
private void addRulesetImportStep(int id) => AddStep($"import test map for ruleset {id}", () => importForRuleset(id)); private void addRulesetImportStep(int id) => AddStep($"import test map for ruleset {id}", () => importForRuleset(id));
private void importForRuleset(int id) => manager.Import(createTestBeatmapSet(rulesets.AvailableRulesets.Where(r => r.ID == id).ToArray())).Wait(); private void importForRuleset(int id) => manager.Import(createTestBeatmapSet(rulesets.AvailableRulesets.Where(r => r.OnlineID == id).ToArray())).Wait();
private static int importId; private static int importId;
@ -880,7 +880,7 @@ namespace osu.Game.Tests.Visual.SongSelect
private void changeMods(params Mod[] mods) => AddStep($"change mods to {string.Join(", ", mods.Select(m => m.Acronym))}", () => SelectedMods.Value = mods); private void changeMods(params Mod[] mods) => AddStep($"change mods to {string.Join(", ", mods.Select(m => m.Acronym))}", () => SelectedMods.Value = mods);
private void changeRuleset(int id) => AddStep($"change ruleset to {id}", () => Ruleset.Value = rulesets.AvailableRulesets.First(r => r.ID == id)); private void changeRuleset(int id) => AddStep($"change ruleset to {id}", () => Ruleset.Value = rulesets.AvailableRulesets.First(r => r.OnlineID == id));
private void createSongSelect() private void createSongSelect()
{ {
@ -893,7 +893,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
AddStep("import test maps", () => AddStep("import test maps", () =>
{ {
var usableRulesets = rulesets.AvailableRulesets.Where(r => r.ID != 2).ToArray(); var usableRulesets = rulesets.AvailableRulesets.Where(r => r.OnlineID != 2).ToArray();
for (int i = 0; i < 100; i += 10) for (int i = 0; i < 100; i += 10)
manager.Import(createTestBeatmapSet(usableRulesets)).Wait(); manager.Import(createTestBeatmapSet(usableRulesets)).Wait();

View File

@ -378,9 +378,9 @@ namespace osu.Game.Tests.Visual.UserInterface
}); });
} }
private void changeRuleset(int? id) private void changeRuleset(int? onlineId)
{ {
AddStep($"change ruleset to {(id?.ToString() ?? "none")}", () => { Ruleset.Value = rulesets.AvailableRulesets.FirstOrDefault(r => r.ID == id); }); AddStep($"change ruleset to {(onlineId?.ToString() ?? "none")}", () => { Ruleset.Value = rulesets.AvailableRulesets.FirstOrDefault(r => r.OnlineID == onlineId); });
waitForLoad(); waitForLoad();
} }

View File

@ -42,7 +42,12 @@ namespace osu.Game.Tournament.Tests.Components
private void success(APIBeatmap beatmap) private void success(APIBeatmap beatmap)
{ {
var mods = rulesets.GetRuleset(Ladder.Ruleset.Value.ID ?? 0).CreateInstance().AllMods; var ruleset = rulesets.GetRuleset(Ladder.Ruleset.Value.OnlineID);
if (ruleset == null)
return;
var mods = ruleset.CreateInstance().AllMods;
foreach (var mod in mods) foreach (var mod in mods)
{ {

View File

@ -127,7 +127,7 @@ namespace osu.Game.Tournament.Components
(string heading, string content)[] stats; (string heading, string content)[] stats;
switch (ruleset.Value.ID) switch (ruleset.Value.OnlineID)
{ {
default: default:
stats = new (string heading, string content)[] stats = new (string heading, string content)[]

View File

@ -349,7 +349,7 @@ namespace osu.Game.Beatmaps
var hashCode = new HashCode(); var hashCode = new HashCode();
hashCode.Add(BeatmapInfo.ID); hashCode.Add(BeatmapInfo.ID);
hashCode.Add(Ruleset.ID); hashCode.Add(Ruleset.ShortName);
foreach (var mod in OrderedMods) foreach (var mod in OrderedMods)
hashCode.Add(mod); hashCode.Add(mod);

View File

@ -83,7 +83,7 @@ namespace osu.Game.Beatmaps
requestedUserId = api.LocalUser.Value.Id; requestedUserId = api.LocalUser.Value.Id;
// only query API for built-in rulesets // only query API for built-in rulesets
rulesets.AvailableRulesets.Where(ruleset => ruleset.ID <= ILegacyRuleset.MAX_LEGACY_RULESET_ID).ForEach(rulesetInfo => rulesets.AvailableRulesets.Where(ruleset => ruleset.OnlineID >= 0 && ruleset.OnlineID <= ILegacyRuleset.MAX_LEGACY_RULESET_ID).ForEach(rulesetInfo =>
{ {
var req = new GetUserRequest(api.LocalUser.Value.Id, rulesetInfo); var req = new GetUserRequest(api.LocalUser.Value.Id, rulesetInfo);

View File

@ -25,12 +25,12 @@ namespace osu.Game.Models
public string InstantiationInfo { get; set; } = string.Empty; public string InstantiationInfo { get; set; } = string.Empty;
public RealmRuleset(string shortName, string name, string instantiationInfo, int? onlineID = null) public RealmRuleset(string shortName, string name, string instantiationInfo, int onlineID)
{ {
ShortName = shortName; ShortName = shortName;
Name = name; Name = name;
InstantiationInfo = instantiationInfo; InstantiationInfo = instantiationInfo;
OnlineID = onlineID ?? -1; OnlineID = onlineID;
} }
[UsedImplicitly] [UsedImplicitly]

View File

@ -98,7 +98,7 @@ namespace osu.Game.Online.API.Requests.Responses
public string MD5Hash => Checksum; public string MD5Hash => Checksum;
public IRulesetInfo Ruleset => new RulesetInfo { ID = RulesetID }; public IRulesetInfo Ruleset => new RulesetInfo { OnlineID = RulesetID };
[JsonIgnore] [JsonIgnore]
public string Hash => throw new NotImplementedException(); public string Hash => throw new NotImplementedException();

View File

@ -146,7 +146,7 @@ namespace osu.Game.Online.API.Requests.Responses
return scoreInfo; return scoreInfo;
} }
public IRulesetInfo Ruleset => new RulesetInfo { ID = RulesetID }; public IRulesetInfo Ruleset => new RulesetInfo { OnlineID = RulesetID };
IBeatmapInfo IScoreInfo.Beatmap => Beatmap; IBeatmapInfo IScoreInfo.Beatmap => Beatmap;
} }

View File

@ -86,8 +86,8 @@ namespace osu.Game.Online.API.Requests
if (General != null && General.Any()) if (General != null && General.Any())
req.AddParameter("c", string.Join('.', General.Select(e => e.ToString().Underscore()))); req.AddParameter("c", string.Join('.', General.Select(e => e.ToString().Underscore())));
if (ruleset.ID.HasValue) if (ruleset.OnlineID >= 0)
req.AddParameter("m", ruleset.ID.Value.ToString()); req.AddParameter("m", ruleset.OnlineID.ToString());
req.AddParameter("s", SearchCategory.ToString().ToLowerInvariant()); req.AddParameter("s", SearchCategory.ToString().ToLowerInvariant());

View File

@ -183,7 +183,7 @@ namespace osu.Game.Rulesets
{ {
Name = Description, Name = Description,
ShortName = ShortName, ShortName = ShortName,
ID = (this as ILegacyRuleset)?.LegacyID, OnlineID = (this as ILegacyRuleset)?.LegacyID ?? -1,
InstantiationInfo = GetType().GetInvariantInstantiationInfo(), InstantiationInfo = GetType().GetInvariantInstantiationInfo(),
Available = true, Available = true,
}; };

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Testing; using osu.Framework.Testing;
@ -65,7 +66,12 @@ namespace osu.Game.Rulesets
#region Implementation of IHasOnlineID #region Implementation of IHasOnlineID
public int OnlineID => ID ?? -1; [NotMapped]
public int OnlineID
{
get => ID ?? -1;
set => ID = value >= 0 ? value : (int?)null;
}
#endregion #endregion
} }

View File

@ -140,7 +140,7 @@ namespace osu.Game.Scoring.Legacy
int countGeki = score.GetCountGeki() ?? 0; int countGeki = score.GetCountGeki() ?? 0;
int countKatu = score.GetCountKatu() ?? 0; int countKatu = score.GetCountKatu() ?? 0;
switch (score.Ruleset.ID) switch (score.Ruleset.OnlineID)
{ {
case 0: case 0:
{ {

View File

@ -42,7 +42,7 @@ namespace osu.Game.Scoring.Legacy
{ {
using (SerializationWriter sw = new SerializationWriter(stream)) using (SerializationWriter sw = new SerializationWriter(stream))
{ {
sw.Write((byte)(score.ScoreInfo.Ruleset.ID ?? 0)); sw.Write((byte)(score.ScoreInfo.Ruleset.OnlineID));
sw.Write(LATEST_VERSION); sw.Write(LATEST_VERSION);
sw.Write(score.ScoreInfo.BeatmapInfo.MD5Hash); sw.Write(score.ScoreInfo.BeatmapInfo.MD5Hash);
sw.Write(score.ScoreInfo.UserString); sw.Write(score.ScoreInfo.UserString);

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using osu.Game.Beatmaps;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.Rooms; using osu.Game.Online.Rooms;
using osu.Game.Online.Solo; using osu.Game.Online.Solo;
@ -25,10 +26,13 @@ namespace osu.Game.Screens.Play
protected override APIRequest<APIScoreToken> CreateTokenRequest() protected override APIRequest<APIScoreToken> CreateTokenRequest()
{ {
if (!(Beatmap.Value.BeatmapInfo.OnlineID is int beatmapId)) int beatmapId = Beatmap.Value.BeatmapInfo.OnlineID ?? -1;
int rulesetId = Ruleset.Value.OnlineID;
if (beatmapId <= 0)
return null; return null;
if (!(Ruleset.Value.ID is int rulesetId) || Ruleset.Value.ID > ILegacyRuleset.MAX_LEGACY_RULESET_ID) if (rulesetId < 0 || rulesetId > ILegacyRuleset.MAX_LEGACY_RULESET_ID)
return null; return null;
return new CreateSoloScoreRequest(beatmapId, rulesetId, Game.VersionHash); return new CreateSoloScoreRequest(beatmapId, rulesetId, Game.VersionHash);
@ -38,13 +42,11 @@ namespace osu.Game.Screens.Play
protected override APIRequest<MultiplayerScore> CreateSubmissionRequest(Score score, long token) protected override APIRequest<MultiplayerScore> CreateSubmissionRequest(Score score, long token)
{ {
var beatmap = score.ScoreInfo.BeatmapInfo; IBeatmapInfo beatmap = score.ScoreInfo.BeatmapInfo;
Debug.Assert(beatmap.OnlineID != null); Debug.Assert(beatmap.OnlineID > 0);
int beatmapId = beatmap.OnlineID.Value; return new SubmitSoloScoreRequest(beatmap.OnlineID, token, score.ScoreInfo);
return new SubmitSoloScoreRequest(beatmapId, token, score.ScoreInfo);
} }
} }
} }

View File

@ -146,7 +146,7 @@ namespace osu.Game.Screens.Spectate
var user = userMap[userId]; var user = userMap[userId];
var spectatorState = playingUserStates[userId]; var spectatorState = playingUserStates[userId];
var resolvedRuleset = rulesets.AvailableRulesets.FirstOrDefault(r => r.ID == spectatorState.RulesetID)?.CreateInstance(); var resolvedRuleset = rulesets.AvailableRulesets.FirstOrDefault(r => r.OnlineID == spectatorState.RulesetID)?.CreateInstance();
if (resolvedRuleset == null) if (resolvedRuleset == null)
return; return;

View File

@ -117,8 +117,8 @@ namespace osu.Game.Stores
// add all legacy rulesets first to ensure they have exclusive choice of primary key. // add all legacy rulesets first to ensure they have exclusive choice of primary key.
foreach (var r in instances.Where(r => r is ILegacyRuleset)) foreach (var r in instances.Where(r => r is ILegacyRuleset))
{ {
if (realm.All<RealmRuleset>().FirstOrDefault(rr => rr.OnlineID == r.RulesetInfo.ID) == null) if (realm.All<RealmRuleset>().FirstOrDefault(rr => rr.OnlineID == r.RulesetInfo.OnlineID) == null)
realm.Add(new RealmRuleset(r.RulesetInfo.ShortName, r.RulesetInfo.Name, r.RulesetInfo.InstantiationInfo, r.RulesetInfo.ID)); realm.Add(new RealmRuleset(r.RulesetInfo.ShortName, r.RulesetInfo.Name, r.RulesetInfo.InstantiationInfo, r.RulesetInfo.OnlineID));
} }
// add any other rulesets which have assemblies present but are not yet in the database. // add any other rulesets which have assemblies present but are not yet in the database.
@ -136,7 +136,7 @@ namespace osu.Game.Stores
existingSameShortName.InstantiationInfo = r.RulesetInfo.InstantiationInfo; existingSameShortName.InstantiationInfo = r.RulesetInfo.InstantiationInfo;
} }
else else
realm.Add(new RealmRuleset(r.RulesetInfo.ShortName, r.RulesetInfo.Name, r.RulesetInfo.InstantiationInfo, r.RulesetInfo.ID)); realm.Add(new RealmRuleset(r.RulesetInfo.ShortName, r.RulesetInfo.Name, r.RulesetInfo.InstantiationInfo, r.RulesetInfo.OnlineID));
} }
} }