1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:47:27 +08:00

Split submission and import into two methods

This commit is contained in:
smoogipoo 2020-12-19 03:32:05 +09:00
parent cc22efaa6b
commit 772dd0287e
3 changed files with 30 additions and 12 deletions

View File

@ -103,8 +103,10 @@ namespace osu.Game.Screens.Multi.Play
return score;
}
protected override async Task<ScoreInfo> SubmitScore(Score score)
protected override async Task SubmitScore(Score score)
{
await base.SubmitScore(score);
Debug.Assert(token != null);
var tcs = new TaskCompletionSource<bool>();
@ -124,8 +126,6 @@ namespace osu.Game.Screens.Multi.Play
api.Queue(request);
await tcs.Task;
return await base.SubmitScore(score);
}
protected override void Dispose(bool isDisposing)

View File

@ -537,13 +537,23 @@ namespace osu.Game.Screens.Play
try
{
return await SubmitScore(score);
await SubmitScore(score);
}
catch (Exception ex)
{
Logger.Error(ex, "Score submission failed!");
return score.ScoreInfo;
}
try
{
await ImportScore(score);
}
catch (Exception ex)
{
Logger.Error(ex, "Score import failed!");
}
return score.ScoreInfo;
});
using (BeginDelayedSequence(RESULTS_DISPLAY_DELAY))
@ -792,15 +802,15 @@ namespace osu.Game.Screens.Play
}
/// <summary>
/// Submits the player's <see cref="Score"/>.
/// Imports the player's <see cref="Score"/> to the local database.
/// </summary>
/// <param name="score">The <see cref="Score"/> to submit.</param>
/// <returns>The submitted score.</returns>
protected virtual async Task<ScoreInfo> SubmitScore(Score score)
/// <param name="score">The <see cref="Score"/> to import.</param>
/// <returns>The imported score.</returns>
protected virtual async Task ImportScore(Score score)
{
// Replays are already populated and present in the game's database, so should not be re-imported.
if (DrawableRuleset.ReplayScore != null)
return score.ScoreInfo;
return;
LegacyByteArrayReader replayReader;
@ -810,9 +820,16 @@ namespace osu.Game.Screens.Play
replayReader = new LegacyByteArrayReader(stream.ToArray(), "replay.osr");
}
return await scoreManager.Import(score.ScoreInfo, replayReader);
await scoreManager.Import(score.ScoreInfo, replayReader);
}
/// <summary>
/// Submits the player's <see cref="Score"/>.
/// </summary>
/// <param name="score">The <see cref="Score"/> to submit.</param>
/// <returns>The submitted score.</returns>
protected virtual Task SubmitScore(Score score) => Task.CompletedTask;
/// <summary>
/// Creates the <see cref="ResultsScreen"/> for a <see cref="ScoreInfo"/>.
/// </summary>

View File

@ -37,7 +37,8 @@ namespace osu.Game.Screens.Play
return Score;
}
protected override Task<ScoreInfo> SubmitScore(Score score) => Task.FromResult(score.ScoreInfo);
// Don't re-import replay scores as they're already present in the database.
protected override Task ImportScore(Score score) => Task.CompletedTask;
protected override ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score, false);