mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Update all actual usages of RulesetInfo.ID
to use OnlineID
instead
This commit is contained in:
parent
f283770f34
commit
bbd3ea5b77
@ -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);
|
||||
|
||||
// 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;
|
||||
|
||||
client.SetPresence(presence);
|
||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
{
|
||||
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(1, score.ScoreInfo.Statistics[HitResult.Good]);
|
||||
|
@ -127,7 +127,7 @@ namespace osu.Game.Tournament.Components
|
||||
|
||||
(string heading, string content)[] stats;
|
||||
|
||||
switch (ruleset.Value.ID)
|
||||
switch (ruleset.Value.OnlineID)
|
||||
{
|
||||
default:
|
||||
stats = new (string heading, string content)[]
|
||||
|
@ -349,7 +349,7 @@ namespace osu.Game.Beatmaps
|
||||
var hashCode = new HashCode();
|
||||
|
||||
hashCode.Add(BeatmapInfo.ID);
|
||||
hashCode.Add(Ruleset.ID);
|
||||
hashCode.Add(Ruleset.ShortName);
|
||||
|
||||
foreach (var mod in OrderedMods)
|
||||
hashCode.Add(mod);
|
||||
|
@ -83,7 +83,7 @@ namespace osu.Game.Beatmaps
|
||||
requestedUserId = api.LocalUser.Value.Id;
|
||||
|
||||
// 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);
|
||||
|
||||
|
@ -25,12 +25,12 @@ namespace osu.Game.Models
|
||||
|
||||
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;
|
||||
Name = name;
|
||||
InstantiationInfo = instantiationInfo;
|
||||
OnlineID = onlineID ?? -1;
|
||||
OnlineID = onlineID;
|
||||
}
|
||||
|
||||
[UsedImplicitly]
|
||||
|
@ -86,8 +86,8 @@ namespace osu.Game.Online.API.Requests
|
||||
if (General != null && General.Any())
|
||||
req.AddParameter("c", string.Join('.', General.Select(e => e.ToString().Underscore())));
|
||||
|
||||
if (ruleset.ID.HasValue)
|
||||
req.AddParameter("m", ruleset.ID.Value.ToString());
|
||||
if (ruleset.OnlineID >= 0)
|
||||
req.AddParameter("m", ruleset.OnlineID.ToString());
|
||||
|
||||
req.AddParameter("s", SearchCategory.ToString().ToLowerInvariant());
|
||||
|
||||
|
@ -140,7 +140,7 @@ namespace osu.Game.Scoring.Legacy
|
||||
int countGeki = score.GetCountGeki() ?? 0;
|
||||
int countKatu = score.GetCountKatu() ?? 0;
|
||||
|
||||
switch (score.Ruleset.ID)
|
||||
switch (score.Ruleset.OnlineID)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Scoring.Legacy
|
||||
{
|
||||
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(score.ScoreInfo.BeatmapInfo.MD5Hash);
|
||||
sw.Write(score.ScoreInfo.UserString);
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Online.Solo;
|
||||
@ -25,10 +26,13 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
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;
|
||||
|
||||
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 new CreateSoloScoreRequest(beatmapId, rulesetId, Game.VersionHash);
|
||||
@ -38,13 +42,11 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
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(beatmapId, token, score.ScoreInfo);
|
||||
return new SubmitSoloScoreRequest(beatmap.OnlineID, token, score.ScoreInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ namespace osu.Game.Screens.Spectate
|
||||
var user = userMap[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)
|
||||
return;
|
||||
|
||||
|
@ -117,8 +117,8 @@ namespace osu.Game.Stores
|
||||
// add all legacy rulesets first to ensure they have exclusive choice of primary key.
|
||||
foreach (var r in instances.Where(r => r is ILegacyRuleset))
|
||||
{
|
||||
if (realm.All<RealmRuleset>().FirstOrDefault(rr => rr.OnlineID == r.RulesetInfo.ID) == null)
|
||||
realm.Add(new RealmRuleset(r.RulesetInfo.ShortName, r.RulesetInfo.Name, r.RulesetInfo.InstantiationInfo, r.RulesetInfo.ID));
|
||||
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.OnlineID));
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user