1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 13:37:25 +08:00

Fix scores sometimes not being re-standardised correctly

This commit is contained in:
smoogipoo 2020-09-29 18:55:06 +09:00
parent 4c872094c9
commit 297168ecc4
3 changed files with 54 additions and 9 deletions

View File

@ -38,6 +38,7 @@ namespace osu.Game.Online.API.Requests.Responses
Rank = Rank,
Ruleset = ruleset,
Mods = mods,
IsLegacyScore = true
};
if (Statistics != null)

View File

@ -185,6 +185,34 @@ namespace osu.Game.Scoring
[JsonProperty("position")]
public int? Position { get; set; }
private bool isLegacyScore;
/// <summary>
/// Whether this <see cref="ScoreInfo"/> represents a legacy (osu!stable) score.
/// </summary>
[JsonIgnore]
[NotMapped]
public bool IsLegacyScore
{
get
{
if (isLegacyScore)
return true;
// The above check will catch legacy online scores that have an appropriate UserString + UserId.
// For non-online scores such as those imported in, a heuristic is used based on the following table:
//
// Mode | UserString | UserId
// --------------- | ---------- | ---------
// stable | <username> | 1
// lazer | <username> | <userid>
// lazer (offline) | Guest | 1
return ID > 0 && UserID == 1 && UserString != "Guest";
}
set => isLegacyScore = value;
}
public IEnumerable<(HitResult result, int count, int? maxCount)> GetStatisticsForDisplay()
{
foreach (var key in OrderAttributeUtils.GetValuesInOrder<HitResult>())

View File

@ -10,6 +10,7 @@ using System.Threading;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Game.Beatmaps;
@ -149,13 +150,17 @@ namespace osu.Game.Scoring
return;
}
int? beatmapMaxCombo = score.Beatmap.MaxCombo;
int beatmapMaxCombo;
if (beatmapMaxCombo == null)
if (score.IsLegacyScore)
{
// This score is guaranteed to be an osu!stable score.
// The combo must be determined through either the beatmap's max combo value or the difficulty calculator, as lazer's scoring has changed and the score statistics cannot be used.
if (score.Beatmap.MaxCombo == null)
{
if (score.Beatmap.ID == 0 || difficulties == null)
{
// We don't have enough information (max combo) to compute the score, so let's use the provided score.
// We don't have enough information (max combo) to compute the score, so use the provided score.
Value = score.TotalScore;
return;
}
@ -163,9 +168,20 @@ namespace osu.Game.Scoring
// We can compute the max combo locally after the async beatmap difficulty computation.
difficultyBindable = difficulties().GetBindableDifficulty(score.Beatmap, score.Ruleset, score.Mods, (difficultyCancellationSource = new CancellationTokenSource()).Token);
difficultyBindable.BindValueChanged(d => updateScore(d.NewValue.MaxCombo), true);
return;
}
beatmapMaxCombo = score.Beatmap.MaxCombo.Value;
}
else
updateScore(beatmapMaxCombo.Value);
{
// This score is guaranteed to be an osu!lazer score.
// The combo must be determined through the score's statistics, as both the beatmap's max combo and the difficulty calculator will provide osu!stable combo values.
beatmapMaxCombo = Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Where(r => r.AffectsCombo()).Select(r => score.Statistics.GetOrDefault(r)).Sum();
}
updateScore(beatmapMaxCombo);
}
private void updateScore(int beatmapMaxCombo)