1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-20 23:23:30 +08:00

Only copy across Hash and ID so statistics aren't lost

This commit is contained in:
Dean Herbert 2022-01-14 18:22:52 +09:00
parent 916b591b1b
commit 34dbde6023

View File

@ -18,7 +18,6 @@ using osu.Framework.Screens;
using osu.Framework.Threading;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Database;
using osu.Game.Graphics.Containers;
using osu.Game.IO.Archives;
using osu.Game.Online.API;
@ -1039,17 +1038,24 @@ namespace osu.Game.Screens.Play
replayReader = new LegacyByteArrayReader(stream.ToArray(), "replay.osr");
}
// the import process will re-attach managed beatmap/rulesets to this score. we don't want this for now, so create a temporary copy to import.
var importableScore = score.ScoreInfo.DeepClone();
// For the time being, online ID responses are not really useful for anything.
// In addition, the IDs provided via new (lazer) endpoints are based on a different autoincrement from legacy (stable) scores.
//
// Until we better define the server-side logic behind this, let's not store the online ID to avoid potential unique constraint
// conflicts across various systems (ie. solo and multiplayer).
score.ScoreInfo.OnlineID = -1;
importableScore.OnlineID = -1;
var imported = await scoreManager.Import(score.ScoreInfo, replayReader).ConfigureAwait(false);
var imported = await scoreManager.Import(importableScore, replayReader).ConfigureAwait(false);
// detach post-import as we want to keep using the score for display in results.
score.ScoreInfo = imported.PerformRead(s => s.Detach());
imported.PerformRead(s =>
{
// because of the clone above, it's required that we copy back the post-import hash/ID to use for availability matching.
score.ScoreInfo.Hash = s.Hash;
score.ScoreInfo.ID = s.ID;
});
}
/// <summary>