mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 16:12:54 +08:00
Fix replay export not working correctly from online leaderboards
This commit is contained in:
parent
f282152f99
commit
ed8b596325
@ -706,24 +706,9 @@ namespace osu.Game
|
||||
{
|
||||
Logger.Log($"Beginning {nameof(PresentScore)} with score {score}");
|
||||
|
||||
// The given ScoreInfo may have missing properties if it was retrieved from online data. Re-retrieve it from the database
|
||||
// to ensure all the required data for presenting a replay are present.
|
||||
ScoreInfo databasedScoreInfo = null;
|
||||
ScoreInfo databasedScoreInfo = ScoreManager.GetDatabasedScoreInfo(score);
|
||||
|
||||
if (score.OnlineID > 0)
|
||||
databasedScoreInfo = ScoreManager.Query(s => s.OnlineID == score.OnlineID);
|
||||
|
||||
if (score.LegacyOnlineID > 0)
|
||||
databasedScoreInfo ??= ScoreManager.Query(s => s.LegacyOnlineID == score.LegacyOnlineID);
|
||||
|
||||
if (score is ScoreInfo scoreInfo)
|
||||
databasedScoreInfo ??= ScoreManager.Query(s => s.Hash == scoreInfo.Hash);
|
||||
|
||||
if (databasedScoreInfo == null)
|
||||
{
|
||||
Logger.Log("The requested score could not be found locally.", LoggingTarget.Information);
|
||||
return;
|
||||
}
|
||||
if (databasedScoreInfo == null) return;
|
||||
|
||||
var databasedScore = ScoreManager.GetScore(databasedScoreInfo);
|
||||
|
||||
|
@ -8,8 +8,8 @@ using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
@ -70,6 +70,34 @@ namespace osu.Game.Scoring
|
||||
return Realm.Run(r => r.All<ScoreInfo>().FirstOrDefault(query)?.Detach());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Re-retrieve a given <see cref="IScoreInfo"/> from the database to ensure all the required data for presenting / exporting a replay are present.
|
||||
/// </summary>
|
||||
/// <param name="originalScoreInfo">The <see cref="IScoreInfo"/> to attempt querying on.</param>
|
||||
/// <returns>The databased score info. Null if the score on the database cannot be found.</returns>
|
||||
/// <remarks>Can be used when the <see cref="IScoreInfo"/> was retrieved from online data, as it may have missing properties.</remarks>
|
||||
public ScoreInfo? GetDatabasedScoreInfo(IScoreInfo originalScoreInfo)
|
||||
{
|
||||
ScoreInfo? databasedScoreInfo = null;
|
||||
|
||||
if (originalScoreInfo.OnlineID > 0)
|
||||
databasedScoreInfo = Query(s => s.OnlineID == originalScoreInfo.OnlineID);
|
||||
|
||||
if (originalScoreInfo.LegacyOnlineID > 0)
|
||||
databasedScoreInfo ??= Query(s => s.LegacyOnlineID == originalScoreInfo.LegacyOnlineID);
|
||||
|
||||
if (originalScoreInfo is ScoreInfo scoreInfo)
|
||||
databasedScoreInfo ??= Query(s => s.Hash == scoreInfo.Hash);
|
||||
|
||||
if (databasedScoreInfo == null)
|
||||
{
|
||||
Logger.Log("The requested score could not be found locally.", LoggingTarget.Information);
|
||||
return null;
|
||||
}
|
||||
|
||||
return databasedScoreInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a bindable that represents the total score of a <see cref="ScoreInfo"/>.
|
||||
/// </summary>
|
||||
@ -78,7 +106,7 @@ namespace osu.Game.Scoring
|
||||
/// </remarks>
|
||||
/// <param name="score">The <see cref="ScoreInfo"/> to retrieve the bindable for.</param>
|
||||
/// <returns>The bindable containing the total score.</returns>
|
||||
public Bindable<long> GetBindableTotalScore([NotNull] ScoreInfo score) => new TotalScoreBindable(score, configManager);
|
||||
public Bindable<long> GetBindableTotalScore(ScoreInfo score) => new TotalScoreBindable(score, configManager);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a bindable that represents the formatted total score string of a <see cref="ScoreInfo"/>.
|
||||
@ -88,7 +116,7 @@ namespace osu.Game.Scoring
|
||||
/// </remarks>
|
||||
/// <param name="score">The <see cref="ScoreInfo"/> to retrieve the bindable for.</param>
|
||||
/// <returns>The bindable containing the formatted total score string.</returns>
|
||||
public Bindable<string> GetBindableTotalScoreString([NotNull] ScoreInfo score) => new TotalScoreStringBindable(GetBindableTotalScore(score));
|
||||
public Bindable<string> GetBindableTotalScoreString(ScoreInfo score) => new TotalScoreStringBindable(GetBindableTotalScore(score));
|
||||
|
||||
/// <summary>
|
||||
/// Provides the total score of a <see cref="ScoreInfo"/>. Responds to changes in the currently-selected <see cref="ScoringMode"/>.
|
||||
|
@ -147,7 +147,9 @@ namespace osu.Game.Screens.Ranking
|
||||
{
|
||||
if (state.NewValue != DownloadState.LocallyAvailable) return;
|
||||
|
||||
scoreManager.Export(Score.Value);
|
||||
ScoreInfo? databasedScoreInfo = scoreManager.GetDatabasedScoreInfo(Score.Value);
|
||||
|
||||
if (databasedScoreInfo != null) scoreManager.Export(databasedScoreInfo);
|
||||
|
||||
State.ValueChanged -= exportWhenReady;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user